org.openmali.vecmath2
Class Colord

java.lang.Object
  extended by org.openmali.vecmath2.Colord
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable

public class Colord
extends java.lang.Object
implements java.io.Externalizable

A simple double-based color implementation with or without alpha channel. Inspired by Kenji Hiranabe's Color3f/Color4f implementation

See Also:
Serialized Form

Field Summary
static Colord BLACK
          The color black.
static Colord BLUE
          The color blue.
static Colord BROWN
          The color brown.
static Colord CYAN
          The color cyan.
static Colord DARK_BROWN
          The color brown.
static Colord DARK_GRAY
          The color dark gray.
static Colord GRAY
          The color gray.
static Colord GRAY10
          A 10% gray.
static Colord GRAY20
          A 20% gray.
static Colord GRAY25
          A 25% gray.
static Colord GRAY30
          A 30% gray.
static Colord GRAY40
          A 40% gray.
static Colord GRAY50
          A 50% gray.
static Colord GRAY60
          A 60% gray.
static Colord GRAY70
          A 70% gray.
static Colord GRAY75
          A 75% gray.
static Colord GRAY80
          A 80% gray.
static Colord GRAY90
          A 90% gray.
static Colord GREEN
          The color green.
protected  boolean hasAlpha
           
protected  boolean[] isDirty
           
static Colord LIGHT_BROWN
          The color brown.
static Colord LIGHT_GRAY
          The color light gray.
static Colord MAGENTA
          The color magenta.
protected static int N
           
static Colord ORANGE
          The color orange.
static Colord PINK
          The color pink.
static Colord RED
          The color red.
protected  int roTrick
           
protected  double[] values
           
static Colord WHITE
          The color white.
static Colord YELLOW
          The color yellow.
 
Constructor Summary
  Colord()
          Creates a new Colorf instance.
protected Colord(boolean readOnly)
          Creates a new Colorf instance.
protected Colord(boolean readOnly, java.awt.Color color)
          Creates a new Colorf instance.
protected Colord(boolean readOnly, Colord color)
          Creates a new Colorf instance.
protected Colord(boolean readOnly, double intensity)
          Creates a new Colorf instance.
protected Colord(boolean readOnly, double[] values, boolean[] isDirty, boolean copy)
          Creates a new Colorf instance.
protected Colord(boolean readOnly, double r, double g, double b)
          Creates a new Colorf instance.
protected Colord(boolean readOnly, double r, double g, double b, double a)
          Creates a new Colorf instance.
  Colord(java.awt.Color color)
           
  Colord(Colord color)
          Creates a new Colorf instance.
  Colord(double intensity)
          Creates a new Colorf instance.
  Colord(double[] values)
          Creates a new Colorf instance.
  Colord(double r, double g, double b)
          Creates a new Colorf instance.
  Colord(double r, double g, double b, double a)
          Creates a new Colorf instance.
 
Method Summary
 double a()
           
 void a(double alpha)
          Sets the value of the alpha-element of this color.
 Colord add(Colord color2)
          Sets the value of this tuple to the vector sum of itself and tuple t1.
 Colord add(Colord color1, Colord color2)
          Sets the value of this color to the vector sum of colors color1 and color2.
 Colord add(double r, double g, double b)
          Adds the given parameters to this tuple's values.
 Colord add(double r, double g, double b, double a)
          Adds the given parameters to this tuple's values.
 Colord addAlpha(double v)
          Adds v to this color's alpha value.
 Colord addBlue(double v)
          Adds v to this color's blue value.
 Colord addGreen(double v)
          Adds v to this color's green value.
 Colord addRed(double v)
          Adds v to this color's red value.
 Colord asReadOnly()
           
 double b()
           
 void b(double blue)
          Sets the Blue color component.
 Colord clamp(double min, double max)
          Clamps this tuple to the range [min, max].
 Colord clamp(double min, double max, Colord vec)
          Clamps the tuple parameter to the range [min, max] and places the values into this tuple.
 Colord clampMax(double max)
          Clamps the maximum value of this tuple to the max parameter.
 Colord clampMax(double max, Colord vec)
          Clamps the maximum value of the tuple parameter to the max parameter and places the values into this tuple.
 Colord clampMin(double min)
          Clamps the minimum value of this tuple to the min parameter.
 Colord clampMin(double min, Colord vec)
          Clamps the minimum value of the tuple parameter to the min parameter and places the values into this tuple.
 Colord clone()
          Creates and returns a copy of this object.
