forked from xavier/KidsCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspirale.py
More file actions
30 lines (21 loc) · 643 Bytes
/
spirale.py
File metadata and controls
30 lines (21 loc) · 643 Bytes
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
import turtle
t = turtle.Pen()
def augmente(segment, pourcent):
return segment + (segment*(pourcent/100.0))
def spirale_recursive(t, segment, pourcent, angle, iterations):
if iterations == 0: return
t.forward(segment)
t.right(angle)
spirale_recursive(t, augmente(segment, pourcent), pourcent, angle, iterations-1)
def spirale_iterative(t, segment, pourcent, angle, iterations):
for i in range(iterations):
t.forward(segment)
t.right(angle)
segment = augmente(segment, pourcent)
t.speed("fast")
spirale_recursive(t, 10, 15, 50, 30)
t.penup()
t.home()
t.pendown()
spirale_iterative(t, 10, 10, 98, 50)
raw_input()