19 package Beatmup.Imaging;
58 g = (code >> 8) % 256;
59 r = (code >> 16) % 256;
60 a = (code >> 24) % 256;
67 return r |
g << 8 |
b << 16 |
a << 24;
78 if (expr.matches(
"(\\d|[a-fA-F]){6}")) {
79 Color c =
new Color(Integer.parseInt(expr, 16));
83 if (expr.matches(
"(\\d|[a-fA-F]){8}"))
84 return new Color(Integer.parseInt(expr, 16));
86 String vals[] = expr.split(
",");
87 if (vals.length != 3 && vals.length != 4)
88 throw new IllegalArgumentException(
"Cannot parse color from expression '" +expr+
"'");
90 Integer.parseInt(vals[0]),
91 Integer.parseInt(vals[1]),
92 Integer.parseInt(vals[2]),
93 vals.length > 3 ? Integer.parseInt(vals[3]) : 255
105 Math.round(
r * factorRGB),
106 Math.round(
g * factorRGB),
107 Math.round(
b * factorRGB),
108 Math.round(
a * factorAlpha)
119 SQRT3 = 1.732050807568877,
120 hue = Math.toRadians(hueDegrees),
121 r = Math.max(0, (2 * Math.cos(hue) + 1) / 3),
122 g = Math.max(0, (SQRT3 * Math.sin(hue) - Math.cos(hue) + 1) / 3),
123 b = Math.max(0, (1 - SQRT3 * Math.sin(hue) - Math.cos(hue)) / 3),
124 norm = Math.max(
r, Math.max(
g,
b));
126 (
int) Math.floor(255 *
r / norm),
127 (
int) Math.floor(255 *
g / norm),
128 (
int) Math.floor(255 *
b / norm),
136 public static final Color
138 BLACK =
new Color(0, 0, 0, 255),
139 WHITE =
new Color(255, 255, 255, 255),
140 RED =
new Color(255, 0, 0, 255),
141 GREEN =
new Color(0, 255, 0, 255),
142 BLUE =
new Color(0, 0, 255, 255),
143 YELLOW =
new Color(255, 255, 0, 255),
144 PURPLE =
new Color(255, 0, 255, 255),
145 ORANGE =
new Color(255, 127, 0, 255),
146 GRAY =
new Color(127, 127, 127, 255),
148 FECAMP_SKY =
new Color(100, 140, 189, 255);
Integer RGBA color value.
static Color byHue(float hueDegrees)
Returns a fully saturated color from its hue.
Color()
Creates a zero-valued color.
Color scale(float factorRGB, float factorAlpha)
Returns a scaled version of the current color by given factors.
Color(int code)
Constructs a color from its integer code.
static Color parseString(String expr)
Builds a color from a string.
Color(int r, int g, int b, int a)
Creates a color by aggregating the four channels values components.
static final Color TRANSPARENT_BLACK
Predefined color constants.