File tree Expand file tree Collapse file tree 2 files changed +49
-0
lines changed
Expand file tree Collapse file tree 2 files changed +49
-0
lines changed File renamed without changes.
Original file line number Diff line number Diff line change 1+ from turtle import *
2+
3+
4+ speed ('fastest' )
5+
6+ # turning the turtle to face upwards
7+ rt (- 90 )
8+
9+ # the acute angle between
10+ # the base and branch of the Y
11+ angle = 30
12+
13+ # function to plot a Y
14+ def y (sz , level ):
15+
16+ if level > 0 :
17+ colormode (255 )
18+
19+ # splitting the rgb range for green
20+ # into equal intervals for each level
21+ # setting the colour according
22+ # to the current level
23+ pencolor (0 , 255 // level , 0 )
24+
25+ # drawing the base
26+ fd (sz )
27+
28+ rt (angle )
29+
30+ # recursive call for
31+ # the right subtree
32+ y (0.8 * sz , level - 1 )
33+
34+ pencolor (0 , 255 // level , 0 )
35+
36+ lt ( 2 * angle )
37+
38+ # recursive call for
39+ # the left subtree
40+ y (0.8 * sz , level - 1 )
41+
42+ pencolor (0 , 255 // level , 0 )
43+
44+ rt (angle )
45+ fd (- sz )
46+
47+
48+ # tree of size 80 and level 7
49+ y (80 , 7 )
You can’t perform that action at this time.
0 commit comments