\r
static final long serialVersionUID = 1;\r
/**\r
- * the color black (0,0,0).\r
+ * The color black (0,0,0).\r
*/\r
public static final ColorRGBA Black = new ColorRGBA(0f, 0f, 0f, 1f);\r
/**\r
- * the color white (1,1,1).\r
+ * The color white (1,1,1).\r
*/\r
public static final ColorRGBA White = new ColorRGBA(1f, 1f, 1f, 1f);\r
/**\r
- * the color gray (.2,.2,.2).\r
+ * The color gray (.2,.2,.2).\r
*/\r
public static final ColorRGBA DarkGray = new ColorRGBA(0.2f, 0.2f, 0.2f, 1.0f);\r
/**\r
- * the color gray (.5,.5,.5).\r
+ * The color gray (.5,.5,.5).\r
*/\r
public static final ColorRGBA Gray = new ColorRGBA(0.5f, 0.5f, 0.5f, 1.0f);\r
/**\r
- * the color gray (.8,.8,.8).\r
+ * The color gray (.8,.8,.8).\r
*/\r
public static final ColorRGBA LightGray = new ColorRGBA(0.8f, 0.8f, 0.8f, 1.0f);\r
/**\r
- * the color red (1,0,0).\r
+ * The color red (1,0,0).\r
*/\r
public static final ColorRGBA Red = new ColorRGBA(1f, 0f, 0f, 1f);\r
/**\r
- * the color green (0,1,0).\r
+ * The color green (0,1,0).\r
*/\r
public static final ColorRGBA Green = new ColorRGBA(0f, 1f, 0f, 1f);\r
/**\r
- * the color blue (0,0,1).\r
+ * The color blue (0,0,1).\r
*/\r
public static final ColorRGBA Blue = new ColorRGBA(0f, 0f, 1f, 1f);\r
/**\r
- * the color yellow (1,1,0).\r
+ * The color yellow (1,1,0).\r
*/\r
public static final ColorRGBA Yellow = new ColorRGBA(1f, 1f, 0f, 1f);\r
/**\r
- * the color magenta (1,0,1).\r
+ * The color magenta (1,0,1).\r
*/\r
public static final ColorRGBA Magenta = new ColorRGBA(1f, 0f, 1f, 1f);\r
/**\r
- * the color cyan (0,1,1).\r
+ * The color cyan (0,1,1).\r
*/\r
public static final ColorRGBA Cyan = new ColorRGBA(0f, 1f, 1f, 1f);\r
/**\r
- * the color orange (251/255, 130/255,0).\r
+ * The color orange (251/255, 130/255,0).\r
*/\r
public static final ColorRGBA Orange = new ColorRGBA(251f / 255f, 130f / 255f, 0f, 1f);\r
/**\r
- * the color brown (65/255, 40/255, 25/255).\r
+ * The color brown (65/255, 40/255, 25/255).\r
*/\r
public static final ColorRGBA Brown = new ColorRGBA(65f / 255f, 40f / 255f, 25f / 255f, 1f);\r
/**\r
- * the color pink (1, 0.68, 0.68).\r
+ * The color pink (1, 0.68, 0.68).\r
*/\r
public static final ColorRGBA Pink = new ColorRGBA(1f, 0.68f, 0.68f, 1f);\r
/**\r
- * the black color with no alpha (0, 0, 0, 0);\r
+ * The black color with no alpha (0, 0, 0, 0).\r
*/\r
public static final ColorRGBA BlackNoAlpha = new ColorRGBA(0f, 0f, 0f, 0f);\r
/**\r
- * The red component of the color.\r
+ * The red component of the color. 0 is none and 1 is maximum red.\r
*/\r
public float r;\r
/**\r
- * The green component of the color.\r
+ * The green component of the color. 0 is none and 1 is maximum green.\r
*/\r
public float g;\r
/**\r
- * the blue component of the color.\r
+ * The blue component of the color. 0 is none and 1 is maximum blue.\r
*/\r
public float b;\r
/**\r
- * the alpha component of the color. 0 is transparent and 1 is opaque\r
+ * The alpha component of the color. 0 is transparent and 1 is opaque.\r
*/\r
public float a;\r
\r
/**\r
* Constructor instantiates a new <code>ColorRGBA</code> object. This\r
* color is the default "white" with all values 1.\r
- *\r
*/\r
public ColorRGBA() {\r
r = g = b = a = 1.0f;\r
* Constructor instantiates a new <code>ColorRGBA</code> object. The\r
* values are defined as passed parameters. These values are then clamped\r
* to insure that they are between 0 and 1.\r
- * @param r the red component of this color.\r
- * @param g the green component of this color.\r
- * @param b the blue component of this color.\r
- * @param a the alpha component of this color.\r
+ * @param r The red component of this color.\r
+ * @param g The green component of this <code>ColorRGBA</code>.\r
+ * @param b The blue component of this <code>ColorRGBA</code>.\r
+ * @param a The alpha component of this <code>ColorRGBA</code>.\r
*/\r
public ColorRGBA(float r, float g, float b, float a) {\r
this.r = r;\r
/**\r
* Copy constructor creates a new <code>ColorRGBA</code> object, based on\r
* a provided color.\r
- * @param rgba the <code>ColorRGBA</code> object to copy.\r
+ * @param rgba The <code>ColorRGBA</code> object to copy.\r
*/\r
public ColorRGBA(ColorRGBA rgba) {\r
this.a = rgba.a;\r
}\r
\r
/**\r
+ * <code>set</code> sets the RGBA values of this <code>ColorRGBA</code>. The \r
+ * values are then clamped to insure that they are between 0 and 1.\r
*\r
- * <code>set</code> sets the RGBA values of this color. The values are then\r
- * clamped to insure that they are between 0 and 1.\r
- *\r
- * @param r the red component of this color.\r
- * @param g the green component of this color.\r
- * @param b the blue component of this color.\r
- * @param a the alpha component of this color.\r
+ * @param r The red component of this color.\r
+ * @param g The green component of this color.\r
+ * @param b The blue component of this color.\r
+ * @param a The alpha component of this color.\r
* @return this\r
*/\r
public ColorRGBA set(float r, float g, float b, float a) {\r
}\r
\r
/**\r
- * <code>set</code> sets the values of this color to those set by a parameter\r
- * color.\r
+ * <code>set</code> sets the values of this <code>ColorRGBA</code> to those \r
+ * set by a parameter color.\r
*\r
- * @param rgba ColorRGBA the color to set this color to.\r
+ * @param rgba The color to set this <code>ColorRGBA</code> to.\r
* @return this\r
*/\r
public ColorRGBA set(ColorRGBA rgba) {\r
* <code>clamp</code> insures that all values are between 0 and 1. If any\r
* are less than 0 they are set to zero. If any are more than 1 they are\r
* set to one.\r
- *\r
*/\r
public void clamp() {\r
if (r < 0) {\r
}\r
\r
/**\r
- *\r
- * <code>getColorArray</code> retrieves the color values of this object as\r
- * a four element float array.\r
- * @return the float array that contains the color elements.\r
+ * <code>getColorArray</code> retrieves the color values of this \r
+ * <code>ColorRGBA</code> as a four element <code>float</code> array in the \r
+ * order: r,g,b,a.\r
+ * @return The <code>float</code> array that contains the color components.\r
*/\r
public float[] getColorArray() {\r
return new float[]{r, g, b, a};\r
}\r
\r
/**\r
- * Stores the current r/g/b/a values into the tempf array. The tempf array must have a\r
+ * Stores the current r,g,b,a values into the given array. The given array must have a\r
* length of 4 or greater, or an array index out of bounds exception will be thrown.\r
- * @param store The array of floats to store the values into.\r
- * @return The float[] after storage.\r
+ * @param store The <code>float</code> array to store the values into.\r
+ * @return The <code>float</code> array after storage.\r
*/\r
public float[] getColorArray(float[] store) {\r
store[0] = r;\r
return store;\r
}\r
\r
+ /**\r
+ * Retrieves the alpha component value of this <code>ColorRGBA</code>.\r
+ * @return The alpha component value.\r
+ */\r
public float getAlpha() {\r
return a;\r
}\r
\r
+ /**\r
+ * Retrieves the red component value of this <code>ColorRGBA</code>.\r
+ * @return The red component value.\r
+ */\r
public float getRed() {\r
return r;\r
}\r
\r
+ /**\r
+ * Retrieves the blue component value of this <code>ColorRGBA</code>.\r
+ * @return The blue component value.\r
+ */\r
public float getBlue() {\r
return b;\r
}\r
\r
+ /**\r
+ * Retrieves the green component value of this <code>ColorRGBA</code>.\r
+ * @return The green component value.\r
+ */\r
public float getGreen() {\r
return g;\r
}\r
\r
/**\r
- * Sets this color to the interpolation by changeAmnt from this to the finalColor\r
+ * Sets this <code>ColorRGBA</code> to the interpolation by changeAmnt from \r
+ * this to the finalColor:\r
* this=(1-changeAmnt)*this + changeAmnt * finalColor\r
- * @param finalColor The final color to interpolate towards\r
- * @param changeAmnt An amount between 0.0 - 1.0 representing a precentage\r
- * change from this towards finalColor\r
+ * @param finalColor The final color to interpolate towards.\r
+ * @param changeAmnt An amount between 0.0 - 1.0 representing a percentage\r
+ * change from this towards finalColor.\r
*/\r
public void interpolate(ColorRGBA finalColor, float changeAmnt) {\r
this.r = (1 - changeAmnt) * this.r + changeAmnt * finalColor.r;\r
}\r
\r
/**\r
- * Sets this color to the interpolation by changeAmnt from beginColor to finalColor\r
+ * Sets this <code>ColorRGBA</code> to the interpolation by changeAmnt from \r
+ * beginColor to finalColor:\r
* this=(1-changeAmnt)*beginColor + changeAmnt * finalColor\r
- * @param beginColor The begining color (changeAmnt=0)\r
- * @param finalColor The final color to interpolate towards (changeAmnt=1)\r
+ * @param beginColor The begining color (changeAmnt=0).\r
+ * @param finalColor The final color to interpolate towards (changeAmnt=1).\r
* @param changeAmnt An amount between 0.0 - 1.0 representing a precentage\r
- * change from beginColor towards finalColor\r
+ * change from beginColor towards finalColor.\r
*/\r
public void interpolate(ColorRGBA beginColor, ColorRGBA finalColor, float changeAmnt) {\r
this.r = (1 - changeAmnt) * beginColor.r + changeAmnt * finalColor.r;\r
}\r
\r
/**\r
- *\r
* <code>randomColor</code> is a utility method that generates a random\r
- * color.\r
- *\r
- * @return a random color.\r
+ * opaque color.\r
+ * @return a random <code>ColorRGBA</code> with an alpha set to 1.\r
*/\r
public static ColorRGBA randomColor() {\r
ColorRGBA rVal = new ColorRGBA(0, 0, 0, 1);\r
}\r
\r
/**\r
- * Multiplies each r/g/b/a of this color by the r/g/b/a of the given color and\r
- * returns the result as a new ColorRGBA. Used as a way of combining colors and lights.\r
- * @param c The color to multiply.\r
- * @return The new ColorRGBA. this*c\r
+ * Multiplies each r,g,b,a of this <code>ColorRGBA</code> by the corresponding \r
+ * r,g,b,a of the given color and returns the result as a new <code>ColorRGBA</code>. \r
+ * Used as a way of combining colors and lights.\r
+ * @param c The color to multiply by.\r
+ * @return The new <code>ColorRGBA</code>. this*c\r
*/\r
public ColorRGBA mult(ColorRGBA c) {\r
return new ColorRGBA(c.r * r, c.g * g, c.b * b, c.a * a);\r
}\r
\r
/**\r
- * Multiplies each r/g/b/a of this color by the given scalar and\r
- * returns the result as a new ColorRGBA. Used as a way of making colors dimmer\r
- * or brighter..\r
- * @param scalar The scalar to multiply.\r
- * @return The new ColorRGBA. this*scalar\r
+ * Multiplies each r,g,b,a of this <code>ColorRGBA</code> by the given scalar and\r
+ * returns the result as a new <code>ColorRGBA</code>. \r
+ * Used as a way of making colors dimmer or brighter.\r
+ * @param scalar The scalar to multiply by.\r
+ * @return The new <code>ColorRGBA</code>. this*scalar\r
*/\r
public ColorRGBA mult(float scalar) {\r
return new ColorRGBA(scalar * r, scalar * g, scalar * b, scalar * a);\r
}\r
\r
/**\r
- * Multiplies each r/g/b/a of this color by the r/g/b/a of the given color and\r
- * returns the result as a new ColorRGBA. Used as a way of combining colors and lights.\r
- * @param scalar scalar to multiply with\r
- * @return The new ColorRGBA. this*c\r
+ * Multiplies each r,g,b,a of this <code>ColorRGBA</code> by the given scalar and\r
+ * returns the result (this). \r
+ * Used as a way of making colors dimmer or brighter.\r
+ * @param scalar The scalar to multiply by.\r
+ * @return this*c\r
*/\r
public ColorRGBA multLocal(float scalar) {\r
this.r *= scalar;\r
}\r
\r
/**\r
- * Adds each r/g/b/a of this color by the r/g/b/a of the given color and\r
- * returns the result as a new ColorRGBA.\r
+ * Adds each r,g,b,a of this <code>ColorRGBA</code> by the corresponding \r
+ * r,g,b,a of the given color and returns the result as a new <code>ColorRGBA</code>.\r
+ * Used as a way of combining colors and lights.\r
* @param c The color to add.\r
- * @return The new ColorRGBA. this+c\r
+ * @return The new <code>ColorRGBA</code>. this+c\r
*/\r
public ColorRGBA add(ColorRGBA c) {\r
return new ColorRGBA(c.r + r, c.g + g, c.b + b, c.a + a);\r
}\r
\r
/**\r
- * Multiplies each r/g/b/a of this color by the r/g/b/a of the given color and\r
- * returns the result as a new ColorRGBA. Used as a way of combining colors and lights.\r
- * @param c The color to multiply.\r
- * @return The new ColorRGBA. this*c\r
+ * Adds each r,g,b,a of this <code>ColorRGBA</code> by the r,g,b,a the given \r
+ * color and returns the result (this). \r
+ * Used as a way of combining colors and lights.\r
+ * @param c The color to add.\r
+ * @return this+c\r
*/\r
public ColorRGBA addLocal(ColorRGBA c) {\r
set(c.r + r, c.g + g, c.b + b, c.a + a);\r
}\r
\r
/**\r
- * <code>toString</code> returns the string representation of this color.\r
+ * <code>toString</code> returns the string representation of this <code>ColorRGBA</code>.\r
* The format of the string is:<br>\r
* <Class Name>: [R=RR.RRRR, G=GG.GGGG, B=BB.BBBB, A=AA.AAAA]\r
- * @return the string representation of this color.\r
+ * @return The string representation of this <code>ColorRGBA</code>.\r
*/\r
+ @Override\r
public String toString() {\r
return "Color[" + r + ", " + g + ", " + b + ", " + a + "]";\r
}\r
}\r
\r
/**\r
- * Saves this ColorRGBA into the given float[] object.\r
- *\r
- * @param floats\r
- * The float[] to take this ColorRGBA. If null, a new float[4] is\r
- * created.\r
- * @return The array, with R, G, B, A float values in that order\r
+ * Saves this <code>ColorRGBA</code> into the given <code>float</code> array.\r
+ * @param floats The <code>float</code> array to take this <code>ColorRGBA</code>. \r
+ * If null, a new <code>float[4]</code> is created.\r
+ * @return The array, with r,g,b,a float values in that order.\r
*/\r
public float[] toArray(float[] floats) {\r
if (floats == null) {\r
}\r
\r
/**\r
- * <code>equals</code> returns true if this color is logically equivalent\r
- * to a given color. That is, if the values of the two colors are the same.\r
+ * <code>equals</code> returns true if this <code>ColorRGBA</code> is logically equivalent\r
+ * to a given color. That is, if all the components of the two colors are the same.\r
* False is returned otherwise.\r
- * @param o the object to compare againts.\r
+ * @param o The object to compare against.\r
* @return true if the colors are equal, false otherwise.\r
*/\r
+ @Override\r
public boolean equals(Object o) {\r
if (!(o instanceof ColorRGBA)) {\r
return false;\r
}\r
\r
/**\r
- * <code>hashCode</code> returns a unique code for this color object based\r
- * on it's values. If two colors are logically equivalent, they will return\r
+ * <code>hashCode</code> returns a unique code for this <code>ColorRGBA</code> based\r
+ * on its values. If two colors are logically equivalent, they will return\r
* the same hash code value.\r
- * @return the hash code value of this color.\r
+ * @return The hash code value of this <code>ColorRGBA</code>.\r
*/\r
+ @Override\r
public int hashCode() {\r
int hash = 37;\r
hash += 37 * hash + Float.floatToIntBits(r);\r
b = capsule.readFloat("b", 0);\r
a = capsule.readFloat("a", 0);\r
}\r
-\r
+ /**\r
+ * Retrieves the component values of this <code>ColorRGBA</code> as\r
+ * a four element <code>byte</code> array in the order: r,g,b,a.\r
+ * @return the <code>byte</code> array that contains the color components.\r
+ */\r
public byte[] asBytesRGBA() {\r
byte[] store = new byte[4];\r
store[0] = (byte) ((int) (r * 255) & 0xFF);\r
return store;\r
}\r
\r
+ /**\r
+ * Retrieves the component values of this <code>ColorRGBA</code> as an \r
+ * <code>int</code> in a,r,g,b order. \r
+ * Bits 24-31 are alpha, 16-23 are red, 8-15 are green, 0-7 are blue.\r
+ * @return The integer representation of this <code>ColorRGBA</code> in a,r,g,b order.\r
+ */\r
public int asIntARGB() {\r
int argb = (((int) (a * 255) & 0xFF) << 24)\r
| (((int) (r * 255) & 0xFF) << 16)\r
return argb;\r
}\r
\r
+ /**\r
+ * Retrieves the component values of this <code>ColorRGBA</code> as an \r
+ * <code>int</code> in r,g,b,a order.\r
+ * Bits 24-31 are red, 16-23 are green, 8-15 are blue, 0-7 are alpha.\r
+ * @return The integer representation of this <code>ColorRGBA</code> in r,g,b,a order.\r
+ */\r
public int asIntRGBA() {\r
int rgba = (((int) (r * 255) & 0xFF) << 24)\r
| (((int) (g * 255) & 0xFF) << 16)\r
| (((int) (a * 255) & 0xFF));\r
return rgba;\r
}\r
-\r
+ /**\r
+ * Retrieves the component values of this <code>ColorRGBA</code> as an \r
+ * <code>int</code> in a,b,g,r order.\r
+ * Bits 24-31 are alpha, 16-23 are blue, 8-15 are green, 0-7 are red.\r
+ * @return The integer representation of this <code>ColorRGBA</code> in a,b,g,r order.\r
+ */\r
public int asIntABGR() {\r
int abgr = (((int) (a * 255) & 0xFF) << 24)\r
| (((int) (b * 255) & 0xFF) << 16)\r
| (((int) (r * 255) & 0xFF));\r
return abgr;\r
}\r
-\r
+ /**\r
+ * Sets the component values of this <code>ColorRGBA</code> with the given \r
+ * combined ARGB <code>int</code>.\r
+ * Bits 24-31 are alpha, bits 16-23 are red, bits 8-15 are green, bits 0-7 are blue.\r
+ * @param color The integer ARGB value used to set this <code>ColorRGBA</code>.\r
+ */\r
public void fromIntARGB(int color) {\r
a = ((byte) (color >> 24) & 0xFF) / 255f;\r
r = ((byte) (color >> 16) & 0xFF) / 255f;\r
g = ((byte) (color >> 8) & 0xFF) / 255f;\r
b = ((byte) (color) & 0xFF) / 255f;\r
}\r
-\r
+ /**\r
+ * Sets the RGBA values of this <code>ColorRGBA</code> with the given combined RGBA value \r
+ * Bits 24-31 are red, bits 16-23 are green, bits 8-15 are blue, bits 0-7 are alpha.\r
+ * @param color The integer RGBA value used to set this object.\r
+ */\r
public void fromIntRGBA(int color) {\r
r = ((byte) (color >> 24) & 0xFF) / 255f;\r
g = ((byte) (color >> 16) & 0xFF) / 255f;\r
}\r
\r
/**\r
- * Transform the current ColorRGBA to a Vector3f using\r
+ * Transform this <code>ColorRGBA</code> to a <code>Vector3f</code> using\r
* x = r, y = g, z = b. The Alpha value is not used.\r
- *\r
* This method is useful to use for shaders assignment.\r
- * @return A Vector3f containing the RGB value of current color definition.\r
+ * @return A <code>Vector3f</code> containing the RGB value of this <code>ColorRGBA</code>.\r
*/\r
public Vector3f toVector3f() {\r
return new Vector3f(r, g, b);\r
}\r
\r
/**\r
- * Transform the current ColorRGBA to a Vector4f using\r
+ * Transform this <code>ColorRGBA</code> to a <code>Vector4f</code> using\r
* x = r, y = g, z = b, w = a.\r
- *\r
* This method is useful to use for shaders assignment.\r
- * @return A Vector4f containing the RGBA value of current color definition.\r
+ * @return A <code>Vector4f</code> containing the RGBA value of this <code>ColorRGBA</code>.\r
*/\r
public Vector4f toVector4f() {\r
return new Vector4f(r, g, b, a);\r