-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpartysquares.pde
70 lines (62 loc) · 1.38 KB
/
partysquares.pde
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
64
65
66
67
68
69
70
int N_ROXES = 256;
int MIN_ROT = 128;
int ROT_RANGE = 2556;
int MIN_SHADE = 32;
int MAX_SHADE = 126;
int MAX_WOBBLE = 64;
Roxor[] roxes;
void setup() {
smooth();
frameRate(30);
size(1280 ,960);
stroke(2.0);
rectMode(CENTER);
ellipseMode(CENTER);
roxes = new Roxor[N_ROXES];
for(int i=0;i<roxes.length;i++) {
int x = (int)random(width);
int y = (int)random(height);
int w = (int)random(width/10);
float rot = PI/(MIN_ROT + random(ROT_RANGE));
roxes[i] = new Roxor(x,y,w,rot);
}
}
void draw() {
background(155);
for(int i=0;i<roxes.length;i++) {
roxes[i].update();
}
}
class Roxor {
int x,y;
int w;
float rot,rincr;
float wobble;
float shade;
public Roxor(int x, int y, int w, float rincr) {
this.x = x;
this.y = y;
this.w = w;
this.rot = PI-random(TWO_PI);
this.rincr = rincr;
this.rincr = (ceil(random(2))>1) ? this.rincr : 0-this.rincr;
this.wobble = MAX_WOBBLE/2 - random(MAX_WOBBLE);
this.shade = MIN_SHADE + random(MAX_SHADE - MIN_SHADE);
}
public void update() {
fill(this.shade);
pushMatrix();
translate(x,y);
rotate(this.rot += this.rincr);
rect(this.wobble,this.wobble,w,w);
pushMatrix();
scale(0.9);
rotate(this.rot);
noStroke();
fill(this.shade+20,189);
rect(this.wobble,this.wobble,w,w);
stroke(2.0);
popMatrix();
popMatrix();
}
}