-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRotate.cpp
More file actions
40 lines (30 loc) · 829 Bytes
/
Copy pathRotate.cpp
File metadata and controls
40 lines (30 loc) · 829 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
40
/**
* Rotate.
*
* Rotating a square around the Z axis. To get the results
* you expect, send the rotate function angle parameters that are
* values between 0 and PI*2 (TWO_PI which is roughly 6.28). If you prefer to
* think about angles as degrees (0-360), you can use the radians()
* method to convert your values. For example: scale(radians(90))
* is identical to the statement scale(PI/2).
*/
float angle;
float jitter;
void setup() {
size(640, 360);
noStroke();
fill(255);
rectMode(CENTER);
}
void draw() {
background(51);
// during even-numbered seconds (0, 2, 4, 6...)
if (second() % 2 == 0) {
jitter = random(-0.1, 0.1);
}
angle = angle + jitter;
float c = cos(angle);
translate(width / 2, height / 2);
rotate(c);
rect(0, 0, 180, 180);
}