def setup_context(width, height, out_width=0):
scale = 1
if out_width >= MIN_WIDTH:
scale = out_width / width
surface = cairo.ImageSurface(
cairo.FORMAT_ARGB32, int(round(width * scale)), int(round(height * scale)))
ctx = cairo.Context(surface)
ctx.scale(scale, scale)
ctx.set_source_rgba(0, 0, 0, 0) # transparent bg
ctx.paint()
return (ctx, surface)
评论列表
文章目录