This object represents a color.
Constructor function.
var myObject = new Color();
var myObject = new Color(colorName);
var myObject = new Color(otherColor);
var myObject = new Color(red, green, blue);
var myObject = new Color(red, green, blue, alpha);
Create a black Color.
var myObject = new Color();
Create a named color. See http://www.w3.org/TR/SVG/types.html#ColorKeywords for the complete list.
var myObject = new Color("red");
Create a color from an hexadecimal value.
var myObject = new Color("#FE5");
var myObject = new Color("#FF5577");
Create a Color representing a copy of otherColor.
var myObject = new Color(otherColor);
Create a gray Color.
var myObject = new Color(50, 50, 50);
Create a half-transparent gray Color.
var myObject = new Color(50, 50, 50, 128);
Returns a copy of this Color.
myObject.clone();
var copyOfMyObject = myObject.clone();
Returns true if this Color and another are referencing the same color.
myObject.equals(other);
if(myFirstObject.equals(mySecondObject)) //Do something
Returns a string representing this Color.
myObject.toString();
Console.print(myObject.toString());
This method is automatically called when trying to convert a Color to a string.
Set the red component of this Color.
myObject.setRed(red);
myObject.setRed(128);
Set the green component of this Color.
myObject.setGreen(green);
myObject.setGreen(128);
Set the blue component of this Color.
myObject.setBlue(blue);
myObject.setBlue(128);
Set the alpha component of this Color.
myObject.setAlpha(alpha);
myObject.setAlpha(128);
Sets this Color to CMYK values.
myObject.setCmyk(cyan, magenta, yellow, black);
myObject.setCmyk(cyan, magenta, yellow, black, alpha);
myObject.setCmyk(128, 60, 60, 100);
myObject.setCmyk(128, 60, 60, 128);
Sets this Color to HSL values.
myObject.setHsl(hue, saturation, lightness);
myObject.setHsl(hue, saturation, lightness, alpha);
myObject.setHsl(50, 100, 100);
myObject.setHsl(50, 100, 100, 128);
Sets this Color to HSV values.
myObject.setHsv(hue, saturation, value);
myObject.setHsv(hue, saturation, value, alpha);
myObject.setHsv(25, 50, 150);
myObject.setHsv(25, 50, 150, 100);
Sets this Color to a named value.
myObject.setNamedColor(name);
Set a named color. See http://www.w3.org/TR/SVG/types.html#ColorKeywords for the complete list.
myObject.setNamedColor("red");
Set a color from an hexadecimal value.
myObject.setNamedColor("#FE5");
myObject.setNamedColor("#FF5577");
Lighten the color by a factor.
Ligthen by 50%.
myObject.lighten();
Ligthen by a factor. (percent)
myObject.lighten(factor);
myObject.lighten();
myObject.lighten(175); //Lighten by 75%
Darken the color by a factor.
Darken by 50%.
myObject.darken();
Darken by a factor. (percent)
myObject.darken(factor);
myObject.darken();
myObject.darken(175); //Darken by 75%
Returns the red component of this Color.
myObject.red();
var myValue = myObject.red();
Returns the green component of this Color.
myObject.green();
var myValue = myObject.green();
Returns the blue component of this Color.
myObject.blue();
var myValue = myObject.blue();
Returns the alpha component of this Color.
myObject.alpha();
var myValue = myObject.alpha();
Returns the cyan component of this Color.
myObject.cyan();
var myValue = myObject.cyan();
Returns the magenta component of this Color.
myObject.magenta();
var myValue = myObject.magenta();
Returns the yellow component of this Color.
myObject.yellow();
var myValue = myObject.yellow();
Returns the black component of this Color.
myObject.black();
var myValue = myObject.black();
Returns the hue component of this Color.
myObject.hue();
var myValue = myObject.hue();
Returns the saturation component of this Color.
myObject.saturation();
var myValue = myObject.saturation();
Returns the lightness component of this Color.
myObject.lightness();
var myValue = myObject.lightness();
Returns the name of this Color in the format "#RRGGBB".
myObject.name();
var myValue = myObject.name();
The red component of this Color. (integer)
myObject.red = 50; Console.print(myObject.red);
The green component of this Color. (integer)
myObject.green = 50; Console.print(myObject.green);
The blue component of this Color. (integer)
myObject.blue = 50; Console.print(myObject.blue);
The alpha component of this Color. (integer)
myObject.alpha = 50; Console.print(myObject.alpha);