Exemple #1
0
 def draw_pie(self, x, y, colour, angle, size, x_offset=0, y_offset=0):
     gfxdraw.pie(self.screen, 
                 x + x_offset, 
                 y + y_offset, 
                 self.vs/2,
                 angle -size,
                 angle +size, 
                 colour) 
Exemple #2
0
 def render(self, screen):
     """Draw some animation before spawn."""
     if 0 < self.cooldown < 1 and self.spawnsLeft:
         x, y = self.rect.center
         r = self.rect.w * (1.0 - self.cooldown) * 0.5
         endAngle = self.startAngle + (1.0 - self.cooldown) * 360
         gfxdraw.pie(screen, x, y, int(r), self.startAngle, int(endAngle),
                     (255, 255, 255))
Exemple #3
0
    def Draw(self, TB, ccolor=Color("orange"), tcolor=Color("black")):
        pygame.draw.circle(TB.background, ccolor, self.pos, self.radius, 1)
        TB.RenderText(18, self.caption,
                      (self.pos[0], self.pos[1] - self.radius - 25), tcolor)

        # pygame.gfxdraw.pie(TB.background,
        #                    Color("blue"),
        #                    Rect(self.pos[0]-self.radius,
        #                         self.pos[1]-self.radius,
        #                         self.radius*2,self.radius*2),
        #                    math.radians(self.forward_angle_range[0]),
        #                    math.radians(self.forward_angle_range[1])
        # )
        gfxdraw.pie(TB.background, self.pos[0], self.pos[1], self.radius,
                    360 - self.forward_angle_range[1],
                    360 - self.forward_angle_range[0], Color("darkgreen"))
        gfxdraw.pie(TB.background, self.pos[0], self.pos[1], self.radius,
                    360 - self.backward_angle_range[1],
                    360 - self.backward_angle_range[0], Color("purple"))
    def pie(self, x, y, r, start, end, color):
        """内部の塗りつぶされた円弧を描画します.

        Parameters
        ----------
        x : int
            円の中心のx座標.
        y : int
            円の中心のy座標.
        r : int
            円の半径.
        start : float
            弧の始点に対応する角度.
            単位はラジアン.
        end : float
            弧の終点に対応する角度.
            単位はラジアン.
        color : tuple of int
            描画に使用される色を指定します.

        """

        return gfx.pie(self.pg.screen, x, y, r, start, end, color)
