com.threerings.opengl.renderer
Class Color4f

java.lang.Object
  extended by com.threerings.opengl.renderer.Color4f
All Implemented Interfaces:
Encodable, Exportable, com.threerings.io.Streamable

public final class Color4f
extends Object
implements Encodable, com.threerings.io.Streamable

A four-element floating point color value.


Nested Class Summary
 
Nested classes/interfaces inherited from interface com.threerings.io.Streamable
com.threerings.io.Streamable.Closure
 
Field Summary
 float a
          The components of the color.
 float b
          The components of the color.
static Color4f BLACK
          An opaque black color object.
static Color4f BLUE
          An opaque blue color object.
static Color4f CYAN
          An opaque cyan color object.
static Color4f DARK_GRAY
          An opaque dark gray color object (OpenGL's default ambient material color).
 float g
          The components of the color.
static Color4f GRAY
          An opaque gray color object (OpenGL's default diffuse material color).
static Color4f GREEN
          An opaque green color object.
static Color4f MAGENTA
          An opaque magenta color object.
 float r
          The components of the color.
static Color4f RED
          An opaque red color object.
static Color4f WHITE
          An opaque white color object.
static Color4f YELLOW
          An opaque yellor color object.
 
Constructor Summary
Color4f()
          Creates an opaque white color object.
Color4f(Color color)
          Creates a color object from an AWT color.
Color4f(Color4f other)
          Copy constructor.
Color4f(float[] values)
          Creates a color from an array of values.
Color4f(float r, float g, float b, float a)
          Creates a color with the supplied components.
 
Method Summary
 Color4f add(Color4f other)
          Adds a color to this one.
 Color4f add(Color4f other, Color4f result)
          Adds a color to this one, storing the result in the object provided.
 Color4f addLocal(Color4f other)
          Adds a color in-place to this one.
 Color4f clampedAdd(Color4f other)
          Adds another color to this one, clamping the elements of the result to one.
 Color4f clampedAdd(Color4f other, Color4f result)
          Adds another color to this one, clamping the elements of the result to one, and storing the result in the object provided.
 Color4f clampedAddLocal(Color4f other)
          Adds another color to this one in-place, clamping the elements of the result to one.
 void decodeFromStream(DataInputStream in)
          Initializes this object with data read from the specified stream.
 void decodeFromString(String string)
          Initializes this object with the contents of the specified string.
 void encodeToStream(DataOutputStream out)
          Encodes this object to the specified stream.
 String encodeToString()
          Returns a string representation of this object.
 boolean equals(Object other)
           
 FloatBuffer get(FloatBuffer buf)
          Places the components of this color object into the specified buffer.
 Color getColor()
          Returns the AWT color object corresponding to this color.
 Color getColor(boolean includeAlpha)
          Returns the AWT color object corresponding to this color.
 int hashCode()
           
 Color4f lerp(Color4f other, float t)
          Linearly interpolates between this and the specified other color by the supplied amount.
 Color4f lerp(Color4f other, float t, Color4f result)
          Linearly interpolates between this and the supplied other color by the supplied amount, storing the result in the supplied object.
 Color4f lerpLocal(Color4f other, float t)
          Linearly interpolates between this and the specified other color in-place by the supplied amount.
 Color4f mult(Color4f other)
          Multiplies this color by another.
 Color4f mult(Color4f other, Color4f result)
          Multiplies this color by another, storing the result in the object provided.
 Color4f mult(float value)
          Multiplies this color by the specified value.
 Color4f mult(float value, Color4f result)
          Multiplies this color by the specified value, placing the result in the object provided.
 Color4f multLocal(Color4f other)
          Multiplies this color in-place by another.
 Color4f multLocal(float value)
          Multiplies this color in-place by the specified value.
 Color4f set(Color color)
          Copies the components of an AWT color.
 Color4f set(Color4f other)
          Copies the components of another color.
 Color4f set(float[] values)
          Copies the elements of an array.
 Color4f set(float r, float g, float b, float a)
          Sets all the components of this color.
 String toString()
           
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

WHITE

public static final Color4f WHITE
An opaque white color object.


GRAY

public static final Color4f GRAY
An opaque gray color object (OpenGL's default diffuse material color).


DARK_GRAY

public static final Color4f DARK_GRAY
An opaque dark gray color object (OpenGL's default ambient material color).


BLACK

public static final Color4f BLACK
An opaque black color object.


RED

public static final Color4f RED
An opaque red color object.


GREEN

public static final Color4f GREEN
An opaque green color object.


BLUE

public static final Color4f BLUE
An opaque blue color object.


CYAN

public static final Color4f CYAN
An opaque cyan color object.


MAGENTA

public static final Color4f MAGENTA
An opaque magenta color object.


YELLOW

public static final Color4f YELLOW
An opaque yellor color object.


r

public float r
The components of the color.


g

public float g
The components of the color.


b

public float b
The components of the color.


a

public float a
The components of the color.

Constructor Detail

Color4f

public Color4f(float r,
               float g,
               float b,
               float a)
Creates a color with the supplied components.


Color4f

public Color4f(float[] values)
Creates a color from an array of values.


Color4f

public Color4f(Color4f other)
Copy constructor.


Color4f

public Color4f(Color color)
Creates a color object from an AWT color.


Color4f

public Color4f()
Creates an opaque white color object.

Method Detail

getColor

public Color getColor()
Returns the AWT color object corresponding to this color.


getColor

public Color getColor(boolean includeAlpha)
Returns the AWT color object corresponding to this color.

Parameters:
includeAlpha - if true, include the alpha component (otherwise use an opaque alpha value).

multLocal

public Color4f multLocal(float value)
Multiplies this color in-place by the specified value.

Returns:
a reference to this color, for chaining.

mult

public Color4f mult(float value)
Multiplies this color by the specified value.

Returns:
a new color containing the result.

mult

public Color4f mult(float value,
                    Color4f result)
Multiplies this color by the specified value, placing the result in the object provided.

Returns:
a reference to the result color, for chaining.

multLocal

public Color4f multLocal(Color4f other)
Multiplies this color in-place by another.

Returns:
a reference to this color, for chaining.

mult

public Color4f mult(Color4f other)
Multiplies this color by another.

Returns:
a new color containing the result.

mult

public Color4f mult(Color4f other,
                    Color4f result)
Multiplies this color by another, storing the result in the object provided.

Returns:
a reference to the result object, for chaining.

addLocal

public Color4f addLocal(Color4f other)
Adds a color in-place to this one.

Returns:
a reference to this color, for chaining.

add

public Color4f add(Color4f other)
Adds a color to this one.

Returns:
a new color containing the result.

add

public Color4f add(Color4f other,
                   Color4f result)
Adds a color to this one, storing the result in the object provided.

Returns:
a reference to the result, for chaining.

clampedAddLocal

public Color4f clampedAddLocal(Color4f other)
Adds another color to this one in-place, clamping the elements of the result to one.

Returns:
a reference to this color, for chaining.

clampedAdd

public Color4f clampedAdd(Color4f other)
Adds another color to this one, clamping the elements of the result to one.

Returns:
a new color containing the result.

clampedAdd

public Color4f clampedAdd(Color4f other,
                          Color4f result)
Adds another color to this one, clamping the elements of the result to one, and storing the result in the object provided.

Returns:
a reference to the result, for chaining.

lerpLocal

public Color4f lerpLocal(Color4f other,
                         float t)
Linearly interpolates between this and the specified other color in-place by the supplied amount.

Returns:
a reference to this color, for chaining.

lerp

public Color4f lerp(Color4f other,
                    float t)
Linearly interpolates between this and the specified other color by the supplied amount.

Returns:
a new color containing the result.

lerp

public Color4f lerp(Color4f other,
                    float t,
                    Color4f result)
Linearly interpolates between this and the supplied other color by the supplied amount, storing the result in the supplied object.

Returns:
a reference to the result, for chaining.

set

public Color4f set(Color4f other)
Copies the components of another color.

Returns:
a reference to this color, for chaining.

set

public Color4f set(Color color)
Copies the components of an AWT color.

Returns:
a reference to this color, for chaining.

set

public Color4f set(float[] values)
Copies the elements of an array.

Returns:
a reference to this color, for chaining.

set

public Color4f set(float r,
                   float g,
                   float b,
                   float a)
Sets all the components of this color.

Returns:
a reference to this color, for chaining.

get

public FloatBuffer get(FloatBuffer buf)
Places the components of this color object into the specified buffer.

Returns:
a reference to the buffer, for chaining.

encodeToString

public String encodeToString()
Description copied from interface: Encodable
Returns a string representation of this object.

Specified by:
encodeToString in interface Encodable

decodeFromString

public void decodeFromString(String string)
                      throws Exception
Description copied from interface: Encodable
Initializes this object with the contents of the specified string.

Specified by:
decodeFromString in interface Encodable
Throws:
Exception

encodeToStream

public void encodeToStream(DataOutputStream out)
                    throws IOException
Description copied from interface: Encodable
Encodes this object to the specified stream.

Specified by:
encodeToStream in interface Encodable
Throws:
IOException

decodeFromStream

public void decodeFromStream(DataInputStream in)
                      throws IOException
Description copied from interface: Encodable
Initializes this object with data read from the specified stream.

Specified by:
decodeFromStream in interface Encodable
Throws:
IOException

toString

public String toString()
Overrides:
toString in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object other)
Overrides:
equals in class Object


Copyright © 2011. All Rights Reserved.