Improvement

This commit is contained in:
2025-03-10 03:10:22 +08:00
commit afd1a37c0c
36 changed files with 1599 additions and 0 deletions

59
pulsar/1.py Normal file
View File

@@ -0,0 +1,59 @@
import pygame
import sys
# 初始化 Pygame
pygame.init()
# 设置窗口大小
width, height = 800, 600
screen = pygame.display.set_mode((width, height))
pygame.display.set_caption("Pygame Draw Example")
# 定义颜色
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
RED = (255, 0, 0)
GREEN = (0, 255, 0)
BLUE = (0, 0, 255)
YELLOW = (255, 255, 0)
# 主循环
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
# 填充背景
screen.fill(WHITE)
# 绘制线条
pygame.draw.line(screen, RED, (50, 50), (200, 50), 5)
pygame.draw.aaline(screen, BLUE, (50, 100), (200, 100))
# 绘制矩形
pygame.draw.rect(screen, GREEN, (50, 150, 150, 100), 0) # 填充矩形
pygame.draw.rect(screen, BLACK, (250, 150, 150, 100), 5) # 边框矩形
# 绘制圆形
pygame.draw.circle(screen, YELLOW, (400, 200), 50, 0) # 填充圆形
pygame.draw.circle(screen, BLACK, (500, 200), 50, 5) # 边框圆形
# 绘制椭圆
pygame.draw.ellipse(screen, BLUE, (50, 300, 200, 100), 0) # 填充椭圆
pygame.draw.ellipse(screen, BLACK, (300, 300, 200, 100), 5) # 边框椭圆
# 绘制多边形
points = [(600, 400), (700, 300), (800, 400), (700, 500)]
pygame.draw.polygon(screen, GREEN, points, 0) # 填充多边形
pygame.draw.polygon(screen, BLACK, points, 5) # 边框多边形
# 绘制弧
pygame.draw.arc(screen, RED, (50, 450, 200, 100), 0, 3.14, 5) # 弧
# 更新显示
pygame.display.flip()
# 退出 Pygame
pygame.quit()
sys.exit()

4
pulsar/README.md Normal file
View File

@@ -0,0 +1,4 @@
# Pulsar - 控制器侧载端
Pulsar(脉冲星) 是 AiraPulsar 飞行控制系统的控制器侧载端, 项目亦由此而得名
Pulsar(控制器) 通过 Moon(中继服务器) 进行通讯, 给 Comet(飞行器) 发送指令

43
pulsar/graph.py Normal file
View File

@@ -0,0 +1,43 @@
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

1
pulsar/lib Symbolic link
View File

@@ -0,0 +1 @@
../lib