Example #1
0
    def on_render(self, g):

        rect = Rect(0, 0, cfg.SCREEN_WIDTH / self.xslices,
                    cfg.SCREEN_HEIGHT / self.yslices)

        for ir, row in enumerate(self.board):
            rect.top = rect.height * ir
            for ic, cell in enumerate(row):
                if cell:
                    rect.left = rect.width * ic
                    cell.on_render(g, rect)
Example #2
0
 def _load(self):
     movie=media.movies.load(self.file)
     self.loaded=True
     screen=pyzzle.screen.get_rect()
     rect=Rect((0,0),movie.get_size())
     rect.center=screen.center
     if self.rectRel:
         left,top,width,height=self.rectRel
         if width:   rect.width =width *screen.width
         if height:  rect.height=height*screen.height
         rect.center=screen.center
         if left:    rect.left=left*screen.width
         if top:     rect.top=top*screen.height
     self._rect=rect
     self.surface=pygame.surface.Surface((rect.width, rect.height))
     movie.set_display(self.surface)
Example #3
0
def adjust_rect(rect: Rect,
                x: int,
                y: int,
                align: str = "center",
                vertical_align: str = "middle") -> Rect:
    if align == "left":
        rect.left = x
    elif align == "right":
        rect.right = x
    else:
        rect.centerx = x

    if vertical_align == "top":
        rect.top = y
    elif vertical_align == "bottom":
        rect.bottom = y
    else:
        rect.centery = y
    return rect