-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathColor.java
More file actions
55 lines (45 loc) · 1.32 KB
/
Color.java
File metadata and controls
55 lines (45 loc) · 1.32 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
package util;
import static java.util.Arrays.stream;
public enum Color {
BLANK(-1f, -1f, -1f),
BLACK(0.000f, 0.000f, 0.000f),
WHITE(1.000f, 1.000f, 1.000f),
RED(1.000f, 0.000f, 0.000f),
LIME(0.000f, 1.000f, 0.000f),
BLUE(0.000f, 0.000f, 1.000f),
YELLOW(1.000f, 1.000f, 0.000f),
CYAN_AQUA( 0.000f, 1.000f, 1.000f),
MAGENTA(1.000f, 0.000f, 1.000f),
SILVER(0.753f, 0.753f, 0.753f),
GRAY(0.502f, 0.502f, 0.502f),
MAROON(0.502f, 0.000f, 0.000f),
OLIVE(0.502f, 0.502f, 0.000f),
GREEN(0.000f, 0.502f, 0.000f),
PURPLE(0.502f, 0.000f, 0.502f),
TEAL(0.000f, 0.502f, 0.502f),
VIOLET(0.933f, 0.510f, 0.933f),
NAVY(0.000f, 0.000f, 0.502f);
private final float red;
private final float green;
private final float blue;
public static Color from(String colorName) {
return stream(Color.values())
.filter(color -> colorName.toLowerCase().contains(color.name().toLowerCase()))
.findFirst()
.orElse(null);
}
Color(float red, float green, float blue) {
this.red = red;
this.green = green;
this.blue = blue;
}
public float getRed() {
return red;
}
public float getGreen() {
return green;
}
public float getBlue() {
return blue;
}
}