def get_bordershadow(self, bg_arr, colour):
"""
Gets a border/shadow with the movement state [top, right, bottom, left].
Inset or outset is random.
"""
bs = self.borderstate.get_sample()
outset = bs['outset']
width = bs['width']
position = bs['position']
# make a copy
border_arr = bg_arr.copy()
# re-colour
border_arr[...,0] = colour
if outset:
# dilate black (erode white)
border_arr[...,1] = ndimage.grey_dilation(border_arr[...,1], size=(width, width))
border_arr = self.arr_scroll(border_arr, position[0], position[1])
# canvas = 255*n.ones(bg_arr.shape)
# canvas = grey_blit(border_arr, canvas)
# canvas = grey_blit(bg_arr, canvas)
# pyplot.imshow(canvas[...,0], cmap=cm.Greys_r)
# pyplot.show()
return border_arr, bg_arr
else:
# erode black (dilate white)
border_arr[...,1] = ndimage.grey_erosion(border_arr[...,1], size=(width, width))
return bg_arr, border_arr
评论列表
文章目录