public class Color
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
float |
alpha
The color's alpha component.
|
float |
blue
The color's blue component.
|
float |
green
The color's green component.
|
float |
red
The color's red component.
|
Constructor and Description |
---|
Color()
Constructs a color with red, green, blue and alpha all 1.0.
|
Color(Color color)
Constructs a color with the components of a specified color.
|
Color(float red,
float green,
float blue,
float alpha)
Constructs a color with specified red, green, blue and alpha components.
|
Color(int colorInt)
Constructs a color with components stored in a color int.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object o) |
int |
hashCode() |
Color |
premultiply()
Premultiplies this color in place.
|
Color |
premultiplyColor(Color color)
Premultiplies the specified color and stores the result in this color.
|
float[] |
premultiplyToArray(float[] result,
int offset)
Copies this color's premultiplied components to the specified array.
|
Color |
set(Color color)
Sets this color to the components of a specified color.
|
Color |
set(float red,
float green,
float blue,
float alpha)
Sets this color to the specified components.
|
Color |
set(int colorInt)
Sets this color to the components stored in a color int.
|
float[] |
toArray(float[] result,
int offset)
Copies this color's components to the specified array.
|
int |
toColorInt()
Returns this color's components as a color int.
|
java.lang.String |
toString() |
public float red
public float green
public float blue
public float alpha
public Color()
public Color(float red, float green, float blue, float alpha)
red
- the red componentgreen
- the green componentblue
- the blue componentalpha
- the alpha componentpublic Color(int colorInt)
(alpha << 24) | (red << 16) | (green << 8) | (blue)
. Each component is an 8 bit number between 0 and
255 with 0 indicating the component's intensity.colorInt
- the color int specifying the componentspublic Color(Color color)
color
- the color specifying the componentsjava.lang.IllegalArgumentException
- If the color is nullpublic Color set(float red, float green, float blue, float alpha)
red
- the new red componentgreen
- the new green componentblue
- the new blue componentalpha
- the new alpha componentpublic Color set(int colorInt)
(alpha << 24) | (red << 16) | (green << 8) | (blue)
. Each component is an 8 bit number between 0 and
255 with 0 indicating the component's intensity.colorInt
- the color int specifying the new componentspublic Color set(Color color)
color
- the color specifying the new componentsjava.lang.IllegalArgumentException
- If the color is nullpublic boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public float[] toArray(float[] result, int offset)
result
- a pre-allocated array of length 4 in which to return the componentsoffset
- a starting index in the result arraypublic int toColorInt()
(alpha <<
24) | (red << 16) | (green << 8) | (blue)
. Each component is an 8 bit number between 0 and 255 with 0
indicating the component's intensity.public Color premultiply()
public Color premultiplyColor(Color color)
color
- the color with components to premultiply and store in this colorjava.lang.IllegalArgumentException
- If the color is nullpublic float[] premultiplyToArray(float[] result, int offset)
result
- a pre-allocated array of length 4 in which to return the componentsoffset
- a starting index in the result array