|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.jme.renderer.ColorRGBA
public class ColorRGBA
ColorRGBA
defines a color made from a collection of
red, green and blue values. An alpha value determines is transparency.
All values must be between 0 and 1. If any value is set higher or lower
than these constraints they are clamped to the min or max. That is, if
a value smaller than zero is set the value clamps to zero. If a value
higher than 1 is passed, that value is clamped to 1. However, because the
attributes r, g, b, a are public for efficiency reasons, they can be
directly modified with invalid values. The client should take care when
directly addressing the values. A call to clamp will assure that the values
are within the constraints.
Field Summary | |
---|---|
float |
a
the alpha component of the color. |
float |
b
the blue component of the color. |
static ColorRGBA |
black
the color black (0,0,0). |
static ColorRGBA |
blue
the color blue (0,0,1). |
static ColorRGBA |
brown
the color brown (65/255, 40/255, 25/255). |
static ColorRGBA |
cyan
the color cyan (0,1,1). |
static ColorRGBA |
darkGray
the color gray (.2,.2,.2). |
float |
g
The green component of the color. |
static ColorRGBA |
gray
the color gray (.5,.5,.5). |
static ColorRGBA |
green
the color green (0,1,0). |
static ColorRGBA |
lightGray
the color gray (.8,.8,.8). |
static ColorRGBA |
magenta
the color magenta (1,0,1). |
static ColorRGBA |
orange
the color orange (251/255, 130/255,0). |
static ColorRGBA |
pink
the color pink (1, 0.68, 0.68). |
float |
r
The red component of the color. |
static ColorRGBA |
red
the color red (1,0,0). |
static ColorRGBA |
white
the color white (1,1,1). |
static ColorRGBA |
yellow
the color yellow (1,1,0). |
Constructor Summary | |
---|---|
ColorRGBA()
Constructor instantiates a new ColorRGBA object. |
|
ColorRGBA(ColorRGBA rgba)
Copy constructor creates a new ColorRGBA object, based on
a provided color. |
|
ColorRGBA(float r,
float g,
float b,
float a)
Constructor instantiates a new ColorRGBA object. |
Method Summary | |
---|---|
ColorRGBA |
add(ColorRGBA c)
Adds each r/g/b/a of this color by the r/g/b/a of the given color and returns the result as a new ColorRGBA. |
ColorRGBA |
addLocal(ColorRGBA c)
Multiplies each r/g/b/a of this color by the r/g/b/a of the given color and returns the result as a new ColorRGBA. |
int |
asIntARGB()
|
int |
asIntRGBA()
|
void |
clamp()
clamp insures that all values are between 0 and 1. |
ColorRGBA |
clone()
|
boolean |
equals(java.lang.Object o)
equals returns true if this color is logically equivalent
to a given color. |
void |
fromIntARGB(int color)
|
void |
fromIntRGBA(int color)
|
java.lang.Class<? extends ColorRGBA> |
getClassTag()
|
float[] |
getColorArray()
getColorArray retrieves the color values of this object as
a four element float array. |
float[] |
getColorArray(float[] store)
Stores the current r/g/b/a values into the tempf array. |
int |
hashCode()
hashCode returns a unique code for this color object based
on it's values. |
void |
interpolate(ColorRGBA beginColor,
ColorRGBA finalColor,
float changeAmnt)
Sets this color to the interpolation by changeAmnt from beginColor to finalColor this=(1-changeAmnt)*beginColor + changeAmnt * finalColor |
void |
interpolate(ColorRGBA finalColor,
float changeAmnt)
Sets this color to the interpolation by changeAmnt from this to the finalColor this=(1-changeAmnt)*this + changeAmnt * finalColor |
ColorRGBA |
mult(ColorRGBA c)
Multiplies each r/g/b/a of this color by the r/g/b/a of the given color and returns the result as a new ColorRGBA. |
ColorRGBA |
multLocal(float scalar)
Multiplies each r/g/b/a of this color by the r/g/b/a of the given color and returns the result as a new ColorRGBA. |
static ColorRGBA |
randomColor()
randomColor is a utility method that generates a random
color. |
void |
read(JMEImporter e)
|
void |
readExternal(java.io.ObjectInput in)
Used with serialization. |
ColorRGBA |
set(ColorRGBA rgba)
set sets the values of this color to those set by a parameter
color. |
void |
set(float r,
float g,
float b,
float a)
set sets the RGBA values of this color. |
float[] |
toArray(float[] floats)
Saves this ColorRGBA into the given float[] object. |
java.lang.String |
toString()
toString returns the string representation of this color. |
void |
write(JMEExporter e)
|
void |
writeExternal(java.io.ObjectOutput out)
Used with serialization. |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final ColorRGBA black
public static final ColorRGBA white
public static final ColorRGBA darkGray
public static final ColorRGBA gray
public static final ColorRGBA lightGray
public static final ColorRGBA red
public static final ColorRGBA green
public static final ColorRGBA blue
public static final ColorRGBA yellow
public static final ColorRGBA magenta
public static final ColorRGBA cyan
public static final ColorRGBA orange
public static final ColorRGBA brown
public static final ColorRGBA pink
public float r
public float g
public float b
public float a
Constructor Detail |
---|
public ColorRGBA()
ColorRGBA
object. This
color is the default "white" with all values 1.
public ColorRGBA(float r, float g, float b, float a)
ColorRGBA
object. The
values are defined as passed parameters. These values are then clamped
to insure that they are between 0 and 1.
r
- the red component of this color.g
- the green component of this color.b
- the blue component of this color.a
- the alpha component of this color.public ColorRGBA(ColorRGBA rgba)
ColorRGBA
object, based on
a provided color.
rgba
- the ColorRGBA
object to copy.Method Detail |
---|
public void set(float r, float g, float b, float a)
set
sets the RGBA values of this color. The values are then
clamped to insure that they are between 0 and 1.
r
- the red component of this color.g
- the green component of this color.b
- the blue component of this color.a
- the alpha component of this color.public ColorRGBA set(ColorRGBA rgba)
set
sets the values of this color to those set by a parameter
color.
rgba
- ColorRGBA the color to set this color to.
public void clamp()
clamp
insures that all values are between 0 and 1. If any
are less than 0 they are set to zero. If any are more than 1 they are
set to one.
public float[] getColorArray()
getColorArray
retrieves the color values of this object as
a four element float array.
public float[] getColorArray(float[] store)
store
- The array of floats to store the values into.
public void interpolate(ColorRGBA finalColor, float changeAmnt)
finalColor
- The final color to interpolate towardschangeAmnt
- An amount between 0.0 - 1.0 representing a precentage
change from this towards finalColorpublic void interpolate(ColorRGBA beginColor, ColorRGBA finalColor, float changeAmnt)
beginColor
- The begining color (changeAmnt=0)finalColor
- The final color to interpolate towards (changeAmnt=1)changeAmnt
- An amount between 0.0 - 1.0 representing a precentage
change from beginColor towards finalColorpublic static ColorRGBA randomColor()
randomColor
is a utility method that generates a random
color.
public ColorRGBA mult(ColorRGBA c)
c
- The color to multiply.
public ColorRGBA multLocal(float scalar)
scalar
- scalar to multiply with
public ColorRGBA add(ColorRGBA c)
c
- The color to add.
public ColorRGBA addLocal(ColorRGBA c)
c
- The color to multiply.
public java.lang.String toString()
toString
returns the string representation of this color.
The format of the string is:
toString
in class java.lang.Object
public ColorRGBA clone()
clone
in class java.lang.Object
public float[] toArray(float[] floats)
floats
- The float[] to take this ColorRGBA. If null, a new float[4] is
created.
public boolean equals(java.lang.Object o)
equals
returns true if this color is logically equivalent
to a given color. That is, if the values of the two colors are the same.
False is returned otherwise.
equals
in class java.lang.Object
o
- the object to compare againts.
public int hashCode()
hashCode
returns a unique code for this color object based
on it's values. If two colors are logically equivalent, they will return
the same hash code value.
hashCode
in class java.lang.Object
public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException
readExternal
in interface java.io.Externalizable
in
- where to read from
java.io.IOException
java.lang.ClassNotFoundException
Externalizable
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException
writeExternal
in interface java.io.Externalizable
out
- where to write to
java.io.IOException
Externalizable
public void write(JMEExporter e) throws java.io.IOException
write
in interface Savable
java.io.IOException
public void read(JMEImporter e) throws java.io.IOException
read
in interface Savable
java.io.IOException
public java.lang.Class<? extends ColorRGBA> getClassTag()
getClassTag
in interface Savable
public int asIntARGB()
public int asIntRGBA()
public void fromIntARGB(int color)
public void fromIntRGBA(int color)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |