forked from APCSLowell/Scales
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Scales.pde
64 lines (55 loc) · 1.39 KB
/
Scales.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
import java.util.Map;
Map<Integer, Map<Integer, float[]>> colors = new HashMap();
int rowToChange;
int columnToChange;
void setup() {
size(500, 500);
noStroke();
if (mousePressed) {
rowToChange = -20;
columnToChange = height;
} else {
rowToChange = width;
columnToChange = -20;
}
}
void draw() {
if (mousePressed) {
if (rowToChange > height) {
rowToChange = -20;
}
if (columnToChange < -20) {
columnToChange = width;
}
} else {
if (rowToChange < -20) {
rowToChange = height;
}
if (columnToChange > width) {
columnToChange = -20;
}
}
for (int i = width; i >= -20; i -= 10) {
if (colors.get(i) == null) {
colors.put(i, new HashMap());
}
for (int j = height; j >= -20; j -= 10) {
if (colors.get(i).get(j) == null || i == columnToChange || j == rowToChange) {
colors.get(i).put(j, scale(i, j, scale(i, j, new float[]{(float) Math.random() * 200 + 57, (float) Math.random() * 200 + 57, (float) Math.random() * 200 + 57})));
} else {
scale(i, j, colors.get(i).get(j));}
}
}
if (mousePressed) {
rowToChange += 20;
columnToChange -= 20;
} else {
rowToChange -= 20;
columnToChange += 20;
}
}
float[] scale(int x, int y, float[] rgb) {
fill(rgb[0], rgb[1], rgb[2]);
bezier(x, y, x + 20, y + 10, x + 15, y + 20, x - 5, y + 10);
return rgb;
}