public class ColorUtils
extends java.lang.Object
lerpColors(int, int, float) to blend RGBA colors, and multiplyAlpha(int, float) to
alter only the alpha channel on an RGBA or HSLA int color.| Constructor and Description |
|---|
ColorUtils() |
| Modifier and Type | Method and Description |
|---|---|
static float |
channel(int color,
int channel)
Given a packed int color and a channel value from 0 to 3, gets the value of that channel as a float from 0.0f
to 1.0f .
|
static float |
channelInt(int color,
int channel)
Given a packed int color and a channel value from 0 to 3, gets the value of that channel as an int from 0 to
255 .
|
static int |
hsb2rgb(float h,
float s,
float b,
float a)
Converts the four HSBA/HSVA components, each in the 0.0 to 1.0 range, to an int in RGBA8888 format.
|
static int |
hsl2rgb(float h,
float s,
float l,
float a)
Converts the four HSLA components, each in the 0.0 to 1.0 range, to an int in RGBA8888 format.
|
static int |
lerpColors(int s,
int e,
float change)
Interpolates from the RGBA8888 int color start towards end by change.
|
static int[][] |
multiplyAllAlpha(int[][] colors,
float multiplier)
Given any purely-non-null 2D int array representing RGBA or HSLA colors, this multiplies the alpha channel of
each color by multiplier, modifying the given array, and returns the changed array for chaining.
|
static int |
multiplyAlpha(int color,
float multiplier)
Given an RGBA8888 or HSLA color as an int, this multiplies the alpha of that color by multiplier and returns
another int color of the same format passed in.
|
static int |
rgb2hsb(float r,
float g,
float b,
float a)
Converts the four RGBA components, each in the 0.0 to 1.0 range, to an int in HSBA/HSVA format (hue,
saturation, brightness/value, alpha).
|
static int |
rgb2hsl(float r,
float g,
float b,
float a)
Converts the four RGBA components, each in the 0.0 to 1.0 range, to an int in HSLA format (hue,
saturation, lightness, alpha).
|
public static int hsl2rgb(float h,
float s,
float l,
float a)
h - hue, from 0.0 to 1.0s - saturation, from 0.0 to 1.0l - lightness, from 0.0 to 1.0a - alpha, from 0.0 to 1.0public static int rgb2hsl(float r,
float g,
float b,
float a)
r - red, from 0.0 to 1.0g - green, from 0.0 to 1.0b - blue, from 0.0 to 1.0a - alpha, from 0.0 to 1.0public static int hsb2rgb(float h,
float s,
float b,
float a)
h - hue, from 0.0 to 1.0s - saturation, from 0.0 to 1.0b - brightness, from 0.0 to 1.0a - alpha, from 0.0 to 1.0public static int rgb2hsb(float r,
float g,
float b,
float a)
r - red, from 0.0 to 1.0g - green, from 0.0 to 1.0b - blue, from 0.0 to 1.0a - alpha, from 0.0 to 1.0public static float channel(int color,
int channel)
HSLA ints,
channel 1 refers to G or S, 2 refers to B or L, and 3 always refers to A.color - a packed int color in any 32-bit, 4-channel formatchannel - which channel to access, as an index from 0 to 3 inclusivepublic static float channelInt(int color,
int channel)
HSLA ints,
channel 1 refers to G or S, 2 refers to B or L, and 3 always refers to A.color - a packed int color in any 32-bit, 4-channel formatchannel - which channel to access, as an index from 0 to 3 inclusivepublic static int lerpColors(int s,
int e,
float change)
s - the starting color as a packed inte - the end/target color as a packed intchange - how much to go from start toward end, as a float between 0 and 1; higher means closer to endpublic static int multiplyAlpha(int color,
float multiplier)
color - an RGBA8888 or HSLA colormultiplier - a multiplier to apply to color's alphapublic static int[][] multiplyAllAlpha(int[][] colors,
float multiplier)
multiplyAlpha(int, float) internally, so its documentation applies.colors - a 2D int array of RGBA or HSLA colors, none of which can include null arraysmultiplier - a multiplier to apply to each color's alpha