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


Python Rect.fill方法代码示例

本文整理汇总了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)
开发者ID:Hug00,项目名称:ninmonkey,代码行数:30,代码来源:colortest.py


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