标签:nbsp mic info png width dom lse pen bsp
ps: 是动态画出的哈哈
1 import turtle as T 2 import random 3 import time 4 5 # 画樱花的躯干(60,t) 6 def Tree(branch, t): 7 time.sleep(0.0005) 8 if branch > 3: 9 if 8 <= branch <= 12: 10 if random.randint(0, 2) == 0: 11 t.color(‘snow‘) # 白 12 else: 13 t.color(‘lightcoral‘) # 淡珊瑚色 14 t.pensize(branch / 3) 15 elif branch < 8: 16 if random.randint(0, 1) == 0: 17 t.color(‘snow‘) 18 else: 19 t.color(‘lightcoral‘) # 淡珊瑚色 20 t.pensize(branch / 2) 21 else: 22 t.color(‘sienna‘) # 赭色 23 t.pensize(branch / 10) # 6 24 t.forward(branch) 25 a = 1.5 * random.random() 26 t.right(20 * a) 27 b = 1.5 * random.random() 28 Tree(branch - 10 * b, t) 29 t.left(40 * a) 30 Tree(branch - 10 * b, t) 31 t.right(20 * a) 32 t.up() 33 t.backward(branch) 34 t.down() 35 36 # 掉落的花瓣 37 def Petal(m, t): 38 for i in range(m): 39 a = 200 - 400 * random.random() 40 b = 10 - 20 * random.random() 41 t.up() 42 t.forward(b) 43 t.left(90) 44 t.forward(a) 45 t.down() 46 t.color(‘lightcoral‘) # 淡珊瑚色 47 t.circle(1) 48 t.up() 49 t.backward(a) 50 t.right(90) 51 t.backward(b) 52 53 # 绘图区域 54 t = T.Turtle() 55 # 画布大小 56 w = T.Screen() 57 t.hideturtle() # 隐藏画笔 58 t.getscreen().tracer(5, 0) 59 w.screensize(bg=‘wheat‘) # wheat小麦 60 t.left(90) 61 t.up() 62 t.backward(150) 63 t.down() 64 t.color(‘sienna‘) 65 66 # 写字 67 t.color(‘purple‘) # 紫色 68 t.write(‘野狗爱吃香蕉‘,font=("name",30,"normal")) 69 70 # 画樱花的躯干 71 Tree(60, t) 72 # 掉落的花瓣 73 Petal(200, t) 74 w.exitonclick()
标签:nbsp mic info png width dom lse pen bsp
原文地址:https://www.cnblogs.com/chen43/p/12245457.html