-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathColourWheelAnimationInTurtle.py
More file actions
39 lines (34 loc) · 1.01 KB
/
ColourWheelAnimationInTurtle.py
File metadata and controls
39 lines (34 loc) · 1.01 KB
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
#################### COLOUR WHEEL IN PYTHON #####################
# import graphics capabilities from turtle module
from turtle import *
# create a window for the graphics
setup()
# create a turtle pen for drawing
tl = Turtle()
# list of colours to randomly choose from
colors = ["red", "blue", "green", "yellow", "purple", "orange"]
# import random capabilities
import random
# basic turtle setup
# pickup the pen so no marks are left
tl.up()
# move the turtle to the left
tl.goto(-200, 0)
# put the pen back down to start marking
tl.down()
# change pen thickness
tl.width(5)
# hide the turtle icon
tl.hideturtle()
# set turtle speed to maximum
tl.speed(0)
# create a loop for the graphics to be built
for i in range(9001):
# chooose a random colour for the turtle
colorchoice = random.choice(colors)
# have the turtle take randomly choosen color
tl.color(colorchoice)
# move the turtle forward
tl.forward(400)
# have the turtle turn 181 degrees (anything over 180 degrees works)
tl.right(181)