本文主要是介绍「Python绘图」绘制太极图,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
python 绘制太极
一、预期结果
二、核心代码
import turtlepen = 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()
这篇关于「Python绘图」绘制太极图的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!