本文整理汇总了Python中pygame.Rect.fill方法的典型用法代码示例。如果您正苦于以下问题:Python Rect.fill方法的具体用法?Python Rect.fill怎么用?Python Rect.fill使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pygame.Rect
的用法示例。
在下文中一共展示了Rect.fill方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Thumbnail
# 需要导入模块: from pygame import Rect [as 别名]
# 或者: from pygame.Rect import fill [as 别名]
class Thumbnail():
"""Thumbnail that has a surface, with a background color set"""
def __init__(self, width=64):
self.surface_thumb = Rect(0,0,width,width)
self.rect_thumb = Rect(0,0,width,width)
# ex [1] the standard pygame.Color("white") , same as Color("#ffffff")
self.color_bg = Color("white")
# ex [2] random color with a filter:
self.color_bg = random_color('light')
self.color_border = random_color('dark')
# create empty surface; fill it
self.surface_thumb = pygame.Surface([width, width])
self.surface_thumb.fill(self.color_bg)
def fill(self):
"""clear thumb."""
self.surface_thumb.fill(self.color_bg)
def move(self, x, y):
"""move all rects/images together"""
self.rect_thumb.move_ip(x,y)
def draw(self, screen):
screen.blit(self.surface_thumb, self.rect_thumb)
def __str__(self): return "<Thumbnail( bg={bg}, rect_thumb={rect_thumb} >".format(bg=self.color_bg, rect_thumb=self.rect_thumb)