Package graphics
Class Color
java.lang.Object
graphics.Color
Azurite
Represents a 4-channel color of either RGBA or HSLA type, with some helper functions to convert an RGBA to HSLA, or vice versa. This Class also contains some predefined colors, a random color generator, and some OpenGL-related helper functions.- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionfloat
Alpha component for this color.float
Blue component for this color.static Color
static Color
static Color
static Color
static Color
static Color
static Color
static Color
static Color
static Color
float
Green component for this color.static Color
static Color
static Color
static Color
static Color
static Color
static Color
float
Red component for this color.static Random
static Color
static Color
static Color
static final int
static final int
static Color
static Color
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Color
Decode a rgb color code into aColor
boolean
Check if colors are equalTurn a Color with normalised values to a color with values from 0-255static Color
getColor
(float x, float y, float z, float a, int inputType) Create a new color.static Color
void
setAlpha
(float value) Set Alpha for this colorvoid
setValue
(char type, float value) Set a component of this color to a valueorg.joml.Vector3f
Get the Normalized Vector3f for this color.org.joml.Vector4f
Get the Normalized Vector4f for this color.org.joml.Vector4f
toVec4f()
Returns a Vector4f with rgba as xyzw
-
Field Details
-
TYPE_RGBA
public static final int TYPE_RGBA- See Also:
-
TYPE_HSLA
public static final int TYPE_HSLA- See Also:
-
random
-
WHITE
-
BLACK
-
RED
-
DARK_RED
-
GREEN
-
BLUE
-
DARK_BLUE
-
DIRTY_BLUE
-
PINK
-
CYAN
-
YELLOW
-
PURPLE
-
SILVER
-
GRAY
-
MAROON
-
OLIVE
-
DARK_GREEN
-
TEAL
-
NAVY_BLUE
-
BROWN
-
FIREBRICK
-
CRIMSON
-
r
public float rRed component for this color. Range: 0-255 -
g
public float gGreen component for this color. Range: 0-255 -
b
public float bBlue component for this color. Range: 0-255 -
a
public float aAlpha component for this color. Range: 0-255
-
-
Constructor Details
-
Color
public Color(float pr, float pg, float pb, float pa) Creates new color with specified rgba values- Parameters:
pr
- initial red valuepg
- initial green valuepb
- initial blue valuepa
- initial alpha value
-
Color
public Color(float pr, float pg, float pb) Creates new color with specified rgb values- Parameters:
pr
- initial red valuepg
- initial green valuepb
- initial blue value
-
Color
public Color(float c) Creates new color with specified value for rgb- Parameters:
c
- value for red, green and blue
-
-
Method Details
-
randomColor
- Returns:
- random Color
-
getColor
Create a new color.- Parameters:
x
- the first componenty
- the second componentz
- the third componenta
- the alpha valueinputType
- whether the input values are RGBA or HSLA- Returns:
- a RGBA
Color
representing the input
-
decode
Decode a rgb color code into aColor
- Parameters:
colorCode
- the color code- Returns:
- a valid rgb color
- See Also:
-
toVec4f
public org.joml.Vector4f toVec4f()Returns a Vector4f with rgba as xyzw -
toNormalizedVec4f
public org.joml.Vector4f toNormalizedVec4f()Get the Normalized Vector4f for this color. Used mostly in OpenGL -
toNormalizedVec3f
public org.joml.Vector3f toNormalizedVec3f()Get the Normalized Vector3f for this color. Used mostly in OpenGL -
fromNormalized
Turn a Color with normalised values to a color with values from 0-255 -
equals
Check if colors are equal -
setAlpha
public void setAlpha(float value) Set Alpha for this color -
toHSLColor
- Returns:
- a
HSLColor
representing the same color
-
setValue
public void setValue(char type, float value) Set a component of this color to a value- Parameters:
type
- can be one of r, g, b, avalue
- value to set the component to
-