赞
踩
阳春三月,草长莺飞。今天下午,百年珞珈、纯美樱花,我们线上赏樱花!
在家用python写了三种樱花树,希望你们能够喜欢。
1 樱花树 动态生成樱花
效果图(这个是动态的):
实现代码(Python):
- import turtle as T
- import random
- import time
-
- # 画樱花的躯干(60,t)
- def Tree(branch, t):
- time.sleep(0.0005)
- if branch > 3:
- if 8 <= branch <= 12:
- if random.randint(0, 2) == 0:
- t.color('snow') # 白
- else:
- t.color('lightcoral') # 淡珊瑚色
- t.pensize(branch / 3)
- elif branch < 8:
- if random.randint(0, 1) == 0:
- t.color('snow')
- else:
- t.color('lightcoral') # 淡珊瑚色
- t.pensize(branch / 2)
- else:
- t.color('sienna') # 赭(zhě)色
- t.pensize(branch / 10) # 6
- t.forward(branch)
- a = 1.5 * random.random()
- t.right(20 * a)
- b = 1.5 * random.random()
- Tree(b

Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。