static Colord createGray(double intensity)
          Creates a gray of the given intensity.
 int deserialize(int pos, byte[] buffer)
          Deserializes this instanc'es data from the byte array.
 Colord div(double vr, double vg, double vb)
          Divides this color's values by vr, vg, vb.
 Colord div(double vr, double vg, double vb, double va)
          Divides this color's values by vr, vg, vb, va.
 Colord divAlpha(double v)
          Divides this color's alpha value by v.
 Colord divBlue(double v)
          Divides this color's blue value by v.
 Colord divGreen(double v)
          Divides this color's green value by v.
 Colord divRed(double v)
          Divides this color's red value by v.
 boolean epsilonEquals(Colord color2, double epsilon)
          Returns true if the L-infinite distance between this tuple and tuple t1 is less than or equal to the epsilon parameter, otherwise returns false.
 boolean equals(Colord color2)
          Returns true if all of the data members of Tuple3f t1 are equal to the corresponding data members in this
 boolean equals(java.lang.Object o)
          Returns true if the Object t1 is of type Tuple3f and all of the data members of t1 are equal to the corresponding data members in this Tuple3f.
static Colord fromPool()
          Allocates an Colorf instance from the pool.
static Colord fromPool(Colord color)
          Allocates an Colorf instance from the pool.
static Colord fromPool(double r, double g, double b)
          Allocates an Colorf instance from the pool.
static Colord fromPool(double r, double g, double b, double a)
          Allocates an Colorf instance from the pool.
 double g()
           
 void g(double green)
          Sets the Green color component.
 void get(Colord buffer)
          Writes all values of this vector to the specified buffer vector.
 void get(double[] buffer)
          Writes all values of this Tuple to the specified buffer.
 double getAlpha()
           
 byte getAlphaByte()
           
 int getAlphaInt()
           
 java.awt.Color getAWTColor()
          Gets java.awt.Color.
 double getBlue()
           
 byte getBlueByte()
           
 int getBlueInt()
           
 void getBytes(byte[] buffer)
          Writes all values of this Tuple to the specified buffer.
 double getGreen()
           
 byte getGreenByte()
           
 int getGreenInt()
           
 void getInts(int[] buffer)
          Writes all values of this Tuple to the specified buffer.
 Colord getReadOnly()
           
 double getRed()
           
 byte getRedByte()
           
 int getRedInt()
           
 int getSize()
           
 boolean hasAlpha()
           
 int hashCode()
          Returns a hash number based on the data values in this object.
 Colord interpolate(Colord color1, Colord color2, double val)
          Linearly interpolates between tuples t1 and t2 and places the result into this tuple: this = (1 - alpha) * t1 + alpha * t2.
 Colord interpolate(Colord color2, double val)
          Linearly interpolates between this tuple and tuple t2 and places the result into this tuple: this = (1 - alpha) * this + alpha * t1.
 boolean isDirty()
           
 boolean isReadOnly()
           
 Colord mul(double factor)
          Sets the value of this tuple to the scalar multiplication of itself.
 Colord mul(double vr, double vg, double vb)
          Multiplies this color's values with vr, vg, vb.
 Colord mul(double vr, double vg, double vb, double va)
          Multiplies this color's values with vr, vg, vb, va.
 Colord mulAlpha(double v)
          Multiplies this color's alpha value with v.
 Colord mulBlue(double v)
          Multiplies this color's blue value with v.
 Colord mulGreen(double v)
          Multiplies this color's green value with v.
 Colord mulRed(double v)
          Multiplies this color's red value with v.
static Colord parseColor(java.lang.String hexString)
          Parses a color-hex-String into a new Colord instance.
static Colord parseColor(java.lang.String hexString, Colord buffer)
          Parses a color-hex-String into a Colord instance.
