Package net.risingworld.api.utils
Class ColorRGBA
java.lang.Object
net.risingworld.api.utils.ColorRGBA
- All Implemented Interfaces:
Serializable
Represents a color consisting of a red, green and blue component (linear color space)
as well as an alpha component (for transparency/opacity).
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionfloatThe alpha (opacity) color component (0-1)floatThe blue color component (0-1)static final ColorRGBABlack color (0, 0, 0)static final ColorRGBABlue color (0, 0, 1)static final ColorRGBABlack color with no alpha (0, 0, 0)floatThe green color component (0-1)static final ColorRGBAGreen color (0, 1, 0)static final ColorRGBAGrey color (0.5, 0.5, 0.5)floatThe red color component (0-1)static final ColorRGBARed color (1, 0, 0)static final ColorRGBAWhite color (1, 1, 1) -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanequals(float r, float g, float b, float a) booleanGets whether or not this color is equal to another object.fromIntRGBA(int rgba) inthashCode()interpolateLocal(ColorRGBA color, float mu) Interpolates this color to the provided final color, e.g if this color is (0, 0, 1, 1), and the final color is (1, 0.5f, 0, 1), the result (by using a mu-value of 0.5f) would be (0.5f, 0.25f, 0.5f, 1)set(float r, float g, float b, float a) Sets the r, g, b and a values of this color to the provided values.Sets the r, g, b and a values of this color to the values of the provided color.intConverts the color r, g, b and a values to an int representation.toString()Gets a String representation of this color, for example(1.0, 0.5, 0.0, 1.0)
-
Field Details
-
White
White color (1, 1, 1) -
Grey
Grey color (0.5, 0.5, 0.5) -
Black
Black color (0, 0, 0) -
Clear
Black color with no alpha (0, 0, 0) -
Red
Red color (1, 0, 0) -
Green
Green color (0, 1, 0) -
Blue
Blue color (0, 0, 1) -
r
public float rThe red color component (0-1) -
g
public float gThe green color component (0-1) -
b
public float bThe blue color component (0-1) -
a
public float aThe alpha (opacity) color component (0-1)
-
-
Constructor Details
-
ColorRGBA
public ColorRGBA()Creates a new white color (all values 1) -
ColorRGBA
public ColorRGBA(int rgba) -
ColorRGBA
public ColorRGBA(float r, float g, float b, float a) Creates a new color with the provided values.- Parameters:
r- the red color component (0-1).g- the green color component (0-1).b- the blue color component (0-1).a- the alpha (opacity) color component (0-1).
-
ColorRGBA
Creates a new color and copies the values from the provided color.- Parameters:
copy- the color to copy.
-
-
Method Details
-
set
Sets the r, g, b and a values of this color to the values of the provided color.- Parameters:
color- the ColorRGBA to copy.- Returns:
- this color.
-
set
Sets the r, g, b and a values of this color to the provided values.- Parameters:
r- the red color value.g- the green color value.b- the blue color value.a- the alpha (opacity) color value.- Returns:
- this color.
-
interpolateLocal
Interpolates this color to the provided final color, e.g if this color is (0, 0, 1, 1), and the final color is (1, 0.5f, 0, 1), the result (by using a mu-value of 0.5f) would be (0.5f, 0.25f, 0.5f, 1)- Parameters:
color- the color to interpolate towards.mu- the mu value between 0.0 and 1.0 (i.e the percentage change from this color to towards the final color).- Returns:
- this color containing the interpolated color values.
-
toVector4f
-
toIntRGBA
public int toIntRGBA()Converts the color r, g, b and a values to an int representation.- Returns:
- the integer representation of this color in rgba order.
-
fromIntRGBA
-
equals
Gets whether or not this color is equal to another object. This function returns true, if the other object is aColorRGBAand if it has exactly the same r, g, b and a values. -
equals
public boolean equals(float r, float g, float b, float a) -
hashCode
public int hashCode() -
toString
Gets a String representation of this color, for example(1.0, 0.5, 0.0, 1.0)
-