「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()
相关推荐
牛客企业服务1 分钟前
2025年AI面试推荐榜单,数字化招聘转型优选
人工智能·python·算法·面试·职场和发展·金融·求职招聘
charlie11451419113 分钟前
深入理解Qt的SetWindowsFlags函数
开发语言·c++·qt·原理分析
胡斌附体13 分钟前
linux测试端口是否可被外部访问
linux·运维·服务器·python·测试·端口测试·临时服务器
likeGhee1 小时前
python缓存装饰器实现方案
开发语言·python·缓存
whoarethenext1 小时前
使用 C++/Faiss 加速海量 MFCC 特征的相似性搜索
开发语言·c++·faiss
项目題供诗1 小时前
黑马python(二十五)
开发语言·python
读书点滴1 小时前
笨方法学python -练习14
java·前端·python
慌糖1 小时前
RabbitMQ:消息队列的轻量级王者
开发语言·javascript·ecmascript
笑衬人心。1 小时前
Ubuntu 22.04 修改默认 Python 版本为 Python3 笔记
笔记·python·ubuntu
蛋仔聊测试2 小时前
Playwright 中 Page 对象的常用方法详解
python