static Colord parseReadOnlyColor(java.lang.String hexString)
          Parses a color-hex-String into a new Colord instance.
 double r()
           
 void r(double red)
          Sets the Red color component.
 void readExternal(java.io.ObjectInput in)
           
 int serialize(int pos, byte[] buffer)
          Serializes this instanc'es data into the byte array.
 void set(java.awt.Color color)
          Sets color from awt.Color.
 void set(Colord color)
          Sets all three values of this Tuple to the specified ones.
 void set(double[] values)
          Sets all values of this Tuple to the specified ones.
 void set(double r, double g, double b)
          Sets all values of this color to the specified ones.
 void set(double r, double g, double b, double a)
          Sets all values of this color to the specified ones.
 void setAlpha(double alpha)
          Sets the value of the alpha-element of this color.
 void setAlphaByte(byte alpha)
          Sets the Alpha value component.
 void setAlphaInt(int alpha)
          Sets the Alpha value component.
 void setBlue(double blue)
          Sets the Blue color component.
 void setBlueByte(byte blue)
          Sets the Blue color component.
 void setBlueInt(int blue)
          Sets the Blue color component.
 void setBytes(byte[] values)
          Sets all values of this Tuple to the specified ones.
 boolean setClean()
          Marks this tuple non-dirty.
 void setGreen(double green)
          Sets the Green color component.
 void setGreenByte(byte green)
          Sets the Green color component.
 void setGreenInt(int green)
          Sets the Green color component.
 void setInts(int[] values)
          Sets all values of this Tuple to the specified ones.
 void setRed(double red)
          Sets the Red color component.
 void setRedByte(byte red)
          Sets the Red color component.
 void setRedInt(int red)
          Sets the Red color component.
 Colord setZero()
          Sets all components to zero.
 Colord sub(Colord color2)
          Sets the value of this color to the vector difference of itself and color2 (this = this - color2).
 Colord sub(Colord color1, Colord color2)
          Sets the value of this color to the vector difference of color color1 and color2 (this = color1 - color2).
 Colord sub(double r, double g, double b)
          Subtracts the given parameters from this tuple's values.
 Colord sub(double r, double g, double b, double a)
          Subtracts the given parameters from this tuple's values.
 Colord subAlpha(double v)
          Subtracts v from this color's alpha value.
 Colord subBlue(double v)
          Subtracts v from this color's blue value.
 Colord subGreen(double v)
          Subtracts v from this color's green value.
 Colord subRed(double v)
          Subtracts v from this color's red value.
 java.lang.String toHexString()
           
static void toPool(Colord o)
          Stores the given Colorf instance in the pool.
 java.lang.String toString()
          Returns a string that contains the values of this Colorf.
 void writeExternal(java.io.ObjectOutput out)
           
static java.nio.DoubleBuffer writeToBuffer(Colord[] colors, java.nio.DoubleBuffer buffer)
          Writes the contents of the colors to a doubleBuffer.
static java.nio.DoubleBuffer writeToBuffer(Colord[] colors, java.nio.DoubleBuffer buffer, boolean forceAlpha)
          Writes the contents of this tuple to a doubleBuffer.
 java.nio.DoubleBuffer writeToBuffer(java.nio.DoubleBuffer buffer)
          Writes the contents of this tuple to a doubleBuffer.
 java.nio.DoubleBuffer writeToBuffer(java.nio.DoubleBuffer buffer, boolean forceAlpha)
          Writes the contents of this tuple to a doubleBuffer.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

N

protected static final int N
See Also:
Constant Field Values

values

protected final double[] values

hasAlpha

protected boolean hasAlpha

roTrick

protected final int roTrick

isDirty

protected final boolean[] isDirty

WHITE

public static final Colord WHITE
The color white. In the default sRGB space.


LIGHT_GRAY

public static final Colord LIGHT_GRAY
The color light gray. In the default sRGB space.


GRAY10

public static final Colord GRAY10
A 10% gray. In the default sRGB space.


GRAY20

public static final Colord GRAY20
A 20% gray. In the default sRGB space.


GRAY25

public static final Colord GRAY25
A 25% gray. In the default sRGB space.


GRAY30

public static final Colord GRAY30
A 30% gray. In the default sRGB space.


GRAY40

public static final Colord GRAY40
A 40% gray. In the default sRGB space.


GRAY50

public static final Colord GRAY50
A 50% gray. In the default sRGB space.


GRAY60

