「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()
相关推荐
阿里嘎多学长3 分钟前
2026-08-24 GitHub 热点项目精选
开发语言·程序员·github·代码托管
SLD_Allen1 小时前
Go语言runtime全景
开发语言·javascript·golang
Elastic 中国社区官方博客1 小时前
OpenTelemetry Java 扩展:无需分叉 agent 即可自定义追踪
java·大数据·运维·开发语言·数据库·人工智能·elasticsearch
不灭的黄金瞳1231 小时前
C语言手写顺序表
c语言·开发语言·数据结构
阿无,1 小时前
Java多线程面试题之AQS
java·开发语言
数据狐(Datafox)1 小时前
京东商品列表API技术解析与落地应用(含标准 JSON 示例)
java·大数据·前端·人工智能·python·数据分析·json
豆沙沙包?1 小时前
C++~~~set容器、map容器(p57-P69)
开发语言·c++
量化吞吐机1 小时前
2026年下半年手工交易规则走向量化表达,产品该先接住哪一步
人工智能·python
Metaphor6922 小时前
使用 Python 读取和删除 Excel 文件属性
python·excel