# Color (Slick - The 2D Library)
Date: 2013-06-03

## org.newdawn.slick
Class Color

    java.lang.Object
      org.newdawn.slick.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
`protected SGL` `GL` The renderer to use for all GL operations
`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(java.nio.FloatBuffer buffer)` Create a component based on the first 4 elements of a float buffer
`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
`void` `bind()` Bind this colour to the GL context
`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)`
`int` `getAlpha()` Get the alpha byte component of this colour
`int` `getAlphaByte()` Get the alpha byte component of this colour
`int` `getBlue()` Get the blue byte component of this colour
`int` `getBlueByte()` Get the blue byte component of this colour
`int` `getGreen()` Get the green byte component of this colour
`int` `getGreenByte()` Get the green byte component of this colour
`int` `getRed()` Get the red byte component of this colour
`int` `getRedByte()` Get the red byte component of this colour
`int` `hashCode()`
`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
`java.lang.String` `toString()`

Methods inherited from class java.lang.Object
`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

Field Detail

### GL

    protected transient SGL GL

  The renderer to use for all GL operations

### 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

### r

    public float r

  The red component of the colour

### g

    public float g

  The green component of the colour

### b

    public float b

  The blue component of the colour

### a

    public float a

  The alpha 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(java.nio.FloatBuffer buffer)

  Create a component based on the first 4 elements of a float buffer

  Parameters:
    `buffer` - The buffer to read the color from

### 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(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

### 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

### bind

    public void bind()

  Bind this colour to the GL context

### hashCode

    public int hashCode()

  Overrides:
    `hashCode` in class `java.lang.Object`
  See Also:
    `Object.hashCode()`

### equals

    public boolean equals(java.lang.Object other)

  Overrides:
    `equals` in class `java.lang.Object`
  See Also:
    `Object.equals(java.lang.Object)`

### toString

    public java.lang.String toString()

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

### 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

### brighter

    public Color brighter()

  Make a brighter instance of this colour

  Returns:
    The brighter version of this colour

### getRed

    public int getRed()

  Get the red byte component of this colour

  Returns:
    The red component (range 0-255)

### getGreen

    public int getGreen()

  Get the green byte component of this colour

  Returns:
    The green component (range 0-255)

### getBlue

    public int getBlue()

  Get the blue byte component of this colour

  Returns:
    The blue component (range 0-255)

### getAlpha

    public int getAlpha()

  Get the alpha byte component of this colour

  Returns:
    The alpha component (range 0-255)

### getRedByte

    public int getRedByte()

  Get the red byte component of this colour

  Returns:
    The red component (range 0-255)

### getGreenByte

    public int getGreenByte()

  Get the green byte component of this colour

  Returns:
    The green component (range 0-255)

### getBlueByte

    public int getBlueByte()

  Get the blue byte component of this colour

  Returns:
    The blue component (range 0-255)

### getAlphaByte

    public int getAlphaByte()

  Get the alpha byte component of this colour

  Returns:
    The alpha component (range 0-255)

### 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

### multiply

    public Color multiply(Color c)

  Multiply this color by another

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

### add

    public void add(Color c)

  Add another colour to this one

  Parameters:
    `c` - The colour to add

### scale

    public void scale(float value)

  Scale the components of the colour by the given value

  Parameters:
    `value` - The value to scale by

### 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

### 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

Copyright © 2006 New Dawn Software. All Rights Reserved.