FlixelColor
View sourceclass
org.flixelgdx.util.FlixelColor
Mutable color wrapper that owns a single Color instance for stable tinting and tween endpoints without per-frame allocations.
Shared presets such as FlixelColor.WHITE and FlixelColor.RED point at the same instances as libGDX Color namesakes. Mutating a preset affects every place that uses that reference. For a private copy, use new FlixelColor(FlixelColor.RED) or FlixelColor.setColor(FlixelColor) on your own instance.
Use FlixelColor.getGdxColor() when you need component access, lerping, or batch tinting; use FlixelColor.getColor() when you need a compact RGBA8888 value.
Constructors
FlixelColor()
Creates a new color with the default white color.
FlixelColor(int, int, int, float)
Creates a new color with the given RGBA values. Values must be in the range 0-255 (with alpha being [0, 1]).
Parameters:
| Name | Description |
|---|---|
r | The red component. |
g | The green component. |
b | The blue component. |
a | The alpha component (ranged from [0, 1]). |
FlixelColor(float, float, float, float)
Creates a new color with the given RGBA values. Values must be in the range 0-1.
Parameters:
| Name | Description |
|---|---|
r | The red component. |
g | The green component. |
b | The blue component. |
a | The alpha component. |
FlixelColor(int)
Creates a new color from the given packed RGBA8888 value.
Parameters:
| Name | Description |
|---|---|
rgba8888 | The packed RGBA8888 value. |
FlixelColor(Color)
Creates a new color from the given Color value.
Parameters:
| Name | Description |
|---|---|
source | The Color value to copy. |
FlixelColor(FlixelColor)
Creates a new color from the given FlixelColor value.
Parameters:
| Name | Description |
|---|---|
source | The FlixelColor value to copy. |
Fields
WHITE
BLACK
RED
GREEN
BLUE
YELLOW
CYAN
MAGENTA
GRAY
CLEAR
ORANGE
PINK
PURPLE
BROWN
OLIVE
MAROON
NAVY
TEAL
Methods
getColor()
Returns: Packed RGBA8888, same as libGDX Color.rgba8888(...) on the backing color.
setColor(Color)
Copies RGBA from other into this wrapper.
Parameters:
| Name | Description |
|---|---|
other | The libGDX color to copy. Must not be null. |
setColor(FlixelColor)
Copies RGBA from other into this wrapper.
Parameters:
| Name | Description |
|---|---|
other | The Flixel color to copy. Must not be null. |
setColor(String)
Sets this color from a hex string, same format accepted by libGDX Color.valueOf(...) (for example "ff0000" or "ff0000ff").
Parameters:
| Name | Description |
|---|---|
hexFormat | The hex string to parse. Must not be null. |
getHue()
Returns: The hue component of this color, in degrees [0, 360).
getSaturation()
Returns: The saturation component of this color, in the range [0, 1].
getValue()
Returns: The value (brightness) component of this color, in the range [0, 1].
setHue(float)
Sets the hue component of this color, leaving saturation, value, and alpha unchanged.
Parameters:
| Name | Description |
|---|---|
hue | The new hue, in degrees [0, 360). |
setSaturation(float)
Sets the saturation component of this color, leaving hue, value, and alpha unchanged.
Parameters:
| Name | Description |
|---|---|
saturation | The new saturation, in the range [0, 1]. |
setValue(float)
Sets the value (brightness) component of this color, leaving hue, saturation, and alpha unchanged.
Parameters:
| Name | Description |
|---|---|
value | The new value, in the range [0, 1]. |
getGdxColor()
Returns: The backing libGDX color (mutable).