Package greenfoot
Class Color
java.lang.Object
greenfoot.Color
A representation of a Color. The Color can be used to draw or fill shapes on
the screen.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ColorThe color black.static final ColorThe color blue.static final ColorThe color cyan.static final ColorThe color dark gray.static final ColorThe color gray.static final ColorThe color green.static final ColorThe color light gray.static final ColorThe color magenta.static final ColorThe color orange.static final ColorThe color pink.static final ColorThe color red.static final ColorThe color white.static final ColorThe color yellow. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbrighter()Creates a new color that is a brighter version of this GreenfootColor.darker()Creates a new GreenfootColor that is a darker version of this GreenfootColor.booleanDetermines whether another object is equal to this color.intgetAlpha()Returns the alpha component in the range 0-255.intgetBlue()Returns the blue component in the range 0-255 in the default RGB space.intgetGreen()Returns the green component in the range 0-255 in the default RGB space.intgetRed()Returns the red component in the range 0-255 in the default RGB space.inthashCode()Computes the hash code for thisColor.toString()Return a text representation of the color.
-
Field Details
-
WHITE
The color white. In the default RGB space. -
LIGHT_GRAY
The color light gray. In the default RGB space. -
GRAY
The color gray. In the default RGB space. -
DARK_GRAY
The color dark gray. In the default RGB space. -
BLACK
The color black. In the default RGB space. -
RED
The color red. In the default RGB space. -
PINK
The color pink. In the default RGB space. -
ORANGE
The color orange. In the default RGB space. -
YELLOW
The color yellow. In the default RGB space. -
GREEN
The color green. In the default RGB space. -
MAGENTA
The color magenta. In the default RGB space. -
CYAN
The color cyan. In the default RGB space. -
BLUE
The color blue. In the default RGB space.
-
-
Constructor Details
-
Color
public Color(int r, int g, int b) Creates a RGB color with the specified red, green, blue values in the range (0 - 255).- Parameters:
r- the red componentg- the green componentb- the blue component
-
Color
public 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).- Parameters:
r- the red componentg- the green componentb- the blue componenta- the alpha component
-
-
Method Details
-
brighter
Creates a new color that is a brighter version of this GreenfootColor.This method creates a brighter version of this color. The alpha value is preserved. Although
brighteranddarkerare inverse operations, the results of a series of invocations of these two methods might be inconsistent because of rounding errors.- Returns:
- a new GreenfootColor object that is a brighter version of this GreenfootColor with the same alpha value.
-
darker
Creates a new GreenfootColor that is a darker version of this GreenfootColor.This method creates a darker version of this color. The alpha value is preserved. Although
brighteranddarkerare inverse operations, the results of a series of invocations of these two methods might be inconsistent because of rounding errors.- Returns:
- a new GreenfootColor object that is a darker version of this GreenfootColor with the same alpha value.
-
equals
Determines whether another object is equal to this color.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.
-
getRed
public int getRed()Returns the red component in the range 0-255 in the default RGB space.- Returns:
- the red component.
-
getGreen
public int getGreen()Returns the green component in the range 0-255 in the default RGB space.- Returns:
- the green component.
-
getAlpha
public int getAlpha()Returns the alpha component in the range 0-255.- Returns:
- the alpha component.
-
getBlue
public int getBlue()Returns the blue component in the range 0-255 in the default RGB space.- Returns:
- the blue component.
-
hashCode
public int hashCode()Computes the hash code for thisColor. -
toString
Return a text representation of the color.
-