Integer RGBA color value.
More...
|
| | Color () |
| | Creates a zero-valued color. More...
|
| |
| | Color (int r, int g, int b, int a) |
| | Creates a color by aggregating the four channels values components. More...
|
| |
| | Color (int code) |
| | Constructs a color from its integer code. More...
|
| |
| int | getRgbaCode () |
| |
| Color | scale (float factorRGB, float factorAlpha) |
| | Returns a scaled version of the current color by given factors. More...
|
| |
|
| static Color | parseString (String expr) throws IllegalArgumentException |
| | Builds a color from a string. More...
|
| |
| static Color | byHue (float hueDegrees) |
| | Returns a fully saturated color from its hue. More...
|
| |
Integer RGBA color value.
Definition at line 24 of file Color.java.
◆ Color() [1/3]
| Beatmup.Imaging.Color.Color |
( |
| ) |
|
|
inline |
Creates a zero-valued color.
Definition at line 33 of file Color.java.
◆ Color() [2/3]
| Beatmup.Imaging.Color.Color |
( |
int |
r, |
|
|
int |
g, |
|
|
int |
b, |
|
|
int |
a |
|
) |
| |
|
inline |
Creates a color by aggregating the four channels values components.
- Parameters
-
| r | the red channel value |
| g | the green channel value |
| b | the blue channel value |
| a | the alpha channel value |
Definition at line 44 of file Color.java.
◆ Color() [3/3]
| Beatmup.Imaging.Color.Color |
( |
int |
code | ) |
|
|
inline |
Constructs a color from its integer code.
- Parameters
-
Definition at line 56 of file Color.java.
58 g = (code >> 8) % 256;
59 r = (code >> 16) % 256;
60 a = (code >> 24) % 256;
◆ getRgbaCode()
| int Beatmup.Imaging.Color.getRgbaCode |
( |
| ) |
|
|
inline |
- Returns
- the integer code of the current color.
Definition at line 66 of file Color.java.
67 return r |
g << 8 |
b << 16 |
a << 24;
◆ parseString()
| static Color Beatmup.Imaging.Color.parseString |
( |
String |
expr | ) |
throws IllegalArgumentException |
|
inlinestatic |
Builds a color from a string.
Accepts hexadecimal RGB and RGBA notations like "7f7f7f", "7f7f7fFF" (case-insensitive) and a comma-separed list of 3 or 4 decimal integer values like "127,127,127,255".
- Parameters
-
| expr | The string expression |
- Returns
- the corresponding color. If cannot parsem throws an exception.
Definition at line 76 of file Color.java.
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
Color()
Creates a zero-valued color.
◆ scale()
| Color Beatmup.Imaging.Color.scale |
( |
float |
factorRGB, |
|
|
float |
factorAlpha |
|
) |
| |
|
inline |
Returns a scaled version of the current color by given factors.
- Parameters
-
| factorRGB | The color components scaling factor |
| factorAlpha | The alpha component scaling factor |
- Returns
- the scaled color value. The current instance of Color is not changed.
Definition at line 103 of file Color.java.
105 Math.round(
r * factorRGB),
106 Math.round(
g * factorRGB),
107 Math.round(
b * factorRGB),
108 Math.round(
a * factorAlpha)
◆ byHue()
| static Color Beatmup.Imaging.Color.byHue |
( |
float |
hueDegrees | ) |
|
|
inlinestatic |
Returns a fully saturated color from its hue.
- Parameters
-
| hueDegrees | The hue in degrees. |
- Returns
- the color having the given hue.
Definition at line 117 of file Color.java.
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),
| int Beatmup.Imaging.Color.r |
| int Beatmup.Imaging.Color.g |
| int Beatmup.Imaging.Color.b |
| int Beatmup.Imaging.Color.a |
◆ TRANSPARENT_BLACK
| final Color Beatmup.Imaging.Color.TRANSPARENT_BLACK = new Color(0, 0, 0, 0) |
|
static |
Predefined color constants.
Definition at line 137 of file Color.java.
The documentation for this class was generated from the following file:
- android/lib/src/main/java/Beatmup/Imaging/Color.java