大家好,本文将围绕用python的turtle画炫酷的图展开说明,python中turtle画蝴蝶代码是一个很多人都想弄明白的事情,想搞清楚python turtle怎么画弧线需要先了解以下几个事情。
这次我们用Turtle绘制上图的蝴蝶曲线
我们需要进行多次循环得出每个点的坐标,最后这些点连接成了上图曲线
公式有点复杂。python作品展示。。。。如下:
用Python程序实现
from turtle import *
from math import sin,cos,e
def draw():
cycle=25
t=0
while not (t>cycle*360):
p=e**cos(t)-2*cos(4*t)+sin(t/12)**5
x=a*sin(t)*p
y=b*cos(t)*p
goto(x,y)
dot()
t+=1
print(t)
pencolor("red")
pu()
speed(0)
tracer(1000)
a=b=40
draw()
ht()
done()
喜欢就赞一下吧~