You've already forked AiraPulsar
changes
This commit is contained in:
51
testfield/vgl/elements/ basic.py
Normal file
51
testfield/vgl/elements/ basic.py
Normal file
@@ -0,0 +1,51 @@
|
||||
from vgllib import *
|
||||
import pygame
|
||||
import time
|
||||
class Line(Element):
|
||||
angle = None
|
||||
def move(self, delta, duration):
|
||||
self.add_task(group = "move", start_time = Aux.gettime(), duration = duration, delta = delta)
|
||||
def update(self):
|
||||
for i in self.tasks.get("move", []):
|
||||
self.teleport(Aux.tuple_scale(tup = i['delta'], mul = Aux.getprogress(i)))
|
||||
class Graph:
|
||||
@staticmethod
|
||||
def rect(frame, pos: tuple = (0, 0), size: tuple = (1, 1), color: tuple = (255, 255, 255), width: int = 0):
|
||||
pygame.draw.rect(frame.surface, color=color, rect=(pos[0], pos[1], size[0], size[1]), width=width)
|
||||
|
||||
@staticmethod
|
||||
def line(frame, start_pos: tuple, end_pos: tuple, color: tuple = (255, 255, 255)):
|
||||
pygame.draw.aaline(frame.surface, color, start_pos, end_pos)
|
||||
|
||||
@staticmethod
|
||||
def circle(frame, center: tuple, radius: int, color: tuple = (255, 255, 255), width: int = 0):
|
||||
pygame.draw.circle(frame.surface, color, center, radius, width)
|
||||
|
||||
@staticmethod
|
||||
def ellipse(frame, pos: tuple = (0, 0), size: tuple = (1, 1), color: tuple = (255, 255, 255), width: int = 0):
|
||||
rect=(pos[0], pos[1], size[0], size[1])
|
||||
pygame.draw.ellipse(frame.surface, color, rect, width)
|
||||
|
||||
@staticmethod
|
||||
def polygon(frame, pointlist: list, color: tuple = (255, 255, 255), width: int = 0):
|
||||
pygame.draw.polygon(frame.surface, color, pointlist, width)
|
||||
|
||||
@staticmethod
|
||||
def arc(frame, pos: tuple = (0, 0), size: tuple = (1, 1), color: tuple = (255, 255, 255), start_angle: float = 0, stop_angle: float = 3.14, width: int = 1):
|
||||
rect=(pos[0], pos[1], size[0], size[1])
|
||||
pygame.draw.arc(frame.surface, color, rect, start_angle, stop_angle, width)
|
||||
|
||||
@staticmethod
|
||||
def point(frame, pos: tuple, color: tuple = (255, 255, 255)):
|
||||
pygame.draw.point(frame.surface, color, pos)
|
||||
|
||||
@staticmethod
|
||||
def lines(frame, pointlist: list, color: tuple = (255, 255, 255)):
|
||||
pygame.draw.aalines(frame.surface, color, closed=False, points=pointlist)
|
||||
|
||||
@staticmethod
|
||||
def call(frame, method, **kwargs):
|
||||
if hasattr(Graph, method):
|
||||
getattr(Graph, method)(frame, **kwargs)
|
||||
else:
|
||||
print(f"方法 {method} 不存在")
|
Reference in New Issue
Block a user