|
|
@ -42,7 +42,6 @@ import java.io.IOException; |
|
|
|
* @version $Id: ColorRGBA.java,v 1.29 2007/09/09 18:25:14 irrisor Exp $ |
|
|
|
* @version $Id: ColorRGBA.java,v 1.29 2007/09/09 18:25:14 irrisor Exp $ |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable { |
|
|
|
public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable { |
|
|
|
|
|
|
|
|
|
|
|
static final float GAMMA = 2.2f; |
|
|
|
static final float GAMMA = 2.2f; |
|
|
|
|
|
|
|
|
|
|
|
static final long serialVersionUID = 1; |
|
|
|
static final long serialVersionUID = 1; |
|
|
@ -137,6 +136,7 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable |
|
|
|
* these values are assumed to be in linear space and stored as is. |
|
|
|
* these values are assumed to be in linear space and stored as is. |
|
|
|
* If you want to assign sRGB values use |
|
|
|
* If you want to assign sRGB values use |
|
|
|
* {@link ColorRGBA#setAsSrgb(float, float, float, float) } |
|
|
|
* {@link ColorRGBA#setAsSrgb(float, float, float, float) } |
|
|
|
|
|
|
|
* |
|
|
|
* @param r The red component of this color. |
|
|
|
* @param r The red component of this color. |
|
|
|
* @param g The green component of this <code>ColorRGBA</code>. |
|
|
|
* @param g The green component of this <code>ColorRGBA</code>. |
|
|
|
* @param b The blue component of this <code>ColorRGBA</code>. |
|
|
|
* @param b The blue component of this <code>ColorRGBA</code>. |
|
|
@ -152,6 +152,7 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Copy constructor creates a new <code>ColorRGBA</code> object, based on |
|
|
|
* Copy constructor creates a new <code>ColorRGBA</code> object, based on |
|
|
|
* a provided color. |
|
|
|
* a provided color. |
|
|
|
|
|
|
|
* |
|
|
|
* @param rgba The <code>ColorRGBA</code> object to copy. |
|
|
|
* @param rgba The <code>ColorRGBA</code> object to copy. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public ColorRGBA(ColorRGBA rgba) { |
|
|
|
public ColorRGBA(ColorRGBA rgba) { |
|
|
@ -217,6 +218,7 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable |
|
|
|
* <code>getColorArray</code> retrieves the color values of this |
|
|
|
* <code>getColorArray</code> retrieves the color values of this |
|
|
|
* <code>ColorRGBA</code> as a four element <code>float</code> array in the |
|
|
|
* <code>ColorRGBA</code> as a four element <code>float</code> array in the |
|
|
|
* order: r,g,b,a. |
|
|
|
* order: r,g,b,a. |
|
|
|
|
|
|
|
* |
|
|
|
* @return The <code>float</code> array that contains the color components. |
|
|
|
* @return The <code>float</code> array that contains the color components. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public float[] getColorArray() { |
|
|
|
public float[] getColorArray() { |
|
|
@ -226,6 +228,7 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Stores the current r,g,b,a values into the given array. The given array must have a |
|
|
|
* Stores the current r,g,b,a values into the given array. The given array must have a |
|
|
|
* length of 4 or greater, or an array index out of bounds exception will be thrown. |
|
|
|
* length of 4 or greater, or an array index out of bounds exception will be thrown. |
|
|
|
|
|
|
|
* |
|
|
|
* @param store The <code>float</code> array to store the values into. |
|
|
|
* @param store The <code>float</code> array to store the values into. |
|
|
|
* @return The <code>float</code> array after storage. |
|
|
|
* @return The <code>float</code> array after storage. |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -239,6 +242,7 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Retrieves the alpha component value of this <code>ColorRGBA</code>. |
|
|
|
* Retrieves the alpha component value of this <code>ColorRGBA</code>. |
|
|
|
|
|
|
|
* |
|
|
|
* @return The alpha component value. |
|
|
|
* @return The alpha component value. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public float getAlpha() { |
|
|
|
public float getAlpha() { |
|
|
@ -247,6 +251,7 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Retrieves the red component value of this <code>ColorRGBA</code>. |
|
|
|
* Retrieves the red component value of this <code>ColorRGBA</code>. |
|
|
|
|
|
|
|
* |
|
|
|
* @return The red component value. |
|
|
|
* @return The red component value. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public float getRed() { |
|
|
|
public float getRed() { |
|
|
@ -255,6 +260,7 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Retrieves the blue component value of this <code>ColorRGBA</code>. |
|
|
|
* Retrieves the blue component value of this <code>ColorRGBA</code>. |
|
|
|
|
|
|
|
* |
|
|
|
* @return The blue component value. |
|
|
|
* @return The blue component value. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public float getBlue() { |
|
|
|
public float getBlue() { |
|
|
@ -263,6 +269,7 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Retrieves the green component value of this <code>ColorRGBA</code>. |
|
|
|
* Retrieves the green component value of this <code>ColorRGBA</code>. |
|
|
|
|
|
|
|
* |
|
|
|
* @return The green component value. |
|
|
|
* @return The green component value. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public float getGreen() { |
|
|
|
public float getGreen() { |
|
|
@ -273,6 +280,7 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable |
|
|
|
* Sets this <code>ColorRGBA</code> to the interpolation by changeAmnt from |
|
|
|
* Sets this <code>ColorRGBA</code> to the interpolation by changeAmnt from |
|
|
|
* this to the finalColor: |
|
|
|
* this to the finalColor: |
|
|
|
* this=(1-changeAmnt)*this + changeAmnt * finalColor |
|
|
|
* this=(1-changeAmnt)*this + changeAmnt * finalColor |
|
|
|
|
|
|
|
* |
|
|
|
* @param finalColor The final color to interpolate towards. |
|
|
|
* @param finalColor The final color to interpolate towards. |
|
|
|
* @param changeAmnt An amount between 0.0 - 1.0 representing a percentage |
|
|
|
* @param changeAmnt An amount between 0.0 - 1.0 representing a percentage |
|
|
|
* change from this towards finalColor. |
|
|
|
* change from this towards finalColor. |
|
|
@ -290,6 +298,7 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable |
|
|
|
* Sets this <code>ColorRGBA</code> to the interpolation by changeAmnt from |
|
|
|
* Sets this <code>ColorRGBA</code> to the interpolation by changeAmnt from |
|
|
|
* beginColor to finalColor: |
|
|
|
* beginColor to finalColor: |
|
|
|
* this=(1-changeAmnt)*beginColor + changeAmnt * finalColor |
|
|
|
* this=(1-changeAmnt)*beginColor + changeAmnt * finalColor |
|
|
|
|
|
|
|
* |
|
|
|
* @param beginColor The beginning color (changeAmnt=0). |
|
|
|
* @param beginColor The beginning color (changeAmnt=0). |
|
|
|
* @param finalColor The final color to interpolate towards (changeAmnt=1). |
|
|
|
* @param finalColor The final color to interpolate towards (changeAmnt=1). |
|
|
|
* @param changeAmnt An amount between 0.0 - 1.0 representing a percentage |
|
|
|
* @param changeAmnt An amount between 0.0 - 1.0 representing a percentage |
|
|
@ -307,6 +316,7 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable |
|
|
|
/** |
|
|
|
/** |
|
|
|
* <code>randomColor</code> is a utility method that generates a random |
|
|
|
* <code>randomColor</code> is a utility method that generates a random |
|
|
|
* opaque color. |
|
|
|
* opaque color. |
|
|
|
|
|
|
|
* |
|
|
|
* @return a random <code>ColorRGBA</code> with an alpha set to 1. |
|
|
|
* @return a random <code>ColorRGBA</code> with an alpha set to 1. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public static ColorRGBA randomColor() { |
|
|
|
public static ColorRGBA randomColor() { |
|
|
@ -321,6 +331,7 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable |
|
|
|
* Multiplies each r,g,b,a of this <code>ColorRGBA</code> by the corresponding |
|
|
|
* Multiplies each r,g,b,a of this <code>ColorRGBA</code> by the corresponding |
|
|
|
* r,g,b,a of the given color and returns the result as a new <code>ColorRGBA</code>. |
|
|
|
* r,g,b,a of the given color and returns the result as a new <code>ColorRGBA</code>. |
|
|
|
* Used as a way of combining colors and lights. |
|
|
|
* Used as a way of combining colors and lights. |
|
|
|
|
|
|
|
* |
|
|
|
* @param c The color to multiply by. |
|
|
|
* @param c The color to multiply by. |
|
|
|
* @return The new <code>ColorRGBA</code>. this*c |
|
|
|
* @return The new <code>ColorRGBA</code>. this*c |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -332,6 +343,7 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable |
|
|
|
* Multiplies each r,g,b,a of this <code>ColorRGBA</code> by the given scalar and |
|
|
|
* Multiplies each r,g,b,a of this <code>ColorRGBA</code> by the given scalar and |
|
|
|
* returns the result as a new <code>ColorRGBA</code>. |
|
|
|
* returns the result as a new <code>ColorRGBA</code>. |
|
|
|
* Used as a way of making colors dimmer or brighter. |
|
|
|
* Used as a way of making colors dimmer or brighter. |
|
|
|
|
|
|
|
* |
|
|
|
* @param scalar The scalar to multiply by. |
|
|
|
* @param scalar The scalar to multiply by. |
|
|
|
* @return The new <code>ColorRGBA</code>. this*scalar |
|
|
|
* @return The new <code>ColorRGBA</code>. this*scalar |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -343,6 +355,7 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable |
|
|
|
* Multiplies each r,g,b,a of this <code>ColorRGBA</code> by the given scalar and |
|
|
|
* Multiplies each r,g,b,a of this <code>ColorRGBA</code> by the given scalar and |
|
|
|
* returns the result (this). |
|
|
|
* returns the result (this). |
|
|
|
* Used as a way of making colors dimmer or brighter. |
|
|
|
* Used as a way of making colors dimmer or brighter. |
|
|
|
|
|
|
|
* |
|
|
|
* @param scalar The scalar to multiply by. |
|
|
|
* @param scalar The scalar to multiply by. |
|
|
|
* @return this*c |
|
|
|
* @return this*c |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -358,6 +371,7 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable |
|
|
|
* Adds each r,g,b,a of this <code>ColorRGBA</code> by the corresponding |
|
|
|
* Adds each r,g,b,a of this <code>ColorRGBA</code> by the corresponding |
|
|
|
* r,g,b,a of the given color and returns the result as a new <code>ColorRGBA</code>. |
|
|
|
* r,g,b,a of the given color and returns the result as a new <code>ColorRGBA</code>. |
|
|
|
* Used as a way of combining colors and lights. |
|
|
|
* Used as a way of combining colors and lights. |
|
|
|
|
|
|
|
* |
|
|
|
* @param c The color to add. |
|
|
|
* @param c The color to add. |
|
|
|
* @return The new <code>ColorRGBA</code>. this+c |
|
|
|
* @return The new <code>ColorRGBA</code>. this+c |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -369,6 +383,7 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable |
|
|
|
* Adds each r,g,b,a of this <code>ColorRGBA</code> by the r,g,b,a the given |
|
|
|
* Adds each r,g,b,a of this <code>ColorRGBA</code> by the r,g,b,a the given |
|
|
|
* color and returns the result (this). |
|
|
|
* color and returns the result (this). |
|
|
|
* Used as a way of combining colors and lights. |
|
|
|
* Used as a way of combining colors and lights. |
|
|
|
|
|
|
|
* |
|
|
|
* @param c The color to add. |
|
|
|
* @param c The color to add. |
|
|
|
* @return this+c |
|
|
|
* @return this+c |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -381,6 +396,7 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable |
|
|
|
* <code>toString</code> returns the string representation of this <code>ColorRGBA</code>. |
|
|
|
* <code>toString</code> returns the string representation of this <code>ColorRGBA</code>. |
|
|
|
* The format of the string is:<br> |
|
|
|
* The format of the string is:<br> |
|
|
|
* Color[R.RRRR, G.GGGG, B.BBBB, A.AAAA] |
|
|
|
* Color[R.RRRR, G.GGGG, B.BBBB, A.AAAA] |
|
|
|
|
|
|
|
* |
|
|
|
* @return The string representation of this <code>ColorRGBA</code>. |
|
|
|
* @return The string representation of this <code>ColorRGBA</code>. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
@ -404,6 +420,7 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Saves this <code>ColorRGBA</code> into the given <code>float</code> array. |
|
|
|
* Saves this <code>ColorRGBA</code> into the given <code>float</code> array. |
|
|
|
|
|
|
|
* |
|
|
|
* @param floats The <code>float</code> array to take this <code>ColorRGBA</code>. |
|
|
|
* @param floats The <code>float</code> array to take this <code>ColorRGBA</code>. |
|
|
|
* If null, a new <code>float[4]</code> is created. |
|
|
|
* If null, a new <code>float[4]</code> is created. |
|
|
|
* @return The array, with r,g,b,a float values in that order. |
|
|
|
* @return The array, with r,g,b,a float values in that order. |
|
|
@ -423,6 +440,7 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable |
|
|
|
* <code>equals</code> returns true if this <code>ColorRGBA</code> is logically equivalent |
|
|
|
* <code>equals</code> returns true if this <code>ColorRGBA</code> is logically equivalent |
|
|
|
* to a given color. That is, if all the components of the two colors are the same. |
|
|
|
* to a given color. That is, if all the components of the two colors are the same. |
|
|
|
* False is returned otherwise. |
|
|
|
* False is returned otherwise. |
|
|
|
|
|
|
|
* |
|
|
|
* @param o The object to compare against. |
|
|
|
* @param o The object to compare against. |
|
|
|
* @return true if the colors are equal, false otherwise. |
|
|
|
* @return true if the colors are equal, false otherwise. |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -456,6 +474,7 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable |
|
|
|
* <code>hashCode</code> returns a unique code for this <code>ColorRGBA</code> based |
|
|
|
* <code>hashCode</code> returns a unique code for this <code>ColorRGBA</code> based |
|
|
|
* on its values. If two colors are logically equivalent, they will return |
|
|
|
* on its values. If two colors are logically equivalent, they will return |
|
|
|
* the same hash code value. |
|
|
|
* the same hash code value. |
|
|
|
|
|
|
|
* |
|
|
|
* @return The hash code value of this <code>ColorRGBA</code>. |
|
|
|
* @return The hash code value of this <code>ColorRGBA</code>. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
@ -499,9 +518,11 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable |
|
|
|
b = capsule.readFloat("b", 0); |
|
|
|
b = capsule.readFloat("b", 0); |
|
|
|
a = capsule.readFloat("a", 0); |
|
|
|
a = capsule.readFloat("a", 0); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Retrieves the component values of this <code>ColorRGBA</code> as |
|
|
|
* Retrieves the component values of this <code>ColorRGBA</code> as |
|
|
|
* a four element <code>byte</code> array in the order: r,g,b,a. |
|
|
|
* a four element <code>byte</code> array in the order: r,g,b,a. |
|
|
|
|
|
|
|
* |
|
|
|
* @return the <code>byte</code> array that contains the color components. |
|
|
|
* @return the <code>byte</code> array that contains the color components. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public byte[] asBytesRGBA() { |
|
|
|
public byte[] asBytesRGBA() { |
|
|
@ -517,6 +538,7 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable |
|
|
|
* Retrieves the component values of this <code>ColorRGBA</code> as an |
|
|
|
* Retrieves the component values of this <code>ColorRGBA</code> as an |
|
|
|
* <code>int</code> in a,r,g,b order. |
|
|
|
* <code>int</code> in a,r,g,b order. |
|
|
|
* Bits 24-31 are alpha, 16-23 are red, 8-15 are green, 0-7 are blue. |
|
|
|
* Bits 24-31 are alpha, 16-23 are red, 8-15 are green, 0-7 are blue. |
|
|
|
|
|
|
|
* |
|
|
|
* @return The integer representation of this <code>ColorRGBA</code> in a,r,g,b order. |
|
|
|
* @return The integer representation of this <code>ColorRGBA</code> in a,r,g,b order. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public int asIntARGB() { |
|
|
|
public int asIntARGB() { |
|
|
@ -531,6 +553,7 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable |
|
|
|
* Retrieves the component values of this <code>ColorRGBA</code> as an |
|
|
|
* Retrieves the component values of this <code>ColorRGBA</code> as an |
|
|
|
* <code>int</code> in r,g,b,a order. |
|
|
|
* <code>int</code> in r,g,b,a order. |
|
|
|
* Bits 24-31 are red, 16-23 are green, 8-15 are blue, 0-7 are alpha. |
|
|
|
* Bits 24-31 are red, 16-23 are green, 8-15 are blue, 0-7 are alpha. |
|
|
|
|
|
|
|
* |
|
|
|
* @return The integer representation of this <code>ColorRGBA</code> in r,g,b,a order. |
|
|
|
* @return The integer representation of this <code>ColorRGBA</code> in r,g,b,a order. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public int asIntRGBA() { |
|
|
|
public int asIntRGBA() { |
|
|
@ -540,10 +563,12 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable |
|
|
|
| (((int) (a * 255) & 0xFF)); |
|
|
|
| (((int) (a * 255) & 0xFF)); |
|
|
|
return rgba; |
|
|
|
return rgba; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Retrieves the component values of this <code>ColorRGBA</code> as an |
|
|
|
* Retrieves the component values of this <code>ColorRGBA</code> as an |
|
|
|
* <code>int</code> in a,b,g,r order. |
|
|
|
* <code>int</code> in a,b,g,r order. |
|
|
|
* Bits 24-31 are alpha, 16-23 are blue, 8-15 are green, 0-7 are red. |
|
|
|
* Bits 24-31 are alpha, 16-23 are blue, 8-15 are green, 0-7 are red. |
|
|
|
|
|
|
|
* |
|
|
|
* @return The integer representation of this <code>ColorRGBA</code> in a,b,g,r order. |
|
|
|
* @return The integer representation of this <code>ColorRGBA</code> in a,b,g,r order. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public int asIntABGR() { |
|
|
|
public int asIntABGR() { |
|
|
@ -553,10 +578,12 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable |
|
|
|
| (((int) (r * 255) & 0xFF)); |
|
|
|
| (((int) (r * 255) & 0xFF)); |
|
|
|
return abgr; |
|
|
|
return abgr; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Sets the component values of this <code>ColorRGBA</code> with the given |
|
|
|
* Sets the component values of this <code>ColorRGBA</code> with the given |
|
|
|
* combined ARGB <code>int</code>. |
|
|
|
* combined ARGB <code>int</code>. |
|
|
|
* Bits 24-31 are alpha, bits 16-23 are red, bits 8-15 are green, bits 0-7 are blue. |
|
|
|
* Bits 24-31 are alpha, bits 16-23 are red, bits 8-15 are green, bits 0-7 are blue. |
|
|
|
|
|
|
|
* |
|
|
|
* @param color The integer ARGB value used to set this <code>ColorRGBA</code>. |
|
|
|
* @param color The integer ARGB value used to set this <code>ColorRGBA</code>. |
|
|
|
* @return this |
|
|
|
* @return this |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -567,9 +594,11 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable |
|
|
|
b = ((byte) (color) & 0xFF) / 255f; |
|
|
|
b = ((byte) (color) & 0xFF) / 255f; |
|
|
|
return this; |
|
|
|
return this; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Sets the RGBA values of this <code>ColorRGBA</code> with the given combined RGBA value |
|
|
|
* Sets the RGBA values of this <code>ColorRGBA</code> with the given combined RGBA value |
|
|
|
* Bits 24-31 are red, bits 16-23 are green, bits 8-15 are blue, bits 0-7 are alpha. |
|
|
|
* Bits 24-31 are red, bits 16-23 are green, bits 8-15 are blue, bits 0-7 are alpha. |
|
|
|
|
|
|
|
* |
|
|
|
* @param color The integer RGBA value used to set this object. |
|
|
|
* @param color The integer RGBA value used to set this object. |
|
|
|
* @return this |
|
|
|
* @return this |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -580,9 +609,11 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable |
|
|
|
a = ((byte) (color) & 0xFF) / 255f; |
|
|
|
a = ((byte) (color) & 0xFF) / 255f; |
|
|
|
return this; |
|
|
|
return this; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Sets the RGBA values of this <code>ColorRGBA</code> with the given combined ABGR value |
|
|
|
* Sets the RGBA values of this <code>ColorRGBA</code> with the given combined ABGR value |
|
|
|
* Bits 24-31 are alpha, bits 16-23 are blue, bits 8-15 are green, bits 0-7 are red. |
|
|
|
* Bits 24-31 are alpha, bits 16-23 are blue, bits 8-15 are green, bits 0-7 are red. |
|
|
|
|
|
|
|
* |
|
|
|
* @param color The integer ABGR value used to set this object. |
|
|
|
* @param color The integer ABGR value used to set this object. |
|
|
|
* @return this |
|
|
|
* @return this |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -598,6 +629,7 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable |
|
|
|
* Transform this <code>ColorRGBA</code> to a <code>Vector3f</code> using |
|
|
|
* Transform this <code>ColorRGBA</code> to a <code>Vector3f</code> using |
|
|
|
* x = r, y = g, z = b. The Alpha value is not used. |
|
|
|
* x = r, y = g, z = b. The Alpha value is not used. |
|
|
|
* This method is useful for shader assignments. |
|
|
|
* This method is useful for shader assignments. |
|
|
|
|
|
|
|
* |
|
|
|
* @return A <code>Vector3f</code> containing the RGB value of this <code>ColorRGBA</code>. |
|
|
|
* @return A <code>Vector3f</code> containing the RGB value of this <code>ColorRGBA</code>. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public Vector3f toVector3f() { |
|
|
|
public Vector3f toVector3f() { |
|
|
@ -608,6 +640,7 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable |
|
|
|
* Transform this <code>ColorRGBA</code> to a <code>Vector4f</code> using |
|
|
|
* Transform this <code>ColorRGBA</code> to a <code>Vector4f</code> using |
|
|
|
* x = r, y = g, z = b, w = a. |
|
|
|
* x = r, y = g, z = b, w = a. |
|
|
|
* This method is useful for shader assignments. |
|
|
|
* This method is useful for shader assignments. |
|
|
|
|
|
|
|
* |
|
|
|
* @return A <code>Vector4f</code> containing the RGBA value of this <code>ColorRGBA</code>. |
|
|
|
* @return A <code>Vector4f</code> containing the RGBA value of this <code>ColorRGBA</code>. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public Vector4f toVector4f() { |
|
|
|
public Vector4f toVector4f() { |
|
|
@ -632,10 +665,10 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable |
|
|
|
* |
|
|
|
* |
|
|
|
* @return this ColorRGBA with updated values. |
|
|
|
* @return this ColorRGBA with updated values. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public ColorRGBA setAsSrgb(float r, float g, float b, float a){ |
|
|
|
public ColorRGBA setAsSrgb(float r, float g, float b, float a) { |
|
|
|
this.r = (float)Math.pow(r, GAMMA); |
|
|
|
this.r = (float) Math.pow(r, GAMMA); |
|
|
|
this.b = (float)Math.pow(b, GAMMA); |
|
|
|
this.b = (float) Math.pow(b, GAMMA); |
|
|
|
this.g = (float)Math.pow(g, GAMMA); |
|
|
|
this.g = (float) Math.pow(g, GAMMA); |
|
|
|
this.a = a; |
|
|
|
this.a = a; |
|
|
|
|
|
|
|
|
|
|
|
return this; |
|
|
|
return this; |
|
|
@ -666,5 +699,4 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable |
|
|
|
srgb.a = a; |
|
|
|
srgb.a = a; |
|
|
|
return srgb; |
|
|
|
return srgb; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|