-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
40 lines (28 loc) · 811 Bytes
/
main.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
import turtle
START_Y = -400
SCALE_FACTOR = .5
EDGE_LENGTH = 400
turtle.speed(100)
def drawTriangle(count = 8, scale = SCALE_FACTOR):
if count == 0:
return
pos = turtle.pos()
turtle.left(120)
turtle.forward(EDGE_LENGTH * scale)
drawTriangle(count - 1, scale * SCALE_FACTOR)
turtle.forward(EDGE_LENGTH * scale)
turtle.right(120)
turtle.forward(EDGE_LENGTH * scale)
drawTriangle(count - 1, scale * SCALE_FACTOR)
turtle.forward(EDGE_LENGTH * scale)
turtle.right(120)
turtle.forward(EDGE_LENGTH * scale)
drawTriangle(count - 1, scale * SCALE_FACTOR)
turtle.forward(EDGE_LENGTH * scale)
turtle.left(120)
turtle.penup()
turtle.goto(0, START_Y)
turtle.pendown()
drawTriangle()
turtle.penup()
input()