dojo._base.Color

Status:Draft
Version:1.0
Authors:Marcus Reimann, Bill Keese
Developers:Eugene Lazutkin, Adam Peller, Alex Russell
Available:since V?

dojo._base.Color contains functions for setting Colors.

As with all dojo._base components, these functions are included within Dojo Base. You get this functionality by just including dojo.js or dojo.xd.js in your page.

Features

  • dojo.Color.named

    An array of named Colors.

  • dojo.blendColors

    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.colorFromRgb

    get rgb(a) array from css-style color declarations

  • dojo.colorFromHex

    converts a hex string with a ‘#’ prefix to a color object. Supports 12-bit #rgb shorthand.

  • dojo.colorFromArray

    builds a color from 1, 2, 3, or 4 element array

  • dojo.colorFromString

    parses str for a color value

Examples

All these expressions result in the same value, a dojo.Color object representing red with no transparency (full opacity):

dojo.colorFromHex("#FF0000")
dojo.colorFromHex("#F00")
dojo.colorFromArray([255, 0, 0])
dojo.colorFromString("red")
dojo.colorFromRgba("rgba(255, 0, 0, 1)")