-
Notifications
You must be signed in to change notification settings - Fork 50
/
Copy pathStar Pattern.py
48 lines (35 loc) · 1.23 KB
/
Star Pattern.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
import turtle
import random
turtle.speed(speed ='fastest')
def draw(n, x, angle):
# loop for number of stars
for i in range(n):
turtle.colormode(255)
# choosing random integers
# between 0 and 255
# to generate random rgb values
a = random.randint(0, 255)
b = random.randint(0, 255)
c = random.randint(0, 255)
# setting the outline
# and fill colour
turtle.pencolor(a, b, c)
turtle.fillcolor(a, b, c)
# begins filling the star
turtle.begin_fill()
# loop for drawing each star
for j in range(5):
turtle.forward(5 * n-5 * i)
turtle.right(x)
turtle.forward(5 * n-5 * i)
turtle.right(72 - x)
# colour filling complete
turtle.end_fill()
# rotating for
# the next star
turtle.rt(angle)
# setting the parameters
n = 30 # number of stars
x = 144 # exterior angle of each star
angle = 18 # angle of rotation for the spiral
draw(n, x, angle)