-
Notifications
You must be signed in to change notification settings - Fork 0
/
recursive_tree_drawing.py
61 lines (48 loc) · 946 Bytes
/
recursive_tree_drawing.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import turtle as tl
length = 30
count = 4
# window = tl.Screen()
# window.screensize(1366, 768)
# window.setup(width=1.0, height=1.0, startx=None, starty=None)
def signature():
tl.up()
tl.home()
tl.backward(40)
tl.left(90)
tl.forward(250)
tl.down()
tl.write("Tree drawing with recursion", font=("Arial", 16, "normal"))
tl.up()
tl.backward(20)
tl.down()
tl.write("~Tanvir Ahmed", font=("Arial", 9, "normal"))
tl.up()
def create_branches(n):
if n == 0 :
return
tl.pendown()
tl.left(30)
tl.forward(length)
create_branches(n-1)
tl.penup()
tl.backward(length)
tl.right(60)
tl.pendown()
tl.forward(length)
create_branches(n-1)
tl.penup()
tl.backward(length)
tl.left(30)
tl.up()
tl.home()
tl.sety(-50)
# tl.forward(250)
tl.left(90)
# tl.goto((0, -330))
tl.pendown()
tl.forward(50)
create_branches(count)
signature()
tl.speed(1)
tl.hideturtle()
tl.exitonclick()