|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.openmali.vecmath2.Colord
public class Colord
A simple double-based color implementation with or without alpha channel. Inspired by Kenji Hiranabe's Color3f/Color4f implementation
| 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 |
|---|
protected static final int N
protected final double[] values
protected boolean hasAlpha
protected final int roTrick
protected final boolean[] isDirty
public static final Colord WHITE
public static final Colord LIGHT_GRAY
public static final Colord GRAY10
public static final Colord GRAY20
public static final Colord GRAY25
public static final Colord GRAY30
public static final Colord GRAY40
public static final Colord GRAY50
public static final Colord GRAY60
public static final Colord GRAY70
public static final Colord GRAY75
public static final Colord GRAY80
public static final Colord GRAY90
public static final Colord GRAY
public static final Colord DARK_GRAY
public static final Colord BLACK
public static final Colord BROWN
public static final Colord LIGHT_BROWN
public static final Colord DARK_BROWN
public static final Colord RED
public static final Colord PINK
public static final Colord ORANGE
public static final Colord YELLOW
public static final Colord GREEN
public static final Colord MAGENTA
public static final Colord CYAN
public static final Colord BLUE
| Constructor Detail |
|---|
protected Colord(boolean readOnly,
double r,
double g,
double b,
double a)
readOnly - r - the red element to useg - the green element to useb - the blue element to usea - the alpha channel to use
protected Colord(boolean readOnly,
double r,
double g,
double b)
readOnly - r - the red element to useg - the green element to useb - the blue element to use
protected Colord(boolean readOnly,
double intensity)
readOnly - intensity - the gray intensity (used for all three r,g,b values
protected Colord(boolean readOnly,
double[] values,
boolean[] isDirty,
boolean copy)
readOnly - values - the values array (must be at least size 3)isDirty - copy -
protected Colord(boolean readOnly,
Colord color)
readOnly - color - the Colorf to copy the values fromprotected Colord(boolean readOnly)
readOnly -
protected Colord(boolean readOnly,
java.awt.Color color)
readOnly - color - the Color to copy the values from
public Colord(double r,
double g,
double b,
double a)
r - the red element to useg - the green element to useb - the blue element to usea - the alpha channel to use
public Colord(double r,
double g,
double b)
r - the red element to useg - the green element to useb - the blue element to usepublic Colord(double intensity)
intensity - the gray intensity (used for all three r,g,b valuespublic Colord(double[] values)
values - the values array (must be at least size 3)public Colord(Colord color)
color - the Colorf to copy the values frompublic Colord()
public Colord(java.awt.Color color)
| Method Detail |
|---|
public final boolean isReadOnly()
public final boolean setClean()
public final boolean isDirty()
public static Colord createGray(double intensity)
intensity - the gray's intensity to be applied to all three
components.
public final int getSize()
public final boolean hasAlpha()
public final void set(java.awt.Color color)
color - awt colorpublic final void set(double[] values)
values - the values array (must be at least size 4)public final void setBytes(byte[] values)
values - the values array (must be at least size 4)public final void setInts(int[] values)
values - the values array (must be at least size 4)public final void set(Colord color)
color - the tuple to be copied
public final void set(double r,
double g,
double b,
double a)
r - the red element to useg - the green element to useb - the blue element to usea - the alpha element to use
public final void set(double r,
double g,
double b)
r - the red element to useg - the green element to useb - the blue element to usepublic final java.awt.Color getAWTColor()
public final void get(double[] buffer)
buffer - the buffer array to write the values topublic final void getBytes(byte[] buffer)
buffer - the buffer array to write the values topublic final void getInts(int[] buffer)
buffer - the buffer array to write the values topublic final void get(Colord buffer)
buffer - the buffer vector to write the values to
public final java.nio.DoubleBuffer writeToBuffer(java.nio.DoubleBuffer buffer,
boolean forceAlpha)
buffer - forceAlpha - if true, an alpha value is written to the buffer
regardless of this color having an alpha value of not.public final java.nio.DoubleBuffer writeToBuffer(java.nio.DoubleBuffer buffer)
buffer -
public static final java.nio.DoubleBuffer writeToBuffer(Colord[] colors,
java.nio.DoubleBuffer buffer,
boolean forceAlpha)
colors - buffer - forceAlpha - if true, an alpha value is written to the buffer
regardless of this color having an alpha value of not.
public static final java.nio.DoubleBuffer writeToBuffer(Colord[] colors,
java.nio.DoubleBuffer buffer)
colors - buffer - public final void setRed(double red)
public final double getRed()
public final void r(double red)
public final double r()
public final void setRedByte(byte red)
public final byte getRedByte()
public final void setRedInt(int red)
public final int getRedInt()
public final void setGreen(double green)
public final double getGreen()
public final void g(double green)
public final double g()
public final void setGreenByte(byte green)
public final byte getGreenByte()
public final void setGreenInt(int green)
public final int getGreenInt()
public final void setBlue(double blue)
public final double getBlue()
public final void b(double blue)
public final double b()
public final void setBlueByte(byte blue)
public final byte getBlueByte()
public final void setBlueInt(int blue)
public final int getBlueInt()
public final void setAlpha(double alpha)
alpha - public final double getAlpha()
public final void a(double alpha)
alpha - public final double a()
public final void setAlphaByte(byte alpha)
public final byte getAlphaByte()
public final void setAlphaInt(int alpha)
public final int getAlphaInt()
public final Colord setZero()
public final Colord addRed(double v)
v -
public final Colord addGreen(double v)
v -
public final Colord addBlue(double v)
v -
public final Colord addAlpha(double v)
v -
public final Colord subRed(double v)
v -
public final Colord subGreen(double v)
v -
public final Colord subBlue(double v)
v -
public final Colord subAlpha(double v)
v -
public final Colord mulRed(double v)
v -
public final Colord mulGreen(double v)
v -
public final Colord mulBlue(double v)
v -
public final Colord mulAlpha(double v)
v -
public final Colord mul(double vr,
double vg,
double vb,
double va)
vr - vg - vb - va -
public final Colord mul(double vr,
double vg,
double vb)
vr - vg - vb -
public final Colord mul(double factor)
factor - the scalar value
public final Colord divRed(double v)
v -
public final Colord divGreen(double v)
v -
public final Colord divBlue(double v)
v -
public final Colord divAlpha(double v)
v -
public final Colord div(double vr,
double vg,
double vb,
double va)
vr - vg - vb - va -
public final Colord div(double vr,
double vg,
double vb)
vr - vg - vb -
public final Colord add(Colord color1,
Colord color2)
color1 - the first colorcolor2 - the second color
public final Colord add(Colord color2)
color2 - the other tuple
public final Colord add(double r,
double g,
double b,
double a)
r - g - b - a -
public final Colord add(double r,
double g,
double b)
r - g - b -
public final Colord sub(Colord color1,
Colord color2)
color1 - the first colorcolor2 - the second color
public final Colord sub(Colord color2)
color2 - the other color
public final Colord sub(double r,
double g,
double b,
double a)
r - g - b - a -
public final Colord sub(double r,
double g,
double b)
r - g - b -
public final Colord clampMin(double min)
min - the lowest value in this tuple after clamping
public final Colord clampMax(double max)
max - the highest value in the tuple after clamping
public final Colord clamp(double min,
double max)
min - the lowest value in this tuple after clampingmax - the highest value in this tuple after clamping
public final Colord clamp(double min,
double max,
Colord vec)
min - the lowest value in the tuple after clampingmax - the highest value in the tuple after clampingvec - the source tuple, which will not be modified
public final Colord clampMin(double min,
Colord vec)
min - the lowest value in the tuple after clampingvec - the source tuple, which will not be modified
public final Colord clampMax(double max,
Colord vec)
max - the highest value in the tuple after clampingvec - the source tuple, which will not be modified
public final Colord interpolate(Colord color2,
double val)
color2 - the first tupleval - the alpha interpolation parameter
public final Colord interpolate(Colord color1,
Colord color2,
double val)
color1 - the first tuplecolor2 - the second tupleval - the interpolation parameter
public Colord asReadOnly()
getReadOnly()public Colord getReadOnly()
asReadOnly()public int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(Colord color2)
color2 - the color with which the comparison is made.public boolean equals(java.lang.Object o)
equals in class java.lang.Objecto - the Object with which the comparison is made
public boolean epsilonEquals(Colord color2,
double epsilon)
color2 - the color to be compared to this colorepsilon - the threshold valuepublic final java.lang.String toHexString()
public java.lang.String toString()
toString in class java.lang.Objectpublic Colord clone()
clone in class java.lang.Objectjava.lang.OutOfMemoryError - if there is not enough memory.Cloneable
public int serialize(int pos,
byte[] buffer)
pos - buffer -
public int deserialize(int pos,
byte[] buffer)
pos - buffer -
public void writeExternal(java.io.ObjectOutput out)
throws java.io.IOException
writeExternal in interface java.io.Externalizablejava.io.IOException
public void readExternal(java.io.ObjectInput in)
throws java.io.IOException,
java.lang.ClassNotFoundException
readExternal in interface java.io.Externalizablejava.io.IOException
java.lang.ClassNotFoundException
public static Colord parseColor(java.lang.String hexString,
Colord buffer)
hexString - buffer -
public static Colord parseColor(java.lang.String hexString)
hexString -
public static Colord parseReadOnlyColor(java.lang.String hexString)
hexString -
public static Colord fromPool()
public static Colord fromPool(double r,
double g,
double b,
double a)
public static Colord fromPool(double r,
double g,
double b)
public static Colord fromPool(Colord color)
public static void toPool(Colord o)
o -
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||