Package org.lwjgl.util

# Class Color

java.lang.Object
org.lwjgl.util.Color

All Implemented Interfaces:
  `Serializable`, `ReadableColor`, `WritableColor`

public final class Color extends Object implements ReadableColor, Serializable, WritableColor
A mutable Color class

Version:
  $Revision$ $Id$
Author:
  $Author$
See Also:
  - Serialized Form

## Field Summary

### Fields inherited from interface org.lwjgl.util.ReadableColor

`BLACK, BLUE, CYAN, DKGREY, GREEN, GREY, LTGREY, ORANGE, PURPLE, RED, WHITE, YELLOW`

## Constructor Summary

Constructors
Constructor
Description
`Color()`
Constructor for Color.
`Color(byte r, byte g, byte b)`
Constructor for Color.
`Color(byte r, byte g, byte b, byte a)`
Constructor for Color.
`Color(int r, int g, int b)`
Constructor for Color.
`Color(int r, int g, int b, int a)`
Constructor for Color.
`Color(ReadableColor c)`
Constructor for Color

## Method Summary

Modifier and Type
Method
Description
`boolean`
`equals(Object o)`
Equals
`void`
`fromHSB(float hue, float saturation, float brightness)`
HSB to RGB conversion, pinched from java.awt.Color.
`int`
`getAlpha()`
Accessor
`byte`
`getAlphaByte()`
Return the red component
`int`
`getBlue()`
Accessor
`byte`
`getBlueByte()`
Return the red component
`int`
`getGreen()`
Accessor
`byte`
`getGreenByte()`
Return the red component
`int`
`getRed()`
Accessor
`byte`
`getRedByte()`
Return the red component
`int`
`hashCode()`
Hashcode
`void`
`readABGR(ByteBuffer src)`
Read a color from a byte buffer
`void`
`readARGB(ByteBuffer src)`
Read a color from a byte buffer
`void`
`readBGR(ByteBuffer src)`
Read a color from a byte buffer
`void`
`readBGRA(ByteBuffer src)`
Read a color from a byte buffer
`void`
`readRGB(ByteBuffer src)`
Read a color from a byte buffer
`void`
`readRGBA(ByteBuffer src)`
Read a color from a byte buffer
`void`
`set(byte r, byte g, byte b)`
Set a color
`void`
`set(byte r, byte g, byte b, byte a)`
Set a color
`void`
`set(int r, int g, int b)`
Set a color
`void`
`set(int r, int g, int b, int a)`
Set a color
`void`
`setAlpha(byte alpha)`
Set the Alpha component
`void`
`setAlpha(int alpha)`
Set the Alpha component
`void`
`setBlue(byte blue)`
Set the Blue component
`void`
`setBlue(int blue)`
Set the Blue component
`void`
`setColor(ReadableColor src)`
Set this color's color by copying another color
`void`
`setGreen(byte green)`
Set the Green component
`void`
`setGreen(int green)`
Set the Green component
`void`
`setRed(byte red)`
Set the Red component
`void`
`setRed(int red)`
Set the Red component
`float[]`
`toHSB(float[] dest)`
RGB to HSB conversion, pinched from java.awt.Color.
`String`
`toString()`
Stringify
`void`
`writeABGR(ByteBuffer dest)`
Write the ABGR color directly out to a ByteBuffer
`void`
`writeARGB(ByteBuffer dest)`
Write the ARGB color directly out to a ByteBuffer
`void`
`writeBGR(ByteBuffer dest)`
Write the BGR color directly out to a ByteBuffer
`void`
`writeBGRA(ByteBuffer dest)`
Write the BGRA color directly out to a ByteBuffer
`void`
`writeRGB(ByteBuffer dest)`
Write the RGB color directly out to a ByteBuffer
`void`
`writeRGBA(ByteBuffer dest)`
Write the RGBA color directly out to a ByteBuffer

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

## Constructor Details

### Color

public Color()
Constructor for Color.

### Color

public Color(int r, int g, int b)
Constructor for Color. Alpha defaults to 255.

### Color

public Color(byte r, byte g, byte b)
Constructor for Color. Alpha defaults to 255.

### Color

public Color(int r, int g, int b, int a)
Constructor for Color.

### Color

public Color(byte r, byte g, byte b, byte a)
Constructor for Color.

### Color

public Color(ReadableColor c)
Constructor for Color

## Method Details

### set

public void set(int r, int g, int b, int a)
Set a color

Specified by:
  `set` in interface `WritableColor`

### set

public void set(byte r, byte g, byte b, byte a)
Set a color

Specified by:
  `set` in interface `WritableColor`

### set

public void set(int r, int g, int b)
Set a color

Specified by:
  `set` in interface `WritableColor`

### set

public void set(byte r, byte g, byte b)
Set a color

Specified by:
  `set` in interface `WritableColor`

### getRed

public int getRed()
Accessor

Specified by:
  `getRed` in interface `ReadableColor`
Returns:
  int

### getGreen

public int getGreen()
Accessor

Specified by:
  `getGreen` in interface `ReadableColor`
Returns:
  int

### getBlue

public int getBlue()
Accessor

Specified by:
  `getBlue` in interface `ReadableColor`
Returns:
  int

### getAlpha

public int getAlpha()
Accessor

Specified by:
  `getAlpha` in interface `ReadableColor`
Returns:
  int

### setRed

public void setRed(int red)
Set the Red component

Specified by:
  `setRed` in interface `WritableColor`

### setGreen

