Without further ado, let's get straight to the code!
#!/usr/bin/env python # coding=utf-8 # Draw a cherry blossom import turtle import random from turtle import * from time import sleep # Drawing cherry blossom torsos (60,t) # def tree(branchLen,t): sleep(0.0005) if branchLen >3: if 8<= branchLen <=12: if (0,2) == 0: ('snow') # White else: ('lightcoral') # Light coral (branchLen / 3) elif branchLen <8: if (0,1) == 0: ('snow') else: ('lightcoral') # Light coral (branchLen / 2) else: ('sienna') # Ochre (zhě) color (branchLen / 10) # 6 (branchLen) a = 1.5 * () (20*a) b = 1.5 * () tree(branchLen-10*b, t) (40*a) tree(branchLen-10*b, t) (20*a) () (branchLen) () # Falling petals def petal(m, t): for i in range(m): a = 200 - 400 * () b = 10 - 20 * () () (b) (90) (a) () ('lightcoral') # Light coral (1) () (a) (90) (b) def main(): # Drawing area t = () # Canvas size w = () () # Hide the brushes getscreen().tracer(5,0) (bg='wheat') # wheat (90) () (150) () ('sienna') # Drawing the trunk of a cherry blossom tree(60,t) # Falling petals petal(200, t) () main()
Above this python3 implementation with turtle module to draw a random cherry blossom tree is all I have to share with you, I hope to be able to give you a reference, and I hope you can support me more.