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
FieldsModifier and TypeFieldDescriptionfloatAlpha component for this color.floatBlue component for this color.static Colorstatic Colorstatic Colorstatic Colorstatic Colorstatic Colorstatic Colorstatic Colorstatic Colorstatic ColorfloatGreen component for this color.static Colorstatic Colorstatic Colorstatic Colorstatic Colorstatic Colorstatic ColorfloatRed component for this color.static Randomstatic Colorstatic Colorstatic Colorstatic final intstatic final intstatic Colorstatic Color -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ColorDecode a rgb color code into aColorbooleanCheck if colors are equalTurn a Color with normalised values to a color with values from 0-255static ColorgetColor(float x, float y, float z, float a, int inputType) Create a new color.static ColorvoidsetAlpha(float value) Set Alpha for this colorvoidsetValue(char type, float value) Set a component of this color to a valueorg.joml.Vector3fGet the Normalized Vector3f for this color.org.joml.Vector4fGet the Normalized Vector4f for this color.org.joml.Vector4ftoVec4f()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
Colorrepresenting 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
HSLColorrepresenting 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
-