public class Color
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static Color |
BLACK
The color black.
|
static Color |
BLUE
The color blue.
|
static Color |
CYAN
The color cyan.
|
static Color |
DARK_GRAY
The color dark gray.
|
static Color |
GRAY
The color gray.
|
static Color |
GREEN
The color green.
|
static Color |
LIGHT_GRAY
The color light gray.
|
static Color |
MAGENTA
The color magenta.
|
static Color |
ORANGE
The color orange.
|
static Color |
PINK
The color pink.
|
static Color |
RED
The color red.
|
static Color |
WHITE
The color white.
|
static Color |
YELLOW
The color yellow.
|
Constructor and Description |
---|
Color(int r,
int g,
int b)
Creates a RGB color with the specified red, green, blue values in the
range (0 - 255).
|
Color(int r,
int g,
int b,
int a)
Creates a RGB color with the specified red, green, blue, and alpha values
in the range (0 - 255).
|
Modifier and Type | Method and Description |
---|---|
Color |
brighter()
Creates a new color that is a brighter version of this GreenfootColor.
|
Color |
darker()
Creates a new GreenfootColor that is a darker version of this
GreenfootColor.
|
boolean |
equals(java.lang.Object obj)
Determines whether another object is equal to this color.
|
int |
getAlpha()
Returns the alpha component in the range 0-255.
|
int |
getBlue()
Returns the blue component in the range 0-255 in the default RGB space.
|
int |
getGreen()
Returns the green component in the range 0-255 in the default RGB space.
|
int |
getRed()
Returns the red component in the range 0-255 in the default RGB space.
|
int |
hashCode()
Computes the hash code for this
Color . |
java.lang.String |
toString()
Return a text representation of the color.
|
public static final Color WHITE
public static final Color LIGHT_GRAY
public static final Color GRAY
public static final Color DARK_GRAY
public static final Color BLACK
public static final Color RED
public static final Color PINK
public static final Color ORANGE
public static final Color YELLOW
public static final Color GREEN
public static final Color MAGENTA
public static final Color CYAN
public static final Color BLUE
public Color(int r, int g, int b)
r
- the red componentg
- the green componentb
- the blue componentpublic Color(int r, int g, int b, int a)
r
- the red componentg
- the green componentb
- the blue componenta
- the alpha componentpublic Color brighter()
This method creates a brighter version of this color. The alpha value is
preserved. Although brighter
and darker
are
inverse operations, the results of a series of invocations of these two
methods might be inconsistent because of rounding errors.
public Color darker()
This method creates a darker version of this color. The alpha value is
preserved. Although brighter
and darker
are
inverse operations, the results of a series of invocations of these two
methods might be inconsistent because of rounding errors.
public boolean equals(java.lang.Object obj)
The result is true if and only if the argument is not null and is a greenfoot.Color object that has the same red, green, blue, and alpha values as this object.
equals
in class java.lang.Object
obj
- the object to test for equality with this colorpublic int getRed()
public int getGreen()
public int getAlpha()
public int getBlue()
public int hashCode()
Color
.hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object