forked from Rafiot/PyCoderDojoLu
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path8_spiralScratch.py
More file actions
33 lines (24 loc) · 896 Bytes
/
8_spiralScratch.py
File metadata and controls
33 lines (24 loc) · 896 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
31
32
33
#!/usr/bin/env python3
# -*- coding: utf-8 -*- #
import turtle
import random
myTurtle = turtle.Turtle()
myWin = turtle.Screen()
# We do not need to set x, y to 0,0 because this is always the default position when starting a turtle program
increase = 0
width = myWin.window_width()
height = myWin.window_height()
degrees = int(input("Please provide an angle: "))
steps = int(input("Please tell me how many steps you want to go? (1-10) "))
# By default color mode is 1.0
#myWin.colormode(255)
def drawSpiral(myTurtle, lineLen):
if lineLen > 0:
myTurtle.pencolor((random.random(), random.random(), random.random()))
#myTurtle.pencolor((random.randrange(255), random.randrange(255), random.randrange(255)))
myTurtle.forward(lineLen)
myTurtle.right(degrees)
drawSpiral(myTurtle,lineLen+steps)
print(myTurtle.position())
drawSpiral(myTurtle,steps)
myWin.exitonclick()