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


Python Surface.createGraphics方法代码示例

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


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

示例1: scale

# 需要导入模块: from surface import Surface [as 别名]
# 或者: from surface.Surface import createGraphics [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, BufferedImage.TYPE_INT_ARGB)
     else:
         surf = dest
     g2d = surf.createGraphics()
     g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR)
     g2d.drawImage(surface, 0, 0, size[0], size[1], None)
     g2d.dispose()
     return surf
开发者ID:YuliReiri,项目名称:WinLifeGame,代码行数:16,代码来源:transform.py

示例2: rotate

# 需要导入模块: from surface import Surface [as 别名]
# 或者: from surface.Surface import createGraphics [as 别名]
 def rotate(self, surface, angle):
     """
     Return Surface rotated by the given angle.
     """
     theta = angle*self.deg_rad
     width_i = surface.getWidth()
     height_i = surface.getHeight()
     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) )
     surf = Surface((width_f,height_f), BufferedImage.TYPE_INT_ARGB)
     at = AffineTransform()
     at.rotate(-theta, width_f/2, height_f/2)
     g2d = surf.createGraphics()
     ot = g2d.getTransform()
     g2d.setTransform(at)
     g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR)
     g2d.drawImage(surface, (width_f-width_i)//2, (height_f-height_i)//2, None)
     g2d.setTransform(ot)
     g2d.dispose()
     return surf
开发者ID:bowbahdoe,项目名称:Keys,代码行数:24,代码来源:transform.py


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