Object
Function
Takes a named string, hex string, array of rgb or rgba values, an object with r, g, b, and a properties, or another `dojo.Color` object and creates a new Color instance to work from.
Work with a Color instance: var c = new dojo.Color(); c.setColor([0,0,0]); // black var hex = c.toHex(); // #000000
Work with a node's color: var color = dojo.style("someNode", "backgroundColor"); var n = new dojo.Color(color); // adjust the color some n.r *= .5; console.log(n.toString()); // rgb(128, 255, 255);
Function
Blend colors end and start with weight from 0 to 1, 0.5 being a 50/50 blend, can reuse a previously allocated dojo.Color object for the result
dojo.Color
Function
Returns a `dojo.Color` instance from a string of the form "rgb(...)" or "rgba(...)". Optionally accepts a `dojo.Color` object to update with the parsed value and return instead of creating a new object.
A dojo.Color object. If obj is passed, it will be the return value.
dojo.Color
Function
Converts a hex string with a '#' prefix to a color object. Supports 12-bit #rgb shorthand. Optionally accepts a `dojo.Color` object to update with the parsed value.
A dojo.Color object. If obj is passed, it will be the return value.
dojo.Color
var thing = dojo.colorFromHex("#ededed"); // grey, longhand
var thing = dojo.colorFromHex("#000"); // black, shorthand
Function
Builds a `dojo.Color` from a 3 or 4 element array, mapping each element in sequence to the rgb(a) values of the color.
A dojo.Color object. If obj is passed, it will be the return value.
dojo.Color
var myColor = dojo.colorFromArray([237,237,237,0.5]); // grey, 50% alpha
Function
Parses `str` for a color value. Accepts hex, rgb, and rgba style color values.
Acceptable input values for str may include arrays of any form accepted by dojo.colorFromArray, hex strings such as "#aaaaaa", or rgb or rgba strings such as "rgb(133, 200, 16)" or "rgba(10, 10, 10, 50)"
A dojo.Color object. If obj is passed, it will be the return value.
Function
Function
Takes a named string, hex string, array of rgb or rgba values, an object with r, g, b, and a properties, or another `dojo.Color` object and sets this color instance to that value.
dojo.Color
var c = new dojo.Color(); // no color c.setColor("#ededed"); // greyish
Function
Ensures the object has correct attributes
the default implementation does nothing, include dojo.colors to augment it with real checks
dojo.Color
Function
Returns 3 component array of rgb values
Array
var c = new dojo.Color("#000000"); console.log(c.toRgb()); // [0,0,0]
Function
Returns a 4 component array of rgba values from the color represented by this object.
Array
Function
Returns a CSS color string in hexadecimal representation
String
console.log(new dojo.Color([0,0,0]).toHex()); // #000000
Function
Returns a css color string in rgb(a) representation
String
var c = new dojo.Color("#FFF").toCss(); console.log(c); // rgb('255','255','255')
Function
Returns a visual representation of the color
String
Object