-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLayer.pde
More file actions
63 lines (55 loc) · 1.07 KB
/
Layer.pde
File metadata and controls
63 lines (55 loc) · 1.07 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
class Layer {
float scale;
char letter;
color colour;
float rotation;
float speed;
int rotationDirection;
float rotationSpeed;
//PGraphics pg;
Layer(char l, color cl, float s) {
letter = l;
scale=1;
colour = cl;
speed = s;
rotationDirection = rand_signum();
rotationSpeed = rand_rotationSpeed();
}
int rand_signum() {
return random(-1, 1) >= 0 ? 1 : -1;
}
float rand_rotationSpeed() {
return radians(random(HALF_PI, PI));
}
float getScale() {
return scale;
}
char getLetter() {
return letter;
}
color getColour() {
return colour;
}
void setColour() {
colour = color(random(255), random(255), random(255));
}
void show() {
if (activateRotation) {
rotate(rotationDirection*rotation);
}
textAlign(CENTER, CENTER);
textSize(24);
scale(scale);
fill(colour);
text(letter, 0, -2);
update();
}
void update() {
scale=scale*speed;
rotation = rotation+rotationSpeed;
speed=map(mouseX, 0, width, 1.02, 1.2);
}
void reset() {
scale=1;
}
}