public static final Colord GRAY60
A 60% gray. In the default sRGB space.


GRAY70

public static final Colord GRAY70
A 70% gray. In the default sRGB space.


GRAY75

public static final Colord GRAY75
A 75% gray. In the default sRGB space.


GRAY80

public static final Colord GRAY80
A 80% gray. In the default sRGB space.


GRAY90

public static final Colord GRAY90
A 90% gray. In the default sRGB space.


GRAY

public static final Colord GRAY
The color gray. In the default sRGB space.


DARK_GRAY

public static final Colord DARK_GRAY
The color dark gray. In the default sRGB space.


BLACK

public static final Colord BLACK
The color black. In the default sRGB space.


BROWN

public static final Colord BROWN
The color brown. In the default sRGB space.


LIGHT_BROWN

public static final Colord LIGHT_BROWN
The color brown. In the default sRGB space.


DARK_BROWN

public static final Colord DARK_BROWN
The color brown. In the default sRGB space.


RED

public static final Colord RED
The color red. In the default sRGB space.


PINK

public static final Colord PINK
The color pink. In the default sRGB space.


ORANGE

public static final Colord ORANGE
The color orange. In the default sRGB space.


YELLOW

public static final Colord YELLOW
The color yellow. In the default sRGB space.


GREEN

public static final Colord GREEN
The color green. In the default sRGB space.


MAGENTA

public static final Colord MAGENTA
The color magenta. In the default sRGB space.


CYAN

public static final Colord CYAN
The color cyan. In the default sRGB space.


BLUE

public static final Colord BLUE
The color blue. In the default sRGB space.

Constructor Detail

Colord

protected Colord(boolean readOnly,
                 double r,
                 double g,
                 double b,
                 double a)
Creates a new Colorf instance.

Parameters:
readOnly -
r - the red element to use
g - the green element to use
b - the blue element to use
a - the alpha channel to use

Colord

protected Colord(boolean readOnly,
                 double r,
                 double g,
                 double b)
Creates a new Colorf instance.

Parameters:
readOnly -
r - the red element to use
g - the green element to use
b - the blue element to use

Colord

protected Colord(boolean readOnly,
                 double intensity)
Creates a new Colorf instance.

