zombie.core
Class Color

java.lang.Object
  extended by zombie.core.Color
All Implemented Interfaces:
java.io.Serializable

public class Color
extends java.lang.Object
implements java.io.Serializable

A simple wrapper round the values required for a colour

Author:
Kevin Glass
See Also:
Serialized Form

Field Summary
 float a
          The alpha component of the colour
 float b
          The blue component of the colour
static Color black
          The fixed colour black
static Color blue
          The fixed colour blue
static Color cyan
          The fixed colour cyan
static Color darkGray
          The fixed colour dark gray
 float g
          The green component of the colour
static Color gray
          The fixed colour gray
static Color green
          The fixed colour green
static Color lightGray
          The fixed colour light gray
static Color magenta
          The fixed colour dark magenta
static Color orange
          The fixed colour dark orange
static Color pink
          The fixed colour dark pink
 float r
          The red component of the colour
static Color red
          The fixed colour red
static Color transparent
          The fixed color transparent
static Color white
          The fixed colour white
static Color yellow
          The fixed colour yellow
 
Constructor Summary
Color(Color color)
          Copy constructor
Color(Color A, Color B, float delta)
           
Color(float r, float g, float b)
          Create a 3 component colour
Color(float r, float g, float b, float a)
          Create a 4 component colour
Color(int value)
          Create a colour from an evil integer packed 0xAARRGGBB.
Color(int r, int g, int b)
          Create a 3 component colour
Color(int r, int g, int b, int a)
          Create a 4 component colour
 
Method Summary
 void add(Color c)
          Add another colour to this one
 Color addToCopy(Color c)
          Add another colour to this one
 Color brighter()
          Make a brighter instance of this colour
 Color brighter(float scale)
          Make a brighter instance of this colour
 Color darker()
          Make a darker instance of this colour
 Color darker(float scale)
          Make a darker instance of this colour
static Color decode(java.lang.String nm)
          Decode a number in a string and process it as a colour reference.
 boolean equals(java.lang.Object other)
           
 void fromColor(int value)
           
 int getAlpha()
          get the alpha byte component of this colour
 int getAlphaByte()
          get the alpha byte component of this colour
 float getAlphaFloat()
           
 int getBlue()
          get the blue byte component of this colour
 int getBlueByte()
          get the blue byte component of this colour
 float getBlueFloat()
           
 int getGreen()
          get the green byte component of this colour
 int getGreenByte()
          get the green byte component of this colour
 float getGreenFloat()
           
 int getRed()
          get the red byte component of this colour
 int getRedByte()
          get the red byte component of this colour
 float getRedFloat()
           
 int hashCode()
           
 void interp(Color to, float delta, Color dest)
           
 Color multiply(Color c)
          Multiply this color by another
 void scale(float value)
          Scale the components of the colour by the given value
 Color scaleCopy(float value)
          Scale the components of the colour by the given value
 void set(Color other)
           
 void setColor(Color A, Color B, float delta)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

transparent

public static final Color transparent
The fixed color transparent


white

public static final Color white
The fixed colour white


yellow

public static final Color yellow
The fixed colour yellow


red

public static final Color red
The fixed colour red


blue

public static final Color blue
The fixed colour blue


green

public static final Color green
The fixed colour green


black

public static final Color black
The fixed colour black


gray

public static final Color gray
The fixed colour gray


cyan

public static final Color cyan
The fixed colour cyan


darkGray

public static final Color darkGray
The fixed colour dark gray


lightGray

public static final Color lightGray
The fixed colour light gray


pink

public static final Color pink
The fixed colour dark pink


orange

public static final Color orange
The fixed colour dark orange


magenta

public static final Color magenta
The fixed colour dark magenta


a

public float a
The alpha component of the colour


b

public float b
The blue component of the colour


g

public float g
The green component of the colour


r

public float r
The red component of the colour

Constructor Detail

Color

public Color(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

public Color(Color A,
             Color B,
             float delta)

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 Detail

setColor

public void setColor(Color A,
                     Color B,
                     float delta)

fromColor

public void fromColor(int value)

decode

public static Color decode(java.lang.String nm)
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

public void add(Color c)
Add another colour to this one

Parameters:
c - The colour to add

addToCopy

public Color addToCopy(Color c)
Add another colour to this one

Parameters:
c - The colour to add
Returns:
The copy which has had the color added to it

brighter

public Color brighter()
Make a brighter instance of this colour

Returns:
The brighter version of this colour

brighter

public Color brighter(float scale)
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

public Color darker()
Make a darker instance of this colour

Returns:
The darker version of this colour

darker

public Color darker(float scale)
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

public boolean equals(java.lang.Object other)
Overrides:
equals in class java.lang.Object
See Also:
Object.equals(java.lang.Object)

set

public void set(Color other)

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()
Overrides:
hashCode in class java.lang.Object
See Also:
Object.hashCode()

multiply

public Color multiply(Color c)
Multiply this color by another

Parameters:
c - the other color
Returns:
product of the two colors

scale

public void scale(float value)
Scale the components of the colour by the given value

Parameters:
value - The value to scale by

scaleCopy

public Color scaleCopy(float value)
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

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
See Also:
Object.toString()

interp

public void interp(Color to,
                   float delta,
                   Color dest)