Skip to main content

Color

class Color

This class represents ARGB Colors.


public class Color

β€” Constructors (6) β€”

ConstructorDescription
Color()Creates a new Color.
Color(int r, int g, int b)Creates a new Color with color r(red) defined to be "r" argument, color g(green) defined to be "g" argument and color b(blue) defined to be "b" argument.
Color(float r, float g, float b)Creates a new Color with color r(red) defined to be "r" argument, color g(green) defined to be "g" argument and color b(blue) defined to be "b" argument.
Color(int a, int r, int g, int b)Creates a new Color with opacity(alpha) defined to be "a" argument, color r(red) defined to be "r" argument, color g(green) defined to be "g" argument and color b(blue) defined to be " B" argument.
Color(float a, float r, float g, float b)Creates a new Color with opacity(alpha) defined to be "a" argument, color r(red) defined to be "r" argument, color g(green) defined to be "g" argument and color b(blue) defined to be " B" argument.
Color(String hex)Creates a new color with its hex(hexadecimal color) defined to be "hex" argument.

β€” Methods (62) β€”

NameDescription
void set(Color color)Sets a new Color to be "color" argument.
int getInt()Returns the current int b(blue) value of Color.
void setInt(int color)Sets the current int b(blue) value of Color to be "color" argument.
void fromHexString(String hex)Sets the Color based on the hex code(hexadecimal color) defined to be "hex" argument.
void fromHex(String hex)Sets the Color based on the hex code(hexadecimal color) defined to be "hex" argument.
String getHexString()Returns a String with the current hex code(hexadecimal color) of the Color.
String toHex()Converts the Color into a String containing its hex code(hexadecimal color).
int getIntAlpha()Returns the current int value of the opacity(alpha) of the Color.
void setIntAlpha(int value)Set the current int value of the Color opacity(alpha) to be "value" argument.
int getIntRed()Returns the current red int value of the Color.
void setIntRed(int value)Set the current red int value of the Color to be "value" argument.
int getIntGreen()Returns the current green int value of the Color.
void setIntGreen(int value)Set the current green int value of the Color to be "value" argument.
int getIntBlue()Returns the current blue int value of the Color.
void setIntBlue(int value)Set the current blue int value of the Color to be "value" argument.
void setInts(int a, int r, int g, int b)Sets current int value of opacity(alpha) of Color to be "a" argument, current int value r(red) to be "r" argument, g(green) to be "g" argument and b(blue) to be "b" argument of the Cor.
void setInts(int r, int g, int b)Sets the current int value r(red) to be argument "r", g(green) to be argument "g" and b(blue) to be argument "b" of the Color.
float getFloatAlpha()Returns the current float value of the opacity(alpha) of the Color.
void setFloatAlpha(float value)Set the current float value of the Color opacity(alpha) to be "value" argument.
float getFloatRed()Returns the current red float value of the Color.
void setFloatRed(float value)Set the current red float value of the Color to be "value" argument.
float getFloatGreen()Returns the current green float value of the Color.
void setFloatGreen(float value)Set the current green float value of the Color to be "value" argument.
float getFloatBlue()Returns the current blue float value of the Color.
void setFloatBlue(float value)Set the current blue float value of the Color to be "value" argument.
void setFloats(float a, float r, float g, float b)Sets current int value of opacity(alpha) of Color to be "a" argument, current int value r(red) to be "r" argument, g(green) to be "g" argument and b(blue) to be "b" argument of the Cor.
void setFloats(float r, float g, float b)Sets the current float value r(red) to be argument "r", g(green) to be argument "g" and b(blue) to be argument "b" of the Color.
Color sum(Color color)Adds this Color to the Color defined to be "color" argument and returns a new Color with the result.
Color sum(Vector3 color)Adds this Color to the vector defined to be "color" argument and returns a new Color with the result.
Color sum(Vector2 color)Adds this Color to the vector defined to be "color" argument and returns a new Color with the result.
Color sub(Color color)Subtracts this Color to the Color defined to be "color" argument and returns a new Color with the result.
Color sub(Vector3 color)Subtracts this Color to the vector defined to be "color" argument and returns a new Color with the result.
Color sub(Vector2 color)Subtracts this Color to the vector defined to be "color" argument and returns a new Color with the result.
Color mul(Color color)Multiplies this Color to the Color defined to be "color" argument and returns a new Color with the result.
Color mul(Vector3 color)Multiplies this Color to the vector defined to be "color" argument and returns a new Color with the result.
Color mul(Vector2 color)Multiplies this Color to the vector defined to be "color" argument and returns a new Color with the result.
Color div(Color color)Divides this Color to the Color defined to be "color" argument and returns a new Color with the result.
Color div(Vector3 color)Divides this Color to the vector defined to be "color" argument and returns a new Color with the result.
Color div(Vector2 color)Divides this Color to the vector defined to be "color" argument and returns a new Color with the result.
void sumLocal(Color color)Adds this Color to the Color defined to be "color" argument and applies the result to the Color itself.
void sumLocal(Vector3 color)Adds this Color to the vector defined to be "color" argument and applies the result to the Color itself.
void sumLocal(Vector2 color)Adds this Color to the vector defined to be "color" argument and applies the result to the Color itself.
void subLocal(Color color)Subtracts this Color to the Color defined to be "color" argument and applies the result to the Color itself.
void subLocal(Vector3 color)Subtracts this Color to the vector defined to be "color" argument and applies the result to the Color itself.
void subLocal(Vector2 color)Subtracts this Color to the vector defined to be "color" argument and applies the result to the Color itself.
void mulLocal(Color color)Multiplies this Color to the Color defined to be "color" argument and applies the result to the Color itself.
void mulLocal(Vector3 color)Multiplies this Color to the vector defined to be "color" argument and applies the result to the Color itself.
void mulLocal(Vector2 color)Multiplies this Color to the vector defined to be "color" argument and applies the result to the Color itself.
void divLocal(Color color)Divides this Color to the Color defined to be "color" argument and applies the result to the Color itself.
void divLocal(Vector3 color)Divides this Color to the vector defined to be "color" argument and applies the result to the Color itself.
void divLocal(Vector2 color)Divides this Color to the vector defined to be "color" argument and applies the result to the Color itself.
String toString()Returns Color values to a String.
void lerp(Color value, float speed)Smoothes that Color into another based on a speed.
void lerp(float a, float r, float g, float b, float speed)Smoothes one Color into another, respectively a, r, g and b based on a velocity.
void lerp(float a, float speed)Smoothes that Color into another based on a speed.
void lerpInSeconds(Color value, float speed)Smoothes that Color into another based on a speed multiplied by "Math.bySecond(1)".
void lerpInSeconds(float a, float r, float g, float b, float speed)Smoothes one Color into another, respectively a, r, g and b based on a velocity multiplied by "Math.bySecond(1)".
void lerpInSeconds(float a, float speed)Smoothes that Color into another based on a speed multiplied by "Math.bySecond(1)".
void blend(Color value, float blend)Mix the Color with another.
void blend(float a, float r, float g, float b, float blend)Mixes the Color with another, respectively, a , r, g and b, given a 0-1 percentage.
void blend(float a, float blend)Mix the Color with another.
Color copy()Returns a perfect copy of Color.

