-
Notifications
You must be signed in to change notification settings - Fork 0
/
christmas_tree.py
61 lines (55 loc) · 1.17 KB
/
christmas_tree.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
from turtle import Turtle
tl = Turtle()
def draw_fractal(size):
if size >= 20:
tl.right(90)
tl.forward(size*1.73205/2)
tl.left(150)
tl.forward(size*3/4)
tl.left(30)
tl.forward(size*1.73205/4)
tl.left(30)
tl.forward(size*3/4)
tl.left(150)
tl.forward(size*1.73205*2/4)
tl.left(90)
tl.penup()
tl.forward(size*3/8)
tl.pendown()
draw_fractal(size/1.5)
else:
tl.color('yellow')
tl.forward(size/8)
tl.begin_fill()
tl.right(114)
tl.forward(20)
tl.left(120)
tl.forward(20)
tl.right(48)
tl.forward(20)
tl.left(120)
tl.forward(20)
tl.right(48)
tl.forward(20)
tl.left(120)
tl.forward(20)
tl.right(48)
tl.forward(20)
tl.left(120)
tl.forward(20)
tl.right(48)
tl.forward(20)
tl.left(120)
tl.forward(20)
tl.end_fill()
size = 300
tl.hideturtle()
tl.penup()
tl.color('green')
tl.goto(0,-size/2)
tl.setheading(90)
tl.pendown()
tl.speed(0)
draw_fractal(size)
turtle.done()