word_renderer.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:text-renderer 作者: cjnolet 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号