language.py 文件源码

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

项目:TikZ 作者: ellisk42 项目源码 文件源码
def draw(self,context = None, adjustCanvasSize = False):
        if adjustCanvasSize:
            x0,y0,x1,y1 = self.extent()
            self = self.translate(-x0 + 1,-y0 + 1)
            x0,y0,x1,y1 = self.extent()
            W = max([256, 16*(y1 + 1), 16*(x1 + 1)])
            H = W
        else:
            W = 256
            H = 256

        if context == None:
            data = np.zeros((W,H), dtype=np.uint8)
            surface = cairo.ImageSurface.create_for_data(data,cairo.FORMAT_A8,W,H)
            context = cairo.Context(surface)
        for l in self.lines: l.draw(context)
        data = np.flip(data, 0)/255.0
        if adjustCanvasSize:
            import scipy.ndimage
            return scipy.ndimage.zoom(data,W/256.0)
        return data
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号