博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[python] math与turtle库之蝴蝶曲线
阅读量:362 次
发布时间:2019-03-04

本文共 533 字,大约阅读时间需要 1 分钟。

【python代码】math与turtle库之蝴蝶曲线的运用

几个turtle库基本函数:

1:turtle.pensize(x) :X大小控制画笔大小
2:turtle.pencolor(“color”):画笔颜色控制,color为想要输入的颜色名称

引入turtle库跟math库:

from turtle import*
from math import*
几个math函数:
exp(x):表示为e的x次方
pow(x,y):表示为x的y次方

[python] math与turtle库之蝴蝶曲线代码:

**from turtle import * from math import * pensize(3) pencolor("red") #画笔颜色 def draw(a,end): t=0 while t<24*end: x=a*sin(t)*(exp(cos(t))-2*cos(4*t)+pow(sin(t/12),5)) y=a*cos(t)*(exp(cos(t))-2*cos(4*t)+pow(sin(t/12),5)) goto(x,y) t=t+0.05 if __name__ == '__main__': draw(60,pi)**
代码
效果图

转载地址:http://diyg.baihongyu.com/

你可能感兴趣的文章