Package zombie.core
Class Color
java.lang.Object
zombie.core.Color
- All Implemented Interfaces:
Serializable
A simple wrapper round the values required for a colour
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionfloat
The alpha component of the colourfloat
The blue component of the colourstatic final Color
The fixed colour blackstatic final Color
The fixed colour bluestatic final Color
The fixed colour cyanstatic final Color
The fixed colour dark graystatic final Color
The fixed colour dark greenfloat
The green component of the colourstatic final Color
The fixed colour graystatic final Color
The fixed colour greenstatic final Color
The fixed colour light graystatic final Color
The fixed colour light greenstatic final Color
The fixed colour dark magentastatic final Color
The fixed colour dark orangestatic final Color
The fixed colour dark pinkstatic final Color
The fixed colour purplefloat
The red component of the colourstatic final Color
The fixed colour redstatic final Color
The fixed color transparentstatic final Color
The fixed colour whitestatic final Color
The fixed colour yellow -
Constructor Summary
ConstructorDescriptionColor()
Color
(float r, float g, float b) Create a 3 component colourColor
(float r, float g, float b, float a) Create a 4 component colourColor
(int value) Create a colour from an evil integer packed 0xAARRGGBB.Color
(int r, int g, int b) Create a 3 component colourColor
(int r, int g, int b, int a) Create a 4 component colourCopy constructor -
Method Summary
Modifier and TypeMethodDescriptionstatic Color
abgrToColor
(int valueABGR, Color out_result) void
Add another colour to this oneAdd another colour to this onestatic int
blendABGR
(int valueABGR, int targetABGR) static int
blendBGR
(int valueABGR, int targetABGR) brighter()
Make a brighter instance of this colourbrighter
(float scale) Make a brighter instance of this colourvoid
changeHSBValue
(float hFactor, float sFactor, float bFactor) static int
colorToABGR
(float r, float g, float b, float a) static int
colorToABGR
(Color val) darker()
Make a darker instance of this colourdarker
(float scale) Make a darker instance of this colourstatic Color
Decode a number in a string and process it as a colour reference.boolean
void
fromColor
(int valueABGR) Deprecated.Performs special-case processing on the supplied value.int
getAlpha()
get the alpha byte component of this colourint
get the alpha byte component of this colourstatic float
getAlphaChannelFromABGR
(int valueABGR) float
int
getBlue()
get the blue byte component of this colourint
get the blue byte component of this colourstatic float
getBlueChannelFromABGR
(int valueABGR) float
int
getGreen()
get the green byte component of this colourint
get the green byte component of this colourstatic float
getGreenChannelFromABGR
(int valueABGR) float
int
getRed()
get the red byte component of this colourint
get the red byte component of this colourstatic float
getRedChannelFromABGR
(int valueABGR) float
int
hashCode()
static Color
HSBtoRGB
(float hue, float saturation, float brightness) static Color
void
static int
lerpABGR
(int colA, int colB, float alpha) Multiply this color by anotherstatic int
multiplyABGR
(int valueABGR, int multiplierABGR) static int
multiplyBGR
(int valueABGR, int multiplierABGR) static Color
random()
Create a random color.scale
(float value) Scale the components of the colour by the given valuescaleCopy
(float value) Scale the components of the colour by the given valueset
(float r, float g, float b) set
(float r, float g, float b, float a) void
setABGR
(int valueABGR) static int
setAlphaChannelToABGR
(int valueABGR, float a) static int
setBlueChannelToABGR
(int valueABGR, float b) void
static int
setGreenChannelToABGR
(int valueABGR, float g) static int
setRedChannelToABGR
(int valueABGR, float r) static int
tintABGR
(int targetABGR, int tintABGR) toString()
-
Field Details
-
transparent
The fixed color transparent -
white
The fixed colour white -
yellow
The fixed colour yellow -
red
The fixed colour red -
purple
The fixed colour purple -
blue
The fixed colour blue -
green
The fixed colour green -
black
The fixed colour black -
gray
The fixed colour gray -
cyan
The fixed colour cyan -
darkGray
The fixed colour dark gray -
lightGray
The fixed colour light gray -
pink
The fixed colour dark pink -
orange
The fixed colour dark orange -
magenta
The fixed colour dark magenta -
darkGreen
The fixed colour dark green -
lightGreen
The fixed colour light green -
a
public float aThe alpha component of the colour -
b
public float bThe blue component of the colour -
g
public float gThe green component of the colour -
r
public float rThe red component of the colour
-
-
Constructor Details
-
Color
public Color() -
Color
Copy constructor- Parameters:
color
- The color to copy into the new instance
-
Color
public Color(float r, float g, float b) Create a 3 component colour- Parameters:
r
- The red component of the colour (0.0 -> 1.0)g
- The green component of the colour (0.0 -> 1.0)b
- The blue component of the colour (0.0 -> 1.0)
-
Color
public Color(float r, float g, float b, float a) Create a 4 component colour- Parameters:
r
- The red component of the colour (0.0 -> 1.0)g
- The green component of the colour (0.0 -> 1.0)b
- The blue component of the colour (0.0 -> 1.0)a
- The alpha component of the colour (0.0 -> 1.0)
-
Color
-
Color
public Color(int r, int g, int b) Create a 3 component colour- Parameters:
r
- The red component of the colour (0 -> 255)g
- The green component of the colour (0 -> 255)b
- The blue component of the colour (0 -> 255)
-
Color
public Color(int r, int g, int b, int a) Create a 4 component colour- Parameters:
r
- The red component of the colour (0 -> 255)g
- The green component of the colour (0 -> 255)b
- The blue component of the colour (0 -> 255)a
- The alpha component of the colour (0 -> 255)
-
Color
public Color(int value) Create a colour from an evil integer packed 0xAARRGGBB. If AA is specified as zero then it will be interpreted as unspecified and hence a value of 255 will be recorded.- Parameters:
value
- The value to interpret for the colour
-
-
Method Details
-
setColor
-
fromColor
Deprecated.Performs special-case processing on the supplied value. Recommend use argbToColor instead.Converts the supplied binary value into color values, and sets the result to this object. Performs a clamp on the alpha channel. Performs a special-case on the alpha channel, where if it is 0, it is set to MAX instead.- Parameters:
valueABGR
-
-
setABGR
public void setABGR(int valueABGR) -
abgrToColor
-
colorToABGR
-
colorToABGR
public static int colorToABGR(float r, float g, float b, float a) -
multiplyABGR
public static int multiplyABGR(int valueABGR, int multiplierABGR) -
multiplyBGR
public static int multiplyBGR(int valueABGR, int multiplierABGR) -
blendBGR
public static int blendBGR(int valueABGR, int targetABGR) -
blendABGR
public static int blendABGR(int valueABGR, int targetABGR) -
tintABGR
public static int tintABGR(int targetABGR, int tintABGR) -
lerpABGR
public static int lerpABGR(int colA, int colB, float alpha) -
getAlphaChannelFromABGR
public static float getAlphaChannelFromABGR(int valueABGR) -
getBlueChannelFromABGR
public static float getBlueChannelFromABGR(int valueABGR) -
getGreenChannelFromABGR
public static float getGreenChannelFromABGR(int valueABGR) -
getRedChannelFromABGR
public static float getRedChannelFromABGR(int valueABGR) -
setAlphaChannelToABGR
public static int setAlphaChannelToABGR(int valueABGR, float a) -
setBlueChannelToABGR
public static int setBlueChannelToABGR(int valueABGR, float b) -
setGreenChannelToABGR
public static int setGreenChannelToABGR(int valueABGR, float g) -
setRedChannelToABGR
public static int setRedChannelToABGR(int valueABGR, float r) -
random
Create a random color. -
decode
Decode a number in a string and process it as a colour reference.- Parameters:
nm
- The number string to decode- Returns:
- The color generated from the number read
-
add
Add another colour to this one- Parameters:
c
- The colour to add
-
addToCopy
Add another colour to this one- Parameters:
c
- The colour to add- Returns:
- The copy which has had the color added to it
-
brighter
Make a brighter instance of this colour- Returns:
- The brighter version of this colour
-
brighter
Make a brighter instance of this colour- Parameters:
scale
- The scale up of RGB (i.e. if you supply 0.03 the colour will be brightened by 3%)- Returns:
- The brighter version of this colour
-
darker
Make a darker instance of this colour- Returns:
- The darker version of this colour
-
darker
Make a darker instance of this colour- Parameters:
scale
- The scale down of RGB (i.e. if you supply 0.03 the colour will be darkened by 3%)- Returns:
- The darker version of this colour
-
equals
-
set
-
set
-
set
-
getAlpha
public int getAlpha()get the alpha byte component of this colour- Returns:
- The alpha component (range 0-255)
-
getAlphaFloat
public float getAlphaFloat() -
getRedFloat
public float getRedFloat() -
getGreenFloat
public float getGreenFloat() -
getBlueFloat
public float getBlueFloat() -
getAlphaByte
public int getAlphaByte()get the alpha byte component of this colour- Returns:
- The alpha component (range 0-255)
-
getBlue
public int getBlue()get the blue byte component of this colour- Returns:
- The blue component (range 0-255)
-
getBlueByte
public int getBlueByte()get the blue byte component of this colour- Returns:
- The blue component (range 0-255)
-
getGreen
public int getGreen()get the green byte component of this colour- Returns:
- The green component (range 0-255)
-
getGreenByte
public int getGreenByte()get the green byte component of this colour- Returns:
- The green component (range 0-255)
-
getRed
public int getRed()get the red byte component of this colour- Returns:
- The red component (range 0-255)
-
getRedByte
public int getRedByte()get the red byte component of this colour- Returns:
- The red component (range 0-255)
-
hashCode
public int hashCode() -
multiply
Multiply this color by another- Parameters:
c
- the other color- Returns:
- product of the two colors
-
scale
Scale the components of the colour by the given value- Parameters:
value
- The value to scale by
-
scaleCopy
Scale the components of the colour by the given value- Parameters:
value
- The value to scale by- Returns:
- The copy which has been scaled
-
toString
-
interp
-
changeHSBValue
public void changeHSBValue(float hFactor, float sFactor, float bFactor) -
HSBtoRGB
-
HSBtoRGB
-