java.lang.Object
technology.sola.engine.graphics.Color
The Color class represents an argb color that can be used for rendering.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Color
Color constant - rgb(0, 0, 0).static final Color
Color constant - argb(0, 0, 0, 0).static final Color
Color constant - rgb(0, 0, 255).static final Color
Color constant - rgb(169, 169, 169).static final Color
Color constant - rgb(0, 255, 0).static final Color
Color constant - rgb(173, 216, 230).static final Color
Color constant - rgb(211, 211, 211)static final float
Constant used to normalize ARGB values to between 0 and 1.static final Color
Color constant - rgb(255, 165, 0).static final Color
Color constant - rgb(255, 0, 0).static final Color
Color constant - rgb(255, 255, 255).static final Color
Color constant - rgb(255, 255, 0). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
int
getAlpha()
int
getBlue()
int
getGreen()
int
getRed()
Creates a grey scale Color using this Color as the base.boolean
hasAlpha()
int
hashCode()
int
hexInt()
shade
(float shadeFactor) Creates a new Color that is a shade of this Color.tint
(float tintFactor) Creates a new Color that is a tint of this Color.toString()
updateAlpha
(int alpha) Returns a newColor
with updated alpha.
-
Field Details
-
BLACK
Color constant - rgb(0, 0, 0). -
BLANK
Color constant - argb(0, 0, 0, 0). -
BLUE
Color constant - rgb(0, 0, 255). -
DARK_GRAY
Color constant - rgb(169, 169, 169). -
GREEN
Color constant - rgb(0, 255, 0). -
ORANGE
Color constant - rgb(255, 165, 0). -
RED
Color constant - rgb(255, 0, 0). -
LIGHT_BLUE
Color constant - rgb(173, 216, 230). -
LIGHT_GRAY
Color constant - rgb(211, 211, 211) -
YELLOW
Color constant - rgb(255, 255, 0). -
WHITE
Color constant - rgb(255, 255, 255). -
ONE_DIV_255
public static final float ONE_DIV_255Constant used to normalize ARGB values to between 0 and 1.- See Also:
-
-
Constructor Details
-
Color
public Color(int r, int g, int b) Creates a Color instance via rgb values. Alpha is set to 255. Values should be set to between 0 and 255 inclusive.- Parameters:
r
- redg
- greenb
- blue
-
Color
public Color(int alpha, int r, int g, int b) Creates a Color instance via argb values. Values should be set to between 0 and 255 inclusive.- Parameters:
alpha
- the alphar
- redg
- greenb
- blue
-
Color
public Color(int argb) Creates a color instance from a 4 byte integer. Order of bytes should be [alpha, red, green, blue].- Parameters:
argb
- the 4 byte integer
-
-
Method Details
-
hexInt
public int hexInt()- Returns:
- the color has a 4 byte hex integer
-
getAlpha
public int getAlpha()- Returns:
- the alpha value
-
getRed
public int getRed()- Returns:
- the red value
-
getGreen
public int getGreen()- Returns:
- the green value
-
getBlue
public int getBlue()- Returns:
- the blue value
-
hasAlpha
public boolean hasAlpha()- Returns:
- true if alpha value is not 255
-
updateAlpha
Returns a newColor
with updated alpha.- Parameters:
alpha
- the new alpha- Returns:
- a new color instance with updated alpha
-
greyScale
Creates a grey scale Color using this Color as the base.- Returns:
- this color as greyscale
-
shade
Creates a new Color that is a shade of this Color.- Parameters:
shadeFactor
- the shade factor from 0-1- Returns:
- the shaded Color
-
tint
Creates a new Color that is a tint of this Color.- Parameters:
tintFactor
- the tint factor from 0-1- Returns:
- the tinted Color
-
equals
-
hashCode
public int hashCode() -
toString
-