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()