A turtle graphics library based on PyQt5 with various drawing functions
Project description
StarsTurtle1.0.3
StarsTurtle 是一个基于 PyQt5 的海龟图形库,提供了丰富的绘图功能,支持多种形状、填充模式、画笔样式等功能。
新增功能:
1.增加抗锯齿功能。 2.增加保存图片功能。
安装
请先安装PyQt5
pip install PyQt5
pip install starsturtle
代码示例:
# main.py - StarsTurtle 使用示例
from StarsTurtle.StarsTurtle import *
import time
def demo():
# 设置画笔速度
speed(5) # 速度为5(1-10之间)
# 绘制多个图形展示功能
# 绘制一个蓝色正方形
draw_square(100, BLUE, 100, 100)
# 绘制一个绿色三角形
draw_triangle(100, GREEN, 300, 100)
# 绘制一个红色圆形
draw_circle(50, RED, x=200, y=300)
# 绘制一个多边形
draw_polygon(6, 60, YELLOW, 500, 200)
# 使用默认海龟绘制一个五角星
penup()
goto(400, 300)
pendown()
for i in range(5):
forward(100)
left(144)
# 绘制一个填充的矩形
penup()
goto(500, 400)
pendown()
begin_fill(CYAN)
draw_rectangle(120, 80, CYAN)
end_fill()
# 创建另一个海龟并演示多海龟功能
turtle2 = create_turtle(200, 200, 0, GREEN, 3, "turtle")
turtle2.width = 3 # 直接赋值,而不是函数调用
turtle2.forward(100)
turtle2.left(90)
turtle2.forward(100)
turtle2.left(90)
turtle2.forward(100)
turtle2.left(90)
turtle2.forward(100)
# 添加文字
text("StarsTurtle 绘图示例", 300, 550, WHITE, 16, "SimHei")
# 在done()之后执行保存图片(使用线程来实现)
import threading
def save_after_done():
time.sleep(3) # 等待动画完成
save_image("my_artwork.png", "PNG")
print("绘图完成,图片已保存!")
# 启动保存线程
save_thread = threading.Thread(target=save_after_done)
save_thread.daemon = True
save_thread.start()
# 显示窗口和执行动画
done()
if __name__ == "__main__":
demo()
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
starsturtle-1.0.3.tar.gz
(11.6 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file starsturtle-1.0.3.tar.gz.
File metadata
- Download URL: starsturtle-1.0.3.tar.gz
- Upload date:
- Size: 11.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fdee871b574e004619fb3ae134f78b31fc3c2e50de219a93fa271d0e431263dc
|
|
| MD5 |
c14ce5b3c5f755eda0b1c0eceed573d9
|
|
| BLAKE2b-256 |
8be6fc7aabce621054e58247e0c562b9ad4355a049472e3af5bd1772ecb52816
|
File details
Details for the file starsturtle-1.0.3-py3-none-any.whl.
File metadata
- Download URL: starsturtle-1.0.3-py3-none-any.whl
- Upload date:
- Size: 10.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f5b3ded0781f9fa2a8f1f8870647218f391adb422a75836c776df4e722da225f
|
|
| MD5 |
36d6c164ca013870cceb8da7b9bfed39
|
|
| BLAKE2b-256 |
5747aed6d063127a149a44f2e5825f7aae51742a90b6b8411c26bc94112f024e
|