当前位置: 首页>>代码示例>>Python>>正文


Python Surface.drawImage方法代码示例

本文整理汇总了Python中surface.Surface.drawImage方法的典型用法代码示例。如果您正苦于以下问题:Python Surface.drawImage方法的具体用法?Python Surface.drawImage怎么用?Python Surface.drawImage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在surface.Surface的用法示例。


在下文中一共展示了Surface.drawImage方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: rotate

# 需要导入模块: from surface import Surface [as 别名]
# 或者: from surface.Surface import drawImage [as 别名]
    def rotate(self, surface, angle):
        """
        Return Surface rotated by the given angle.
        """
        if not angle:
            return surface.copy()
        theta = angle*self.deg_rad
        width_i = surface.get_width()
        height_i = surface.get_height()
        cos_theta = math.fabs( math.cos(theta) )
        sin_theta = math.fabs( math.sin(theta) )
        width_f = int( (width_i*cos_theta)+(height_i*sin_theta) )
        height_f = int( (width_i*sin_theta)+(height_i*cos_theta) )
        if width_f%2:
            width_f += 1
        if height_f%2:
            height_f += 1
        surf = Surface((width_f,height_f))
        surf.saveContext()
        surf.translate(width_f/2.0, height_f/2.0)
        surf.rotate(-theta)
        surf.drawImage(surface.canvas, -width_i/2, -height_i/2)    #pyjs0.8 *.canvas
#        surf.drawImage(surface, -width_i/2, -height_i/2)
        surf.restoreContext()
        return surf
开发者ID:Lucytheanimefan,项目名称:Center-for-Advanced-HindSight-Games,代码行数:27,代码来源:transform.py

示例2: convert_image

# 需要导入模块: from surface import Surface [as 别名]
# 或者: from surface.Surface import drawImage [as 别名]
 def convert_image(self, image):
     """
     Return the image as a Surface.
     """
     if env.canvas._isCanvas:
         img = image.getElement()
         surface = Surface((img.width,img.height))
         surface.drawImage(image, 0, 0)
     else:
         surface = Surf(image)
     return surface
开发者ID:Lucytheanimefan,项目名称:Center-for-Advanced-HindSight-Games,代码行数:13,代码来源:image.py

示例3: scale

# 需要导入模块: from surface import Surface [as 别名]
# 或者: from surface.Surface import drawImage [as 别名]
    def scale(self, surface, size, dest=None):
        """
        Return Surface resized by the given size.
        An optional destination surface can be provided.
        """
        if not dest:
            surf = Surface(size)
        else:
            surf = dest
        surf.drawImage(surface.canvas, 0, 0, surface.get_width(), surface.get_height(), 0, 0, size[0], size[1])    #pyjs0.8 *.canvas
#        surf.drawImage(surface, 0, 0, surface.get_width(), surface.get_height(), 0, 0, size[0], size[1])
        return surf
开发者ID:Lucytheanimefan,项目名称:Center-for-Advanced-HindSight-Games,代码行数:14,代码来源:transform.py

示例4: flip

# 需要导入模块: from surface import Surface [as 别名]
# 或者: from surface.Surface import drawImage [as 别名]
    def flip(self, surface, xbool=True, ybool=False):
        """
        Return Surface that is flipped horizontally, vertically, or both.
        """
        surf = Surface((surface.get_width(),surface.get_height()))
        surf.saveContext()
        if xbool and ybool:
            surf.translate(surface.get_width(), surface.get_height())
            surf.scale(-1, -1)
        elif xbool:
            surf.translate(surface.get_width(), 0)
            surf.scale(-1, 1)
        elif ybool:
            surf.translate(0, surface.get_height())
            surf.scale(1, -1)
        surf.drawImage(surface.canvas, 0, 0)    #pyjs0.8 *.canvas
#        surf.drawImage(surface, 0, 0)
        surf.restoreContext()
        return surf
开发者ID:Lucytheanimefan,项目名称:Center-for-Advanced-HindSight-Games,代码行数:21,代码来源:transform.py


注:本文中的surface.Surface.drawImage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。