def get_rectangle_im(sz=gm.Point(4,100), fColor=Color(1.0, 0.0, 0.0)):
data = np.zeros((sz.y_asint(), sz.x_asint(), 4), dtype=np.uint8)
surface = cairo.ImageSurface.create_for_data(data,
cairo.FORMAT_ARGB32, sz.x_asint(), sz.y_asint())
cr = cairo.Context(surface)
#Create a transparent source
cr.set_source_rgba(1.0, 1.0, 1.0, 0.0)
cr.paint()
# Make rectangle and fill in the desired color
cr.set_source_rgba(fColor.b, fColor.g, fColor.r, fColor.a)
cr.rectangle(0, 0, sz.x_asint(), sz.y_asint())
cr.fill()
#cr.destroy()
return cr, data
评论列表
文章目录