Package org.lwjgl.util
Class Color
- java.lang.Object
-
- org.lwjgl.util.Color
-
- All Implemented Interfaces:
java.io.Serializable
,ReadableColor
,WritableColor
public final class Color extends java.lang.Object implements ReadableColor, java.io.Serializable, WritableColor
A mutable Color class- Version:
- $Revision$ $Id$
- Author:
- $Author$
- See Also:
- Serialized Form
-
-
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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object o)
Equalsvoid
fromHSB(float hue, float saturation, float brightness)
HSB to RGB conversion, pinched from java.awt.Color.int
getAlpha()
Accessorbyte
getAlphaByte()
Return the red componentint
getBlue()
Accessorbyte
getBlueByte()
Return the red componentint
getGreen()
Accessorbyte
getGreenByte()
Return the red componentint
getRed()
Accessorbyte
getRedByte()
Return the red componentint
hashCode()
Hashcodevoid
readABGR(java.nio.ByteBuffer src)
Read a color from a byte buffervoid
readARGB(java.nio.ByteBuffer src)
Read a color from a byte buffervoid
readBGR(java.nio.ByteBuffer src)
Read a color from a byte buffervoid
readBGRA(java.nio.ByteBuffer src)
Read a color from a byte buffervoid
readRGB(java.nio.ByteBuffer src)
Read a color from a byte buffervoid
readRGBA(java.nio.ByteBuffer src)
Read a color from a byte buffervoid
set(byte r, byte g, byte b)
Set a colorvoid
set(byte r, byte g, byte b, byte a)
Set a colorvoid
set(int r, int g, int b)
Set a colorvoid
set(int r, int g, int b, int a)
Set a colorvoid
setAlpha(byte alpha)
Set the Alpha componentvoid
setAlpha(int alpha)
Set the Alpha componentvoid
setBlue(byte blue)
Set the Blue componentvoid
setBlue(int blue)
Set the Blue componentvoid
setColor(ReadableColor src)
Set this color's color by copying another colorvoid
setGreen(byte green)
Set the Green componentvoid
setGreen(int green)
Set the Green componentvoid
setRed(byte red)
Set the Red componentvoid
setRed(int red)
Set the Red componentfloat[]
toHSB(float[] dest)
RGB to HSB conversion, pinched from java.awt.Color.java.lang.String
toString()
Stringifyvoid
writeABGR(java.nio.ByteBuffer dest)
Write the ABGR color directly out to a ByteBuffervoid
writeARGB(java.nio.ByteBuffer dest)
Write the ARGB color directly out to a ByteBuffervoid
writeBGR(java.nio.ByteBuffer dest)
Write the BGR color directly out to a ByteBuffervoid
writeBGRA(java.nio.ByteBuffer dest)
Write the BGRA color directly out to a ByteBuffervoid
writeRGB(java.nio.ByteBuffer dest)
Write the RGB color directly out to a ByteBuffervoid
writeRGBA(java.nio.ByteBuffer dest)
Write the RGBA color directly out to a ByteBuffer
-
-
-
Constructor Detail
-
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 Detail
-
set
public void set(int r, int g, int b, int a)
Set a color- Specified by:
set
in interfaceWritableColor
-
set
public void set(byte r, byte g, byte b, byte a)
Set a color- Specified by:
set
in interfaceWritableColor
-
set
public void set(int r, int g, int b)
Set a color- Specified by:
set
in interfaceWritableColor
-
set
public void set(byte r, byte g, byte b)
Set a color- Specified by:
set
in interfaceWritableColor
-
getRed
public int getRed()
Accessor- Specified by:
getRed
in interfaceReadableColor
- Returns:
- int
-
getGreen
public int getGreen()
Accessor- Specified by:
getGreen
in interfaceReadableColor
- Returns:
- int
-
getBlue
public int getBlue()
Accessor- Specified by:
getBlue
in interfaceReadableColor
- Returns:
- int
-
getAlpha
public int getAlpha()
Accessor- Specified by:
getAlpha
in interfaceReadableColor
- Returns:
- int
-
setRed
public void setRed(int red)
Set the Red component- Specified by:
setRed
in interfaceWritableColor
-
setGreen
public void setGreen(int green)
Set the Green component- Specified by:
setGreen
in interfaceWritableColor
-
setBlue
public void setBlue(int blue)
Set the Blue component- Specified by:
setBlue
in interfaceWritableColor
-
setAlpha
public void setAlpha(int alpha)
Set the Alpha component- Specified by:
setAlpha
in interfaceWritableColor
-
setRed
public void setRed(byte red)
Set the Red component- Specified by:
setRed
in interfaceWritableColor
-
setGreen
public void setGreen(byte green)
Set the Green component- Specified by:
setGreen
in interfaceWritableColor
-
setBlue
public void setBlue(byte blue)
Set the Blue component- Specified by:
setBlue
in interfaceWritableColor
-
setAlpha
public void setAlpha(byte alpha)
Set the Alpha component- Specified by:
setAlpha
in interfaceWritableColor
-
toString
public java.lang.String toString()
Stringify- Overrides:
toString
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
Equals- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
Hashcode- Overrides:
hashCode
in classjava.lang.Object
-
getAlphaByte
public byte getAlphaByte()
Description copied from interface:ReadableColor
Return the red component- Specified by:
getAlphaByte
in interfaceReadableColor
- Returns:
- int
-
getBlueByte
public byte getBlueByte()
Description copied from interface:ReadableColor
Return the red component- Specified by:
getBlueByte
in interfaceReadableColor
- Returns:
- int
-
getGreenByte
public byte getGreenByte()
Description copied from interface:ReadableColor
Return the red component- Specified by:
getGreenByte
in interfaceReadableColor
- Returns:
- int
-
getRedByte
public byte getRedByte()
Description copied from interface:ReadableColor
Return the red component- Specified by:
getRedByte
in interfaceReadableColor
- Returns:
- int
-
writeRGBA
public void writeRGBA(java.nio.ByteBuffer dest)
Description copied from interface:ReadableColor
Write the RGBA color directly out to a ByteBuffer- Specified by:
writeRGBA
in interfaceReadableColor
- Parameters:
dest
- the buffer to write to
-
writeRGB
public void writeRGB(java.nio.ByteBuffer dest)
Description copied from interface:ReadableColor
Write the RGB color directly out to a ByteBuffer- Specified by:
writeRGB
in interfaceReadableColor
- Parameters:
dest
- the buffer to write to
-
writeABGR
public void writeABGR(java.nio.ByteBuffer dest)
Description copied from interface:ReadableColor
Write the ABGR color directly out to a ByteBuffer- Specified by:
writeABGR
in interfaceReadableColor
- Parameters:
dest
- the buffer to write to
-
writeARGB
public void writeARGB(java.nio.ByteBuffer dest)
Description copied from interface:ReadableColor
Write the ARGB color directly out to a ByteBuffer- Specified by:
writeARGB
in interfaceReadableColor
- Parameters:
dest
- the buffer to write to
-
writeBGR
public void writeBGR(java.nio.ByteBuffer dest)
Description copied from interface:ReadableColor
Write the BGR color directly out to a ByteBuffer- Specified by:
writeBGR
in interfaceReadableColor
- Parameters:
dest
- the buffer to write to
-
writeBGRA
public void writeBGRA(java.nio.ByteBuffer dest)
Description copied from interface:ReadableColor
Write the BGRA color directly out to a ByteBuffer- Specified by:
writeBGRA
in interfaceReadableColor
- Parameters:
dest
- the buffer to write to
-
readRGBA
public void readRGBA(java.nio.ByteBuffer src)
Read a color from a byte buffer- Specified by:
readRGBA
in interfaceWritableColor
- Parameters:
src
- The source buffer
-
readRGB
public void readRGB(java.nio.ByteBuffer src)
Read a color from a byte buffer- Specified by:
readRGB
in interfaceWritableColor
- Parameters:
src
- The source buffer
-
readARGB
public void readARGB(java.nio.ByteBuffer src)
Read a color from a byte buffer- Specified by:
readARGB
in interfaceWritableColor
- Parameters:
src
- The source buffer
-
readBGRA
public void readBGRA(java.nio.ByteBuffer src)
Read a color from a byte buffer- Specified by:
readBGRA
in interfaceWritableColor
- Parameters:
src
- The source buffer
-
readBGR
public void readBGR(java.nio.ByteBuffer src)
Read a color from a byte buffer- Specified by:
readBGR
in interfaceWritableColor
- Parameters:
src
- The source buffer
-
readABGR
public void readABGR(java.nio.ByteBuffer src)
Read a color from a byte buffer- Specified by:
readABGR
in interfaceWritableColor
- Parameters:
src
- The source buffer
-
setColor
public void setColor(ReadableColor src)
Set this color's color by copying another color- Specified by:
setColor
in interfaceWritableColor
- 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
-
-