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
评论列表
文章目录