ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
``` from turtle import * from random import * from math import * def yezi(n,l): right(90) n=cos(radians(heading()-45))/4+0.5 pencolor(n,n*0.8,n*0.8) circle(3) left(90) #添加0.3倍的飘落叶子 if(random()>0.7): pu() #飘落 t = heading() an = -40 +random()*40 setheading(an) dis = int(800*random()*0.5 + 400*random()*0.3 + 200*random()*0.2) forward(dis) setheading(t) #画叶子 pd() right(90) n = cos(radians(heading()-45))/4+0.5 pencolor(n*0.5+0.5,0.4+n*0.4,0.4+n*0.4) circle(2) left(90) pu() #返回 t=heading() setheading(an) backward(dis) setheading(t) yezi(n-1,l-1) yezi(5,10) ``` ``` from turtle import * from random import * from math import * def yezi(n,l): right(90) n=cos(radians(heading()-45))/4+0.5 pencolor(n,n*0.8,n*0.8) circle(30) left(90) #添加0.3倍的飘落叶子 if(random()>0.7): pu() #飘落 t = heading() an = -40 +random()*40 setheading(an) dis = int(800*random()*0.5 + 400*random()*0.3 + 200*random()*0.2) forward(dis) setheading(t) #画叶子 pd() right(90) n = cos(radians(heading()-45))/4+0.5 pencolor(n*0.5+0.5,0.4+n*0.4,0.4+n*0.4) circle(20) left(90) pu() #返回 t=heading() #pd() setheading(an) backward(dis) setheading(t) pu() backward(l)#退回 pd() yezi(n-1,l-1) yezi(2,20) ``` ``` import turtle from math import cos a = turtle.heading() print(a) turtle.speed(1) #turtle.mode('logo') turtle.mode('world') #turtle.setworldcoordinates(-500,-500,500,500) #turtle.setworldcoordinates(-50,-7.5,50,7.5) for i in range(4): turtle.forward(100) val = turtle.heading() print(val) n=cos(radians(val-45)) print(n) turtle.write(str(val)) turtle.backward(100) turtle.left(90) ``` ``` right(90) n=cos(radians(heading()-45))/4+0.5 pencolor(n,n*0.8,n*0.8) circle(3) left(90) #添加0.3倍的飘落叶子 if(random()>0.7): pu() #飘落 t = heading() an = -40 +random()*40 setheading(an) dis = int(800*random()*0.5 + 400*random()*0.3 + 200*random()*0.2) forward(dis) setheading(t) #画叶子 pd() right(90) n = cos(radians(heading()-45))/4+0.5 pencolor(n*0.5+0.5,0.4+n*0.4,0.4+n*0.4) circle(2) left(90) pu() #返回 t=heading() setheading(an) backward(dis) setheading(t) ```