See the dojox/color/_base reference documentation for more information.
Blend colors end and start with weight from 0 to 1, 0.5 being a 50/50 blend, can reuse a previously allocated Color object for the result
| Parameter | Type | Description |
|---|---|---|
| start | dojo/_base/Color | |
| end | dojo/_base/Color | |
| weight | Number | |
| obj | dojo/_base/Color |
Optional
|
Takes a named string, hex string, array of rgb or rgba values,
an object with r, g, b, and a properties, or another Color object
and creates a new Color instance to work from.
| Parameter | Type | Description |
|---|---|---|
| color | Array | String | Object |
Work with a Color instance:
require(["dojo/_base/color"], function(Color){
var c = new Color();
c.setColor([0,0,0]); // black
var hex = c.toHex(); // #000000
});
Work with a node's color:
require(["dojo/_base/color", "dojo/dom-style"], function(Color, domStyle){
var color = domStyle("someNode", "backgroundColor");
var n = new Color(color);
// adjust the color some
n.r *= .5;
console.log(n.toString()); // rgb(128, 255, 255);
});
Builds a Color from a 3 or 4 element array, mapping each
element in sequence to the rgb(a) values of the color.
| Parameter | Type | Description |
|---|---|---|
| a | Array | |
| obj | dojo/_base/Color |
Optional
|
A Color object. If obj is passed, it will be the return value.
require(["dojo/_base/color"], function(Color){
var myColor = new Color().fromArray([237,237,237,0.5]); // grey, 50% alpha
});
Create a dojox.color.Color from a CMY defined color. All colors should be expressed as 0-100 (percentage)
| Parameter | Type | Description |
|---|---|---|
| cyan | Object | Array | int | |
| magenta | int | |
| yellow | int |
Create a dojox.color.Color from a CMYK defined color. All colors should be expressed as 0-100 (percentage)
| Parameter | Type | Description |
|---|---|---|
| cyan | Object | Array | int | |
| magenta | int | |
| yellow | int | |
| black | int |
Converts a hex string with a '#' prefix to a color object.
Supports 12-bit #rgb shorthand. Optionally accepts a
Color object to update with the parsed value.
| Parameter | Type | Description |
|---|---|---|
| color | String | |
| obj | dojo/_base/Color |
Optional
|
A Color object. If obj is passed, it will be the return value.
require(["dojo/_base/color"], function(Color){
var thing = new Color().fromHex("#ededed"); // grey, longhand
var thing2 = new Color().fromHex("#000"); // black, shorthand
});
Create a dojox.color.Color from an HSL defined color. hue from 0-359 (degrees), saturation and luminosity 0-100.
| Parameter | Type | Description |
|---|---|---|
| hue | Object | Array | int | |
| saturation | int | |
| luminosity | int |
Create a dojox.color.Color from an HSV defined color. hue from 0-359 (degrees), saturation and value 0-100.
| Parameter | Type | Description |
|---|---|---|
| hue | Object | Array | int | |
| saturation | int | |
| value | int |
get rgb(a) array from css-style color declarations
this function can handle all 4 CSS3 Color Module formats: rgb, rgba, hsl, hsla, including rgb(a) with percentage values.
| Parameter | Type | Description |
|---|---|---|
| color | String | |
| obj | dojo/_base/Color |
Optional
|
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)"
| Parameter | Type | Description |
|---|---|---|
| str | String | |
| obj | dojo/_base/Color |
Optional
|
A Color object. If obj is passed, it will be the return value.
An object that represents a palette of colors.
A Palette is a representation of a set of colors. While the standard number of colors contained in a palette is 5, it can really handle any number of colors.
A palette is useful for the ability to transform all the colors in it using a simple object-based approach. In addition, you can generate palettes using dojox.color.Palette.generate; these generated palettes are based on the palette generators at http://kuler.adobe.com.
| Parameter | Type | Description |
|---|---|---|
| base | String | Array | dojox.color.Color | dojox.color.Palette |