public final class ColorRGB extends Object implements Cloneable, Serializable, org.synthclipse.core.ICopyable<ColorRGB>
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.
ColorRGB
instance can be created by
Native.newColorRGB()
/
Native.newColorRGB(r, g, b)
.
Modifier and Type | Field and Description |
---|---|
float |
b
The blue component of the color.
|
static ColorRGB |
Black
The color black (0,0,0).
|
static ColorRGB |
Blue
The color blue (0,0,1).
|
static ColorRGB |
Brown
The color brown (65/255, 40/255, 25/255).
|
static ColorRGB |
Cyan
The color cyan (0,1,1).
|
static ColorRGB |
DarkGray
The color gray (.2,.2,.2).
|
float |
g
The green component of the color.
|
static ColorRGB |
Gray
The color gray (.5,.5,.5).
|
static ColorRGB |
Green
The color green (0,1,0).
|
static ColorRGB |
LightGray
The color gray (.8,.8,.8).
|
static ColorRGB |
Magenta
The color magenta (1,0,1).
|
static ColorRGB |
Orange
The color orange (251/255, 130/255,0).
|
static ColorRGB |
Pink
The color pink (1, 0.68, 0.68).
|
float |
r
The red component of the color.
|
static ColorRGB |
Red
The color red (1,0,0).
|
static ColorRGB |
White
The color white (1,1,1).
|
static ColorRGB |
Yellow
The color yellow (1,1,0).
|
Constructor and Description |
---|
ColorRGB()
Constructor instantiates a new
ColorRGBA object. |
ColorRGB(ColorRGB rgba)
Copy constructor creates a new
ColorRGBA object, based on a
provided color. |
ColorRGB(float r,
float g,
float b)
Constructor instantiates a new
ColorRGBA object. |
Modifier and Type | Method and Description |
---|---|
ColorRGB |
add(ColorRGB c)
Adds each r,g,b,a of this
ColorRGBA by the corresponding
r,g,b,a of the given color and returns the result as a new
ColorRGBA . |
ColorRGB |
addLocal(ColorRGB c)
Adds each r,g,b,a of this
ColorRGBA by the r,g,b,a the given
color and returns the result (this). |
byte[] |
asBytesRGBA()
Retrieves the component values of this
ColorRGBA as a four
element byte array in the order: r,g,b,a. |
int |
asIntABGR()
Retrieves the component values of this
ColorRGBA as an
int in a,b,g,r order. |
int |
asIntARGB()
Retrieves the component values of this
ColorRGBA as an
int in a,r,g,b order. |
int |
asIntRGBA()
Retrieves the component values of this
ColorRGBA as an
int in r,g,b,a order. |
void |
clamp()
clamp insures that all values are between 0 and 1. |
ColorRGB |
clone() |
ColorRGB |
copy() |
boolean |
equals(Object o)
equals returns true if this ColorRGBA is
logically equivalent to a given color. |
void |
fromIntARGB(int color)
Sets the component values of this
ColorRGBA with the given
combined ARGB int . |
void |
fromIntRGBA(int color)
Sets the RGBA values of this
ColorRGBA 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. |
float |
getBlue()
Retrieves the blue component value of this
ColorRGBA . |
float[] |
getColorArray()
getColorArray retrieves the color values of this
ColorRGBA as a four element float array in the
order: r,g,b,a. |
float[] |
getColorArray(float[] store)
Stores the current r,g,b,a values into the given array.
|
float |
getGreen()
Retrieves the green component value of this
ColorRGBA . |
float |
getRed()
Retrieves the red component value of this
ColorRGBA . |
int |
hashCode()
hashCode returns a unique code for this
ColorRGBA based on its values. |
void |
interpolate(ColorRGB beginColor,
ColorRGB finalColor,
float changeAmnt)
Sets this
ColorRGBA to the interpolation by changeAmnt from
beginColor to finalColor: this=(1-changeAmnt)*beginColor + changeAmnt *
finalColor |
void |
interpolate(ColorRGB finalColor,
float changeAmnt)
Sets this
ColorRGBA to the interpolation by changeAmnt from
this to the finalColor: this=(1-changeAmnt)*this + changeAmnt *
finalColor |
ColorRGB |
mult(ColorRGB c)
Multiplies each r,g,b,a of this
ColorRGBA by the
corresponding r,g,b,a of the given color and returns the result as a new
ColorRGBA . |
ColorRGB |
mult(float scalar)
Multiplies each r,g,b,a of this
ColorRGBA by the given
scalar and returns the result as a new ColorRGBA . |
ColorRGB |
multLocal(float scalar)
Multiplies each r,g,b,a of this
ColorRGBA by the given
scalar and returns the result (this). |
static ColorRGB |
randomColor()
randomColor is a utility method that generates a random
opaque color. |
ColorRGB |
set(ColorRGB rgba)
set sets the values of this ColorRGBA to those
set by a parameter color. |
ColorRGB |
set(float r,
float g,
float b)
set sets the RGBA values of this ColorRGBA . |
float[] |
toArray(float[] floats)
Saves this
ColorRGBA into the given float
array. |
String |
toString()
toString returns the string representation of this
ColorRGBA . |
Vector3f |
toVector3f()
Transform this
ColorRGBA to a Vector3f using x
= r, y = g, z = b. |
Vector4f |
toVector4f()
Transform this
ColorRGBA to a Vector4f using x
= r, y = g, z = b, w = a. |
public static final ColorRGB Black
public static final ColorRGB White
public static final ColorRGB DarkGray
public static final ColorRGB Gray
public static final ColorRGB LightGray
public static final ColorRGB Red
public static final ColorRGB Green
public static final ColorRGB Blue
public static final ColorRGB Yellow
public static final ColorRGB Magenta
public static final ColorRGB Cyan
public static final ColorRGB Orange
public static final ColorRGB Brown
public static final ColorRGB Pink
public float r
public float g
public float b
public ColorRGB()
ColorRGBA
object. This color
is the default "white" with all values 1.public ColorRGB(float r, float g, float b)
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 ColorRGBA
.b
- The blue component of this ColorRGBA
.public ColorRGB(ColorRGB rgba)
ColorRGBA
object, based on a
provided color.rgba
- The ColorRGBA
object to copy.public ColorRGB set(float r, float g, float b)
set
sets the RGBA values of this ColorRGBA
. 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.public ColorRGB set(ColorRGB rgba)
set
sets the values of this ColorRGBA
to those
set by a parameter color.rgba
- The color to set this ColorRGBA
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
ColorRGBA
as a four element float
array in the
order: r,g,b,a.float
array that contains the color components.public float[] getColorArray(float[] store)
store
- The float
array to store the values into.float
array after storage.public float getRed()
ColorRGBA
.public float getBlue()
ColorRGBA
.public float getGreen()
ColorRGBA
.public void interpolate(ColorRGB finalColor, float changeAmnt)
ColorRGBA
to the interpolation by changeAmnt from
this to the finalColor: this=(1-changeAmnt)*this + changeAmnt *
finalColorfinalColor
- The final color to interpolate towards.changeAmnt
- An amount between 0.0 - 1.0 representing a percentage change
from this towards finalColor.public void interpolate(ColorRGB beginColor, ColorRGB finalColor, float changeAmnt)
ColorRGBA
to the interpolation by changeAmnt from
beginColor to finalColor: this=(1-changeAmnt)*beginColor + changeAmnt *
finalColorbeginColor
- 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 finalColor.public static ColorRGB randomColor()
randomColor
is a utility method that generates a random
opaque color.ColorRGBA
with an alpha set to 1.public ColorRGB mult(ColorRGB c)
ColorRGBA
by the
corresponding r,g,b,a of the given color and returns the result as a new
ColorRGBA
. Used as a way of combining colors and lights.c
- The color to multiply by.ColorRGBA
. this*cpublic ColorRGB mult(float scalar)
ColorRGBA
by the given
scalar and returns the result as a new ColorRGBA
. Used as a
way of making colors dimmer or brighter.scalar
- The scalar to multiply by.ColorRGBA
. this*scalarpublic ColorRGB multLocal(float scalar)
ColorRGBA
by the given
scalar and returns the result (this). Used as a way of making colors
dimmer or brighter.scalar
- The scalar to multiply by.public ColorRGB add(ColorRGB c)
ColorRGBA
by the corresponding
r,g,b,a of the given color and returns the result as a new
ColorRGBA
. Used as a way of combining colors and lights.c
- The color to add.ColorRGBA
. this+cpublic ColorRGB addLocal(ColorRGB c)
ColorRGBA
by the r,g,b,a the given
color and returns the result (this). Used as a way of combining colors
and lights.c
- The color to add.public String toString()
toString
returns the string representation of this
ColorRGBA
. The format of the string is:public float[] toArray(float[] floats)
ColorRGBA
into the given float
array.floats
- The float
array to take this
ColorRGBA
. If null, a new float[4]
is created.public boolean equals(Object o)
equals
returns true if this ColorRGBA
is
logically equivalent to a given color. That is, if all the components of
the two colors are the same. False is returned otherwise.public int hashCode()
hashCode
returns a unique code for this
ColorRGBA
based on its values. If two colors are logically
equivalent, they will return the same hash code value.public byte[] asBytesRGBA()
ColorRGBA
as a four
element byte
array in the order: r,g,b,a.byte
array that contains the color components.public int asIntARGB()
ColorRGBA
as an
int
in a,r,g,b order. Bits 24-31 are alpha, 16-23 are red,
8-15 are green, 0-7 are blue.ColorRGBA
in
a,r,g,b order.public int asIntRGBA()
ColorRGBA
as an
int
in r,g,b,a order. Bits 24-31 are red, 16-23 are green,
8-15 are blue, 0-7 are alpha.ColorRGBA
in
r,g,b,a order.public int asIntABGR()
ColorRGBA
as an
int
in a,b,g,r order. Bits 24-31 are alpha, 16-23 are blue,
8-15 are green, 0-7 are red.ColorRGBA
in
a,b,g,r order.public void fromIntARGB(int color)
ColorRGBA
with the given
combined ARGB int
. Bits 24-31 are alpha, bits 16-23 are red,
bits 8-15 are green, bits 0-7 are blue.color
- The integer ARGB value used to set this ColorRGBA
.public void fromIntRGBA(int color)
ColorRGBA
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.color
- The integer RGBA value used to set this object.public Vector3f toVector3f()
ColorRGBA
to a Vector3f
using x
= r, y = g, z = b. The Alpha value is not used. This method is useful to
use for shaders assignment.Vector3f
containing the RGB value of this
ColorRGBA
.public Vector4f toVector4f()
ColorRGBA
to a Vector4f
using x
= r, y = g, z = b, w = a. This method is useful to use for shaders
assignment.Vector4f
containing the RGBA value of this
ColorRGBA
.