primitives.py 文件源码

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

项目:pyphy-engine 作者: pulkitag 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号