primitives.py 文件源码

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

项目:pyphy-engine 作者: pulkitag 项目源码 文件源码
def imprint(self, cr, xSz, ySz):
        '''
            xSz, ySz: Size of the canvas on which imprint has to be made. 
        '''
        #Create Source
        y, x  = self.pos_.y_asint(), self.pos_.x_asint()        
        srcIm = np.zeros((ySz, xSz, 4), dtype=np.uint8)
        #print "pos: (%f, %f), sz:(%f, %f)" % (x, y, self.imSzX_, self.imSzY_)
        srcIm[y : y + self.imSzY_, x : x + self.imSzX_,:] = self.data_.im[:] 
        surface = cairo.ImageSurface.create_for_data(srcIm, 
                                cairo.FORMAT_ARGB32, xSz, ySz)
        cr.set_source_surface(surface)  
        #Create Mask
        pt1, pt2, pt3, pt4 = self.pts_  
        cr.move_to(pt1.x(), pt1.y())
        cr.line_to(pt2.x(), pt2.y())
        cr.line_to(pt3.x(), pt3.y())
        cr.line_to(pt4.x(), pt4.y())
        cr.line_to(pt1.x(), pt1.y())
        #Fill source into the mask
        cr.fill()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号