-
Notifications
You must be signed in to change notification settings - Fork 1
/
generateColor.pde
58 lines (55 loc) · 1.38 KB
/
generateColor.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
class generateColor {
String c;
generateColor(String c) {
this.c = c;
}
float[] getRGB() {
float[] rgb = new float[3];
if (c.equals("red")) {
rgb[0] = random(175, 255);
rgb[1] = random(0, 60);
rgb[2] = rgb[1] + random(-20, 10);
}
else if (c.equals("orange")) {
rgb[0] = random(210, 255);
rgb[1] = rgb[0] - random(120, 150);
rgb[2] = random(0, 50);
}
else if (c.equals("yellow")) {
rgb[0] = random(175, 255);
rgb[1] = rgb[0] - random(50, 70);
rgb[2] = random(0, 50);
}
else if (c.equals("green")) {
rgb[0] = random(0, 150);
rgb[1] = random(175, 255);
rgb[2] = rgb[0] + random(-40, 10);
}
else if (c.equals("teal")) {
rgb[0] = random(5, 100);
rgb[1] = random(175, 255);
rgb[2] = rgb[1] + random(-10, 30);
}
else if (c.equals("blue")) {
rgb[0] = random(0, 80);
rgb[1] = rgb[0] + random(-20, 20);
rgb[2] = random(175, 255);
}
else if (c.equals("purple")) {
rgb[0] = random(150, 200);
rgb[1] = random(0, 75);
rgb[2] = rgb[0] + random(20, 60);
}
else if (c.equals("pink")) {
rgb[0] = random(240, 255);
rgb[1] = random(80, 120);
rgb[2] = random(140, 180);
}
else { // White
rgb[0] = random(245, 255);
rgb[1] = rgb[0];
rgb[2] = rgb[0];
}
return rgb;
}
}