primitives.py 文件源码

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

项目:pyphy-engine 作者: pulkitag 项目源码 文件源码
def generate_image(self, returnContext=False, 
                                cropObject=None, cropSz=None):
        '''
            returnContext: returns object of type cairo.Context
            cropObject   : the object around which image needs to be cropped
            cropSz       : the size of the image crop
        '''
        data    = np.zeros((self.ySz_, self.xSz_, 4), dtype=np.uint8)
        data[:] = self.baseCanvas_.im[:]
        surface = cairo.ImageSurface.create_for_data(data, 
                                cairo.FORMAT_ARGB32, self.xSz_, self.ySz_)
        cr      = cairo.Context(surface)
        for key, obj in self.objects_.iteritems():
            obj.imprint(cr, self.xSz_, self.ySz_)
        if returnContext:
            return data, cr
        else:
            return data
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号