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


Python Rect.unionall方法代码示例

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


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

示例1: screen

# 需要导入模块: from pygame import Rect [as 别名]
# 或者: from pygame.Rect import unionall [as 别名]
 def screen(self,surface,pos,fgcolor=(128,128,125),font=None,interline=0):
     fgcolor = [fgcolor]
     px,y = pos
     mono = True
     if not font: font = Text.defaultfont
     if font.size('i')!=font.size('x'): mono = False
     char_w,char_h = font.size(' ')
     char_h += interline
     style_cmd = {'+':True,'-':False,'b':font.set_bold,'i':font.set_italic,'u':font.set_underline}
     bz = self.baliz
     def set_style(pos):
         while True:
             if bz and pos == bz[0][0]: 
                 _,mode,style,color,value = bz.pop(0)
                 if mode: style_cmd[style](style_cmd[mode])
                 elif color:
                     if value: fgcolor.append(Color(int(value,16)<<8))
                     else: fgcolor.pop()
             else: break
     rec = Rect(pos,(0,0))
     pos = 0
     set_style(pos)
     if mono:
         for lines in self:
             for line in lines:
                 x = px
                 for char in line:
                     rec = rec.unionall([(surface.blit(font.render(char,1,fgcolor[-1]),(x,y))),rec])
                     x += char_w
                     pos += 1
                     set_style(pos)
                 y += char_h
             pos += 1
             set_style(pos)
         return rec
     for lines in self:
         for line in lines:
             x = px
             for char in line:
                 x = surface.blit(font.render(char,1,fgcolor[-1]),(x,y))
                 rec = rec.unionall([x,rec])
                 x = x.right
                 pos += 1
                 set_style(pos)
             y += char_h
         pos += 1
         set_style(pos)
     return rec
开发者ID:602p,项目名称:spacegame,代码行数:50,代码来源:text.py

示例2: test_unionall

# 需要导入模块: from pygame import Rect [as 别名]
# 或者: from pygame.Rect import unionall [as 别名]
 def test_unionall( self ):
     r1 = Rect( 0, 0, 1, 1 )
     r2 = Rect( -2, -2, 1, 1 )
     r3 = Rect( 2, 2, 1, 1 )
     
     r4 = r1.unionall( [r2,r3] )
     self.assertEqual( Rect(-2, -2, 5, 5), r4 )
开发者ID:CTPUG,项目名称:pygame_cffi,代码行数:9,代码来源:rect_test.py

示例3: update

# 需要导入模块: from pygame import Rect [as 别名]
# 或者: from pygame.Rect import unionall [as 别名]
    def update (self, **kwargs):
        """V.update (...) -> None

        Updates the ViewPort.

        Updates the ViewPort and causes its parent to update itself on
        demand.
        """
        if not self.dirty:
            border = base.GlobalStyle.get_border_size \
                     (self.__class__, self.style,
                      StyleInformation.get ("VIEWPORT_BORDER"))
            resize = kwargs.get ("resize", False)

            children = kwargs.get ("children", {})
            blit = self.image.blit
            items = children.items ()

            # Clean up the dirty areas on the widget.
            vals = []
            for child, rect in items:
                blit (self._bg, rect, rect)

                # r will be the area for the blit.
                r = Rect (abs (self.hadjustment), abs (self.vadjustment),
                          self.width - 2 * border, self.height - 2 * border)
                blit (child.image, (border, border), r)
                vals.append (r)

            # If a parent's available, reassign the child rects, so that
            # they point to the absolute position on the widget and build
            # one matching them all for an update.
            if self.parent:
                rect = Rect (self._oldrect)
                if len (vals) != 0:
                    for r in vals:
                        r.x += self.x
                        r.y += self.y
                    rect.unionall (vals[1:])
                self.parent.update (children={ self : rect }, resize=resize)
            self._lock = max (self._lock - 1, 0)
        else:
            Bin.update (self, **kwargs)
开发者ID:BGCX067,项目名称:eyestabs-svn-to-git,代码行数:45,代码来源:ViewPort.py


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