44 lines
1.9 KiB
Python
44 lines
1.9 KiB
Python
import pygame
|
|
|
|
class Graph:
|
|
def rect(frame, position: tuple = (0, 0), size: tuple = (1, 1), color: tuple = (255, 255, 255), width: int = 0):
|
|
pygame.draw.rect(frame.surface, color=color, rect=(position[0], position[1], size[0], size[1]), width=width)
|
|
|
|
def line(frame, start_pos: tuple, end_pos: tuple, color: tuple = (255, 255, 255)):
|
|
pygame.draw.aaline(frame.surface, color, start_pos, end_pos)
|
|
|
|
def circle(frame, center: tuple, radius: int, color: tuple = (255, 255, 255), width: int = 0):
|
|
pygame.draw.circle(frame.surface, color, center, radius, width)
|
|
|
|
def ellipse(frame, rect: tuple, color: tuple = (255, 255, 255), width: int = 0):
|
|
pygame.draw.ellipse(frame.surface, color, rect, width)
|
|
|
|
def polygon(frame, pointlist: list, color: tuple = (255, 255, 255), width: int = 0):
|
|
pygame.draw.polygon(frame.surface, color, pointlist, width)
|
|
|
|
def arc(frame, rect: tuple, color: tuple = (255, 255, 255), start_angle: float = 0, stop_angle: float = 3.14, width: int = 1):
|
|
pygame.draw.arc(frame.surface, color, rect, start_angle, stop_angle, width)
|
|
|
|
def points(frame, pos: tuple, color: tuple = (255, 255, 255)):
|
|
pygame.draw.point(frame.surface, color, pos)
|
|
|
|
def lines(frame, pointlist: list, color: tuple = (255, 255, 255), closed: bool = False):
|
|
pygame.draw.aalines(frame.surface, color, closed, pointlist)
|
|
|
|
class Frame(object):
|
|
name = None
|
|
size = None
|
|
surface = None
|
|
is_hide = False
|
|
def __init__(self, name: str, size: tuple):
|
|
self.name = name
|
|
self.surface = pygame.Surface(size, flags=pygame.HWSURFACE)
|
|
print("初始化子模块")
|
|
def show(self, window, position: tuple):
|
|
if not self.is_hide:
|
|
window.blit(self.surface, position)
|
|
def set_visible(self, newstat=True):
|
|
self.is_hide = newstat
|
|
def set_position(self, newposition):
|
|
self.position = newposition
|