本文整理汇总了Python中display.Display.translate方法的典型用法代码示例。如果您正苦于以下问题:Python Display.translate方法的具体用法?Python Display.translate怎么用?Python Display.translate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类display.Display
的用法示例。
在下文中一共展示了Display.translate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: draw
# 需要导入模块: from display import Display [as 别名]
# 或者: from display.Display import translate [as 别名]
def draw(self, surface, total_surface):
"""
Calculate the scaling and display to the inputted surface.
`surface` - The `Surface` being drawn to.
`total_surface` - The `Surface` being copied from.
"""
scale = self.getScale()
# Optimization, no need to do scaling when the scale is 1.
if scale == 1:
self._display.update(total_surface, Display.translate(total_surface.get_rect(), self))
else:
# Optimization, caches the `Surface` object so long as the scale isn't changing.
if scale != self._lastScale:
self._surfaceCache = Surface((self.w, self.h))
self._surfaceCache.blit(total_surface, (-self.x, -self.y))
scaleTo = self.unscaled()
transform.scale(self._surfaceCache, (scaleTo.w, scaleTo.h), self._displaySurfaceCache)
self._lastScale = scale
self._display.draw(surface)