Parameters:
readOnly -
intensity - the gray intensity (used for all three r,g,b values

Colord

protected Colord(boolean readOnly,
                 double[] values,
                 boolean[] isDirty,
                 boolean copy)
Creates a new Colorf instance.

Parameters:
readOnly -
values - the values array (must be at least size 3)
isDirty -
copy -

Colord

protected Colord(boolean readOnly,
                 Colord color)
Creates a new Colorf instance.

Parameters:
readOnly -
color - the Colorf to copy the values from

Colord

protected Colord(boolean readOnly)
Creates a new Colorf instance.

Parameters:
readOnly -

Colord

protected Colord(boolean readOnly,
                 java.awt.Color color)
Creates a new Colorf instance.

Parameters:
readOnly -
color - the Color to copy the values from

Colord

public Colord(double r,
              double g,
              double b,
              double a)
Creates a new Colorf instance.

Parameters:
r - the red element to use
g - the green element to use
b - the blue element to use
a - the alpha channel to use

Colord

public Colord(double r,
              double g,
              double b)
Creates a new Colorf instance.

Parameters:
r - the red element to use
g - the green element to use
b - the blue element to use

Colord

public Colord(double intensity)
Creates a new Colorf instance.

Parameters:
intensity - the gray intensity (used for all three r,g,b values

Colord

public Colord(double[] values)
Creates a new Colorf instance.

Parameters:
values - the values array (must be at least size 3)

Colord

public Colord(Colord color)
Creates a new Colorf instance.

Parameters:
color - the Colorf to copy the values from

Colord

public Colord()
Creates a new Colorf instance.


Colord

public Colord(java.awt.Color color)
Method Detail

isReadOnly

public final boolean isReadOnly()
Returns:
Is this tuple a read-only one?

setClean

public final boolean setClean()
Marks this tuple non-dirty. Any value-manipulation will mark it dirty again.

Returns:
the old value

isDirty

public final boolean isDirty()
Returns:
This tuple's dirty-flag

createGray

public static Colord createGray(double intensity)
Creates a gray of the given intensity.
This is euqal to new Color3f(intensity, intensity, intensity);

Parameters:
intensity - the gray's intensity to be applied to all three components.
Returns:
the new gray color

getSize

public final int getSize()
Returns:
this Vector's size().

hasAlpha

public final boolean hasAlpha()
Returns:
if this Colorf has an alpha channel.

set

public final void set(java.awt.Color color)
Sets color from awt.Color.

Parameters:
color - awt color

set

public final void set(double[] values)
Sets all values of this Tuple to the specified ones.

Parameters:
values - the values array (must be at least size 4)

setBytes

public final void setBytes(byte[] values)
Sets all values of this Tuple to the specified ones.

Parameters:
values - the values array (must be at least size 4)

setInts

public final void setInts(int[] values)
Sets all values of this Tuple to the specified ones.

Parameters:
values - the values array (must be at least size 4)

set

public final void set(Colord color)
Sets all three values of this Tuple to the specified ones.

Parameters:
color - the tuple to be copied

set

public final void set(double r,
                      double g,
                      double b,
                      double a)
Sets all values of this color to the specified ones.

Parameters:
r - the red element to use
g - the green element to use
b - the blue element to use
a - the alpha element to use

set

public final void set(double r,
                      double g,
                      double b)
Sets all values of this color to the specified ones.

Parameters:
r - the red element to use
g - the green element to use
b - the blue element to use

getAWTColor

public final java.awt.Color getAWTColor()
Gets java.awt.Color.

Returns:
AWT color

get

public final void get(double[] buffer)
Writes all values of this Tuple to the specified buffer.

Parameters:
buffer - the buffer array to write the values to

getBytes

public final void getBytes(byte[] buffer)
Writes all values of this Tuple to the specified buffer.

Parameters:
buffer - the buffer array to write the values to

getInts

public final void getInts(int[] buffer)
Writes all values of this Tuple to the specified buffer.

Parameters:
buffer - the buffer array to write the values to

get

public final void get(Colord buffer)
Writes all values of this vector to the specified buffer vector.

Parameters:
buffer - the buffer vector to write the values to

writeToBuffer

public final java.nio.DoubleBuffer writeToBuffer(java.nio.DoubleBuffer buffer,
                                                 boolean forceAlpha)
Writes the contents of this tuple to a doubleBuffer.
The buffer is automatically cleared (before) and flipped (after).

Parameters:
buffer -
forceAlpha - if true, an alpha value is written to the buffer regardless of this color having an alpha value of not.

writeToBuffer

public final java.nio.DoubleBuffer writeToBuffer(java.nio.DoubleBuffer buffer)
Writes the contents of this tuple to a doubleBuffer.
The buffer is automatically cleared (before) and flipped (after).

Parameters:
buffer -

writeToBuffer

public static final java.nio.DoubleBuffer writeToBuffer(Colord[] colors,
                                                        java.nio.DoubleBuffer buffer,
                                                        boolean forceAlpha)
Writes the contents of this tuple to a doubleBuffer.
The buffer is automatically cleared (before) and flipped (after).

Parameters:
colors -
buffer -
forceAlpha - if true, an alpha value is written to the buffer regardless of this color having an alpha value of not.

writeToBuffer

public static final java.nio.DoubleBuffer writeToBuffer(Colord[] colors,
                                                        java.nio.DoubleBuffer buffer)
Writes the contents of the colors to a doubleBuffer.
The buffer is automatically cleared (before) and flipped (after).

Parameters:
colors -
buffer -

setRed

public final void setRed(double red)
Sets the Red color component.


getRed

public final double getRed()
Returns:
the Red color component.

r

public final void r(double red)
Sets the Red color component.


r

public final double r()
Returns:
the Red color component.

setRedByte

public final void setRedByte(byte red)
Sets the Red color component.


getRedByte

public final byte getRedByte()
Returns:
the Red color component.

setRedInt

public final void setRedInt(int red)
Sets the Red color component.


getRedInt

public final int getRedInt()
Returns:
the Red color component.

setGreen

public final void setGreen(double green)
Sets the Green color component.


getGreen

public final double getGreen()
Returns:
the Green color component.

g

public final void g(double green)
Sets the Green color component.


g

public final double g()
Returns:
the Green color component.

setGreenByte

public final void setGreenByte(byte green)
Sets the Green color component.


getGreenByte

public final byte getGreenByte()
Returns:
the Green color component.

setGreenInt

public final void setGreenInt(int green)
Sets the Green color component.


getGreenInt

public final int getGreenInt()
Returns:
the Green color component.

setBlue

public final void setBlue(double blue)
Sets the Blue color component.


getBlue

public final double getBlue()
Returns:
the Blue color component.

b

public final void b(double blue)
Sets the Blue color component.


b

public final double b()
Returns:
the Blue color component.

setBlueByte

public final void setBlueByte(byte blue)
Sets the Blue color component.


getBlueByte

public final byte getBlueByte()
Returns:
the Blue color component.

setBlueInt

public final void setBlueInt(int blue)
Sets the Blue color component.


getBlueInt

public final int getBlueInt()
Returns:
the Blue color component.

setAlpha

public final void setAlpha(double alpha)
Sets the value of the alpha-element of this color.

Parameters:
alpha -

getAlpha

public final double getAlpha()
Returns:
the value of the alpha-element of this color.

a

public final void a(double alpha)
Sets the value of the alpha-element of this color.

Parameters:
alpha -

a

public final double a()
Returns:
the value of the alpha-element of this color.

setAlphaByte

public final void setAlphaByte(byte alpha)
Sets the Alpha value component.


getAlphaByte

public final byte getAlphaByte()
Returns:
the Alhpa value component.

setAlphaInt

public final void setAlphaInt(int alpha)
Sets the Alpha value component.


getAlphaInt

public final int getAlphaInt()
Returns:
the Alhpa value component.

setZero

public final Colord setZero()
Sets all components to zero.

Returns:
itself

addRed

public final Colord addRed(double v)
Adds v to this color's red value.

Parameters:
v -
Returns:
itself

addGreen

public final Colord addGreen(double v)
Adds v to this color's green value.

Parameters:
v -
Returns:
itself

addBlue

public final Colord addBlue(double v)
Adds v to this color's blue value.

Parameters:
v -
Returns:
itself

addAlpha

public final Colord addAlpha(double v)
Adds v to this color's alpha value.

Parameters:
v -
Returns:
itself

subRed

public final Colord subRed(double v)
Subtracts v from this color's red value.

Parameters:
v -
Returns:
itself

subGreen

public final Colord subGreen(double v)
Subtracts v from this color's green value.

Parameters:
v -
Returns:
itself

subBlue

public final Colord subBlue(double v)
Subtracts v from this color's blue value.

Parameters:
v -
Returns:
itself

subAlpha

public final Colord subAlpha(double v)
Subtracts v from this color's alpha value.

Parameters:
v -
Returns:
itself

mulRed

public final Colord mulRed(double v)
Multiplies this color's red value with v.

Parameters:
v -
Returns:
itself

mulGreen

public final Colord mulGreen(double v)
Multiplies this color's green value with v.

Parameters:
v -
Returns:
itself

mulBlue

public final Colord mulBlue(double v)
Multiplies this color's blue value with v.

Parameters:
v -
Returns:
itself

mulAlpha

public final Colord mulAlpha(double v)
Multiplies this color's alpha value with v.

Parameters:
v -
Returns:
itself

mul

public final Colord mul(double vr,
                        double vg,
                        double vb,
                        double va)
Multiplies this color's values with vr, vg, vb, va.

Parameters:
vr -
vg -
vb -
va -
Returns:
itself

mul

public final Colord mul(double vr,
                        double vg,
                        double vb)
Multiplies this color's values with vr, vg, vb.

Parameters:
vr -
vg -
vb -
Returns:
itself

mul

public final Colord mul(double factor)
Sets the value of this tuple to the scalar multiplication of itself.

Parameters:
factor - the scalar value
Returns:
itself

divRed

public final Colord divRed(double v)
Divides this color's red value by v.

Parameters:
v -
Returns:
itself

divGreen

public final Colord divGreen(double v)
Divides this color's green value by v.

Parameters:
v -
Returns:
itself

divBlue

public final Colord divBlue(double v)
Divides this color's blue value by v.

Parameters:
v -
Returns:
itself

divAlpha

public final Colord divAlpha(double v)
Divides this color's alpha value by v.

Parameters:
v -
Returns:
itself

div

public final Colord div(double vr,
                        double vg,
                        double vb,
                        double va)
Divides this color's values by vr, vg, vb, va.

Parameters:
vr -
vg -
vb -
va -
Returns:
itself

div

public final Colord div(double vr,
                        double vg,
                        double vb)
Divides this color's values by vr, vg, vb.

Parameters:
vr -
vg -
vb -
Returns:
itself

add

public final Colord add(Colord color1,
                        Colord color2)
Sets the value of this color to the vector sum of colors color1 and color2.

Parameters:
color1 - the first color
color2 - the second color
Returns:
itself

add

public final Colord add(Colord color2)
Sets the value of this tuple to the vector sum of itself and tuple t1.

Parameters:
color2 - the other tuple
Returns:
itself

add

public final Colord add(double r,
                        double g,
                        double b,
                        double a)
Adds the given parameters to this tuple's values.

Parameters:
r -
g -
b -
a -
Returns:
itself

add

public final Colord add(double r,
                        double g,
                        double b)
Adds the given parameters to this tuple's values.

Parameters:
r -
g -
b -
Returns:
itself

sub

public final Colord sub(Colord color1,
                        Colord color2)
Sets the value of this color to the vector difference of color color1 and color2 (this = color1 - color2).

Parameters:
color1 - the first color
color2 - the second color
Returns:
itself

sub

public final Colord sub(Colord color2)
Sets the value of this color to the vector difference of itself and color2 (this = this - color2).

Parameters:
color2 - the other color
Returns:
itself

sub

public final Colord sub(double r,
                        double g,
                        double b,
                        double a)
Subtracts the given parameters from this tuple's values.

Parameters:
r -
g -
b -
a -
Returns:
itself

sub

public final Colord sub(double r,
                        double g,
                        double b)
Subtracts the given parameters from this tuple's values.

Parameters:
r -
g -
b -
Returns:
itself

clampMin

public final Colord clampMin(double min)
Clamps the minimum value of this tuple to the min parameter.

Parameters:
min - the lowest value in this tuple after clamping
Returns:
itself

clampMax

public final Colord clampMax(double max)
Clamps the maximum value of this tuple to the max parameter.

Parameters:
max - the highest value in the tuple after clamping
Returns:
itself

clamp

public final Colord clamp(double min,
                          double max)
Clamps this tuple to the range [min, max].

Parameters:
min - the lowest value in this tuple after clamping
max - the highest value in this tuple after clamping
Returns:
itself

clamp

public final Colord clamp(double min,
                          double max,
                          Colord vec)
Clamps the tuple parameter to the range [min, max] and places the values into this tuple.

Parameters:
min - the lowest value in the tuple after clamping
max - the highest value in the tuple after clamping
vec - the source tuple, which will not be modified
Returns:
itself

clampMin

public final Colord clampMin(double min,
                             Colord vec)
Clamps the minimum value of the tuple parameter to the min parameter and places the values into this tuple.

Parameters:
min - the lowest value in the tuple after clamping
vec - the source tuple, which will not be modified
Returns:
itself

clampMax

public final Colord clampMax(double max,
                             Colord vec)
Clamps the maximum value of the tuple parameter to the max parameter and places the values into this tuple.

Parameters:
max - the highest value in the tuple after clamping
vec - the source tuple, which will not be modified
Returns:
itself

interpolate

public final Colord interpolate(Colord color2,
                                double val)
Linearly interpolates between this tuple and tuple t2 and places the result into this tuple: this = (1 - alpha) * this + alpha * t1.

Parameters:
color2 - the first tuple
val - the alpha interpolation parameter
Returns:
itself

interpolate

public final Colord interpolate(Colord color1,
                                Colord color2,
                                double val)
Linearly interpolates between tuples t1 and t2 and places the result into this tuple: this = (1 - alpha) * t1 + alpha * t2.

Parameters:
color1 - the first tuple
color2 - the second tuple
val - the interpolation parameter
Returns:
itself

asReadOnly

public Colord asReadOnly()
Returns:
a new instance sharing the values array with this instance. The new instance is read-only. Changes to this instance will be reflected in the new read-only-instance.
See Also:
getReadOnly()

getReadOnly

public Colord getReadOnly()
Returns:
a single instance sharing the values array with this instance (one unique instance per 'master-instance'). The instance is read-only. Changes to this instance will be reflected in the read-only-instance.
See Also:
asReadOnly()

hashCode

public int hashCode()
Returns a hash number based on the data values in this object. Two different Tuple3f objects with identical data values (ie, returns true for equals(Tuple3f) ) will return the same hash number. Two vectors with different data members may return the same hash value, although this is not likely.

Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(Colord color2)
Returns true if all of the data members of Tuple3f t1 are equal to the corresponding data members in this

Parameters:
color2 - the color with which the comparison is made.

equals

public boolean equals(java.lang.Object o)
Returns true if the Object t1 is of type Tuple3f and all of the data members of t1 are equal to the corresponding data members in this Tuple3f.

Overrides:
equals in class java.lang.Object
Parameters:
o - the Object with which the comparison is made
Returns:
true or false

epsilonEquals

public boolean epsilonEquals(Colord color2,
                             double epsilon)
Returns true if the L-infinite distance between this tuple and tuple t1 is less than or equal to the epsilon parameter, otherwise returns false. The L-infinite distance is equal to MAX[abs(x1-x2), abs(y1-y2)].

Parameters:
color2 - the color to be compared to this color
epsilon - the threshold value

toHexString

public final java.lang.String toHexString()
Returns:
a hex-String represending the RGB-values of this color.

toString

public java.lang.String toString()
Returns a string that contains the values of this Colorf. The form is ( red = f, green = f, blue = f, alpha = f ).

Overrides:
toString in class java.lang.Object
Returns:
the String representation

clone

public Colord clone()
Creates and returns a copy of this object.

Overrides:
clone in class java.lang.Object
Returns:
a clone of this instance.
Throws:
java.lang.OutOfMemoryError - if there is not enough memory.
See Also:
Cloneable

serialize

public int serialize(int pos,
                     byte[] buffer)
Serializes this instanc'es data into the byte array.

Parameters:
pos -
buffer -
Returns:
the incremented position

deserialize

public int deserialize(int pos,
                       byte[] buffer)
Deserializes this instanc'es data from the byte array.

Parameters:
pos -
buffer -
Returns:
the incremented position

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Specified by:
writeExternal in interface java.io.Externalizable
Throws:
java.io.IOException

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Specified by:
readExternal in interface java.io.Externalizable
Throws:
java.io.IOException
java.lang.ClassNotFoundException

parseColor

public static Colord parseColor(java.lang.String hexString,
                                Colord buffer)
Parses a color-hex-String into a Colord instance.
The color must be of the form "#RRGGBB" or "RRGGBB" or "#RRGGBBAA" or "RRGGBBAA", where the letters must be hex chars.

Parameters:
hexString -
buffer -
Returns:
the color back again

parseColor

public static Colord parseColor(java.lang.String hexString)
Parses a color-hex-String into a new Colord instance.
The color must be of the form "#RRGGBB" or "RRGGBB" or "#RRGGBBAA" or "RRGGBBAA", where the letters must be hex chars.

Parameters:
hexString -
Returns:
the new Colorf instance

parseReadOnlyColor

public static Colord parseReadOnlyColor(java.lang.String hexString)
Parses a color-hex-String into a new Colord instance.
The color must be of the form "#RRGGBB" or "RRGGBB" or "#RRGGBBAA" or "RRGGBBAA", where the letters must be hex chars.

Parameters:
hexString -
Returns:
the new Colord instance

fromPool

public static Colord fromPool()
Allocates an Colorf instance from the pool.


fromPool

public static Colord fromPool(double r,
                              double g,
                              double b,
                              double a)
Allocates an Colorf instance from the pool.


fromPool

public static Colord fromPool(double r,
                              double g,
                              double b)
Allocates an Colorf instance from the pool.


fromPool

public static Colord fromPool(Colord color)
Allocates an Colorf instance from the pool.


toPool

public static void toPool(Colord o)
Stores the given Colorf instance in the pool.

Parameters:
o -