public class Color
extends java.lang.Object
implements java.io.Serializable
A Color represents a color in RGBA format. It stores four floating-point values, all between 0 and 1: the intensities of red, green, and blue, plus an alpha (opacity) value. An alpha of 0 is completely transparent, and an alpha of 1 is completely opaque. Once created, Colors are immutable.
Modifier and Type | Field and Description |
---|---|
static Color |
BLACK
The color black.
|
static Color |
TRANSPARENT
A completely transparent Color.
|
static Color |
WHITE
The color white.
|
Constructor and Description |
---|
Color(float r,
float g,
float b)
Constructs a Color with the specified RGB values and an alpha value of 1.
|
Color(float r,
float g,
float b,
float a)
Constructs a Color with the specified values.
|
Color(int r,
int g,
int b)
Constructs a Color with the specified RGB values, given as integers from
0 to 255, and an alpha value of 1.
|
Color(int r,
int g,
int b,
int a)
Constructs a Color with the specified values, given as integers from 0 to
255.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object obj) |
float |
getA()
Returns this Color's alpha value.
|
int |
getAByte()
Returns this Color's alpha value as an integer from 0 to 255.
|
float |
getB()
Returns this Color's blue value.
|
int |
getBByte()
Returns this Color's blue value as an integer from 0 to 255.
|
float |
getG()
Returns this Color's green value.
|
int |
getGByte()
Returns this Color's green value as an integer from 0 to 255.
|
float |
getR()
Returns this Color's red value.
|
int |
getRByte()
Returns this Color's red value as an integer from 0 to 255.
|
int |
hashCode() |
java.lang.String |
toString() |
public static final Color TRANSPARENT
public static final Color BLACK
public static final Color WHITE
public Color(float r, float g, float b, float a)
r
- The Color's red valueg
- The Color's green valueb
- The Color's blue valuea
- The Color's alpha valuepublic Color(float r, float g, float b)
r
- The Color's red valueg
- The Color's green valueb
- The Color's blue valuepublic Color(int r, int g, int b, int a)
r
- The Color's red valueg
- The Color's green valueb
- The Color's blue valuea
- The Color's alpha valuepublic Color(int r, int g, int b)
r
- The Color's red valueg
- The Color's green valueb
- The Color's blue valuepublic int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public final float getR()
public final float getG()
public final float getB()
public final float getA()
public final int getRByte()
public final int getGByte()
public final int getBByte()
public final int getAByte()