「Python绘图」绘制太极图

python 绘制太极

一、预期结果

二、核心代码

复制代码
import turtle

pen = turtle.Turtle()

print("开始绘制太极")

radius = 100
pen.color("black", "black")
pen.begin_fill()
pen.circle(radius/2, 180)
pen.circle(radius, 180)
pen.left(180)
pen.circle(-radius/2, 180)
pen.end_fill() 


pen.left(90)
pen.pu()
pen.fd(radius*0.35)
pen.right(90)
pen.pd()

print("绘制小圆")
pen.color("white", "white")
pen.begin_fill()
pen.circle(radius*0.15)
pen.end_fill() 


pen.left(90)
pen.up()
pen.backward(radius*0.7)
pen.down()
pen.left(90)

print("绘制小圆")
pen.color("black", "black")
pen.begin_fill()
pen.circle(radius*0.15)
pen.end_fill()

print("补大圆")
pen.right(90)
pen.pu()
pen.backward(radius*0.65)
pen.right(90)
pen.pd()
pen.circle(radius, 180)
print("绘制完成")
pen.ht()
turtle.done()
相关推荐
lhbian3 分钟前
C++、C与易语言:编程语言对比解析
c语言·开发语言·c++
꧁细听勿语情꧂4 分钟前
数据结构概念和算法、时间复杂度、空间复杂度引入
c语言·开发语言·数据结构·算法
weixin_381288184 分钟前
PyTorch中高效实现SOM邻域权重更新:向量化替代双重循环
jvm·数据库·python
Yuanxl9039 分钟前
pytorch-优化器
人工智能·pytorch·python
m0_6178814211 分钟前
在 Go 中声明包级全局 Map 的正确方法
jvm·数据库·python
Polar__Star11 分钟前
Redis怎样管理废弃的数据集合_利用EXPIRE指令为任意数据类型设置生命周期
jvm·数据库·python
weixin_5689960611 分钟前
CSS布局如何解决父级因全是绝对定位导致本身没高度的问题
jvm·数据库·python
weixin_3812881812 分钟前
MySQL无法通过网络连接服务器_检查bind-address与访问权限
jvm·数据库·python
Irene199122 分钟前
Python 中的 round() 函数不是严格的“四舍五入“,而是采用银行家舍入法(Bankers‘ Rounding)
python
ZC跨境爬虫22 分钟前
3D 地球卫星轨道可视化平台开发 Day9(AI阈值调控+小众卫星识别+低Token测试模式实战)
人工智能·python·3d·信息可视化·json