-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathrotatingTriangles.pyde
More file actions
39 lines (32 loc) · 916 Bytes
/
Copy pathrotatingTriangles.pyde
File metadata and controls
39 lines (32 loc) · 916 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
34
35
36
37
38
39
#rotatingTriangles.pyde
#from Chapter 5 of Math Adventures with Python
def setup():
size(600,600)
rectMode(CENTER)
colorMode(HSB)
t = 0
def draw():
global t
background(255)#white
translate(width/2,height/2)
for i in range(90):
#space the triangles evenly
#around the circle
rotate(radians(360/90))
pushMatrix() #save this orientation
#go to circumference of circle
translate(200,0)
#spin each triangle
rotate(radians(t + 2*i*360/90))
#draw the triangle
strokeWeight(2)
stroke(3*i, 255,255)
tri(100)
#return to saved orientation
popMatrix()
t += 0.5
def tri(length):
noFill() #makes the triangle transparent
triangle(0, -length,
-length*sqrt(3)/2, length/2,
length*sqrt(3)/2, length/2)