Exemple #5
0
    def _draw(self, deco: List[Tuple[int, str, Any]], surface: 'pygame.Surface') -> None:
        """
        Draw.

        :param deco: Decoration list
        :param surface: Pygame surface
        :return: None
        """
        if len(deco) == 0:
            return
        rect = self._obj.get_rect()

        for d in deco:
            dtype, decoid, data = d
            if not self._decor_enabled[decoid]:
                continue

            if dtype == DECORATION_POLYGON:
                points, color, filled, width, gfx, kwargs = data
                points = self._update_pos_list(rect, decoid, points, **kwargs)
                if gfx:
                    if filled:
                        gfxdraw.filled_polygon(surface, points, color)
                    else:
                        gfxdraw.polygon(surface, points, color)
                else:
                    pydraw.polygon(surface, color, points, width)

            elif dtype == DECORATION_CIRCLE:
                points, r, color, filled, width, gfx, kwargs = data
                points = self._update_pos_list(rect, decoid, points, **kwargs)
                x, y = points[0]
                if filled:
                    if gfx:
                        gfxdraw.filled_circle(surface, x, y, r, color)
                    else:
                        pydraw.circle(surface, color, (x, y), r)
                else:
                    pydraw.circle(surface, color, (x, y), r, width)

            elif dtype == DECORATION_SURFACE or dtype == DECORATION_BASEIMAGE or dtype == DECORATION_TEXT:
                pos, surf, centered, kwargs = data
                if isinstance(surf, pygame_menu.BaseImage):
                    surf = surf.get_surface(new=False)
                pos = self._update_pos_list(rect, decoid, pos, **kwargs)[0]
                surfrect = surf.get_rect()
                surfrect.x += pos[0]
                surfrect.y += pos[1]
                if centered:
                    surfrect.x -= surfrect.width / 2
                    surfrect.y -= surfrect.height / 2
                surface.blit(surf, surfrect)

            elif dtype == DECORATION_ELLIPSE:
                pos, rx, ry, color, filled, kwargs = data
                pos = self._update_pos_list(rect, decoid, pos, **kwargs)[0]
                if filled:
                    gfxdraw.filled_ellipse(surface, pos[0], pos[1], rx, ry, color)
                else:
                    gfxdraw.ellipse(surface, pos[0], pos[1], rx, ry, color)

            elif dtype == DECORATION_CALLABLE:
                data(surface, self._obj)

            elif dtype == DECORATION_CALLABLE_NO_ARGS:
                data()

            elif dtype == DECORATION_TEXTURE_POLYGON:
                pos, texture, tx, ty, kwargs = data
                pos = self._update_pos_list(rect, decoid, pos, **kwargs)
                if isinstance(texture, pygame_menu.BaseImage):
                    texture = texture.get_surface()
                gfxdraw.textured_polygon(surface, pos, texture, tx, ty)

            elif dtype == DECORATION_ARC:
                points, r, ia, fa, color, width, gfx, kwargs = data
                points = self._update_pos_list(rect, decoid, points, **kwargs)
                x, y = points[0]
                rectarc = pygame.Rect(x - r, y - r, x + 2 * r, y + 2 * r)
                if gfx:
                    gfxdraw.arc(surface, x, y, r, ia, fa, color)
                else:
                    pydraw.arc(surface, color, rectarc, ia / (2 * pi), fa / (2 * pi), width)

            elif dtype == DECORATION_PIE:
                points, r, ia, fa, color, kwargs = data
                points = self._update_pos_list(rect, decoid, points, **kwargs)
                x, y = points[0]
                gfxdraw.pie(surface, x, y, r, ia, fa, color)

            elif dtype == DECORATION_BEZIER:
                points, color, steps, kwargs = data
                points = self._update_pos_list(rect, decoid, points, **kwargs)
                gfxdraw.bezier(surface, points, steps, color)

            elif dtype == DECORATION_RECT:
                drect: 'pygame.Rect'
                pos, drect, color, width, kwargs = data
                pos = self._update_pos_list(rect, decoid, pos, **kwargs)[0]
                drect = drect.copy()
                drect.x += pos[0]
                drect.y += pos[1]
                pygame.draw.rect(surface, color, drect, width)

            elif dtype == DECORATION_PIXEL:
                pos, color, kwargs = data
                pos = self._update_pos_list(rect, decoid, pos, **kwargs)[0]
                gfxdraw.pixel(surface, pos[0], pos[1], color)

            elif dtype == DECORATION_LINE:
                pos, color, width, kwargs = data
                pos = self._update_pos_list(rect, decoid, pos, **kwargs)
                pydraw.line(surface, color, pos[0], pos[1], width)

            else:
                raise ValueError('unknown decoration type')
Exemple #6
0
                print(pygame.ver)
                key = pygame.ver

            if event.key == pygame.K_q:
                exit()
            if event.key == pygame.K_e:
                #color = (random.randrange(50,250,10),random.randrange(50,250,10),random.randrange(50,250,10))
                pygame.draw.rect(fenster, (0, 0, 0), (0, 0, xmax, ymax))
                pygame.display.flip()
            if event.key == pygame.K_w:
                color = (random.randrange(50, 250,
                                          10), random.randrange(50, 250, 10),
                         random.randrange(50, 250, 10))
            if event.key == pygame.K_t:
                gfx.box(fenster, (20, 20, 40, 40), color)
                gfx.pie(fenster, 80, 80, 30, 20, 340, color)

            if event.key == pygame.K_0:
                werkzeug = 0
            if event.key == pygame.K_1:
                werkzeug = 1
            if event.key == pygame.K_2:
                werkzeug = 2
            if event.key == pygame.K_3:
                werkzeug = 3

        if event.type == pygame.KEYUP:
            print("stop")
    x = 0
    for event in pygame.mouse.get_pressed():
        if x == 0 and event == 1:
Exemple #7
0
 def draw_pie(self, x, y, colour, angle, size, x_offset=0, y_offset=0):
     gfxdraw.pie(self.screen, x + x_offset, y + y_offset, self.vs / 2,
                 angle - size, angle + size, colour)