public void setGreen(int green)
Set the Green component

Specified by:
  `setGreen` in interface `WritableColor`

### setBlue

public void setBlue(int blue)
Set the Blue component

Specified by:
  `setBlue` in interface `WritableColor`

### setAlpha

public void setAlpha(int alpha)
Set the Alpha component

Specified by:
  `setAlpha` in interface `WritableColor`

### setRed

public void setRed(byte red)
Set the Red component

Specified by:
  `setRed` in interface `WritableColor`

### setGreen

public void setGreen(byte green)
Set the Green component

Specified by:
  `setGreen` in interface `WritableColor`

### setBlue

public void setBlue(byte blue)
Set the Blue component

Specified by:
  `setBlue` in interface `WritableColor`

### setAlpha

public void setAlpha(byte alpha)
Set the Alpha component

Specified by:
  `setAlpha` in interface `WritableColor`

### toString

public String toString()
Stringify

Overrides:
  `toString` in class `Object`

### equals

public boolean equals(Object o)
Equals

Overrides:
  `equals` in class `Object`

### hashCode

public int hashCode()
Hashcode

Overrides:
  `hashCode` in class `Object`

### getAlphaByte

public byte getAlphaByte()
Description copied from interface: `ReadableColor`
Return the red component

Specified by:
  `getAlphaByte` in interface `ReadableColor`
Returns:
  int

### getBlueByte

public byte getBlueByte()
Description copied from interface: `ReadableColor`
Return the red component

Specified by:
  `getBlueByte` in interface `ReadableColor`
Returns:
  int

### getGreenByte

public byte getGreenByte()
Description copied from interface: `ReadableColor`
Return the red component

Specified by:
  `getGreenByte` in interface `ReadableColor`
Returns:
  int

### getRedByte

public byte getRedByte()
Description copied from interface: `ReadableColor`
Return the red component

Specified by:
  `getRedByte` in interface `ReadableColor`
Returns:
  int

### writeRGBA

public void writeRGBA(ByteBuffer dest)
Description copied from interface: `ReadableColor`
Write the RGBA color directly out to a ByteBuffer

Specified by:
  `writeRGBA` in interface `ReadableColor`
Parameters:
  `dest` - the buffer to write to

### writeRGB

public void writeRGB(ByteBuffer dest)
Description copied from interface: `ReadableColor`
Write the RGB color directly out to a ByteBuffer

Specified by:
  `writeRGB` in interface `ReadableColor`
Parameters:
  `dest` - the buffer to write to

### writeABGR

public void writeABGR(ByteBuffer dest)
Description copied from interface: `ReadableColor`
Write the ABGR color directly out to a ByteBuffer

Specified by:
  `writeABGR` in interface `ReadableColor`
Parameters:
  `dest` - the buffer to write to

### writeARGB

public void writeARGB(ByteBuffer dest)
Description copied from interface: `ReadableColor`
Write the ARGB color directly out to a ByteBuffer

Specified by:
  `writeARGB` in interface `ReadableColor`
Parameters:
  `dest` - the buffer to write to

### writeBGR

public void writeBGR(ByteBuffer dest)
Description copied from interface: `ReadableColor`
Write the BGR color directly out to a ByteBuffer

Specified by:
  `writeBGR` in interface `ReadableColor`
Parameters:
  `dest` - the buffer to write to

### writeBGRA

public void writeBGRA(ByteBuffer dest)
Description copied from interface: `ReadableColor`
Write the BGRA color directly out to a ByteBuffer

Specified by:
  `writeBGRA` in interface `ReadableColor`
Parameters:
  `dest` - the buffer to write to

### readRGBA

public void readRGBA(ByteBuffer src)
Read a color from a byte buffer

Specified by:
  `readRGBA` in interface `WritableColor`
Parameters:
  `src` - The source buffer

### readRGB

public void readRGB(ByteBuffer src)
Read a color from a byte buffer

Specified by:
  `readRGB` in interface `WritableColor`
Parameters:
  `src` - The source buffer

### readARGB

public void readARGB(ByteBuffer src)
Read a color from a byte buffer

Specified by:
  `readARGB` in interface `WritableColor`
Parameters:
  `src` - The source buffer

### readBGRA

public void readBGRA(ByteBuffer src)
Read a color from a byte buffer

Specified by:
  `readBGRA` in interface `WritableColor`
Parameters:
  `src` - The source buffer

### readBGR

public void readBGR(ByteBuffer src)
Read a color from a byte buffer

Specified by:
  `readBGR` in interface `WritableColor`
Parameters:
  `src` - The source buffer

### readABGR

public void readABGR(ByteBuffer src)
Read a color from a byte buffer

Specified by:
  `readABGR` in interface `WritableColor`
Parameters:
  `src` - The source buffer

### setColor

public void setColor(ReadableColor src)
Set this color's color by copying another color

Specified by:
  `setColor` in interface `WritableColor`
Parameters:
  `src` - The source color

### fromHSB

public void fromHSB(float hue, float saturation, float brightness)
HSB to RGB conversion, pinched from java.awt.Color.

Parameters:
  `hue` - (0..1.0f)
  `saturation` - (0..1.0f)
  `brightness` - (0..1.0f)

### toHSB

public float[] toHSB(float[] dest)
RGB to HSB conversion, pinched from java.awt.Color. The HSB value is returned in dest[] if dest[] is supplied. Values range from 0..1

Parameters:
  `dest` - Destination floats, or null
Returns:
  dest, or a new float array