β€” Static Methods (7) β€”

NameDescription
Color RED()Returns Solid Red Color(255, 255, 0, 0).
Color WHITE()Returns Solid White Color(255, 255, 255, 255).
Color BLACK()Returns Solid Black Color(255, 0, 0, 0).
Color GREEN()Returns Solid Green Color(255, 0, 255, 0).
Color BLUE()Returns Solid Blue Color(255, 0, 0, 255).
Color YELLOW()Returns Solid Yellow Color(255, 255, 255, 0).
Color PINK()Returns Solid Pink Color(255, 255, 0, 255).

β€” Operators (8) β€”

+ Sum 2 colors and return a new with the result.

Color a = new Color(255, 0, 255, 0); 
Color b = new Color(255, 255, 0, 0);

a + b;

// a = {255, 255, 255, 0}

- Decreases 2 colors and returns a new with the result.

Color a = new Color(255, 0, 255, 0); 
Color b = new Color(255, 255, 0, 0);

a - b;

// a = {0, 0, 0, 0}

* Multiplies 2 colors and returns a new with the result.

Color a = new Color(255, 0, 255, 0); 
Color b = new Color(255, 255, 0, 0);

a * b;

// a = {255, 0, 0, 0}

/ Divide 2 colors and returns a new with the result.

Color a = new Color(255, 255, 255, 0);  
Color b = new Color(255, 255, 0, 0);

a / b;

// a = {1, 1, 0, 0}

+= Sum 2 colors and apply the result to the color itself.

Color a = new Color(255, 0, 255, 0);  
Color b = new Color(255, 255, 0, 0);

a += b;

// a = {255, 255, 255, 0}

-= Decreases 2 colors and apply the result to the color itself.

Color a = new Color(255, 0, 255, 0); 
Color b = new Color(255, 255, 0, 0);

a -= b;

// a = {0, 0, 0, 0}

/= Divide 2 vectors and apply the result to the vector itself.

Color a = new Color(255, 255, 255, 0);  
Color b = new Color(255, 255, 0, 0);
a /= b;

// a = {1, 1, 0, 0}

*= Multiplies 2 colors and apply the result to the color itself.

Color a = new Color(255, 0, 255, 0); 
Color b = new Color(255, 255, 0, 0);

a *= b;

// a = {255, 0, 0, 0}

β€” Comparators (5) β€”

>= Compares whether the value of the color is greater than or equal to the other.

Color a = new Color(255, 255, 255, 255);  

if(a >= 100){

// TRUE because the value of the color "a" is 100 or greater

}

<= Compares whether the value of the color is less than or equal to the other.

Color a = new Color(100, 100, 0, 0);  
if(a <= 255){

// TRUE because the value is less than "255"

}

> Compares if the value of the color is greater than the other.

Color a = new Color(255, 0, 255, 0);  
if(a > 255){

// FALSE because the value of the color "a" is 255 not greater

}

< Compares if the value of the color is greater than the other.

Color a = new Color(255, 0, 255, 0);  

if(a < 255){

// FALSE because the value of color "a" is not less than 255

}

== Compares whether the color values are the same.

Color a = new Color(255, 0, 0, 255);
Color b = new Color(255, 0, 0, 255);

if(a == b){

// TRUE because the value of color "a" is equal to that of color "b"

}