dojo/_base/Color.js

  • Provides:

    • dojo._base.Color
  • Requires:

    • dojo.lib.kernel in common
    • dojo._base.array in common
    • dojo._base.lang in common
  • dojo.Color

    • type
      Function
    • parameters:
      • color: (typeof Array|String|Object)
    • summary
      Takes a named string, hex string, array of rgb or rgba values,
      an object with r, g, b, and a properties, or another <code>dojo.Color</code> object
      and creates a new Color instance to work from.
    • example
      Work with a Color instance:
       var c = new dojo.Color();
       c.setColor([0,0,0]); // black
       var hex = c.toHex(); // #000000
    • example
      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);
  • dojo.Color.r

    • type
      Number
  • dojo.Color.g

    • type
      Number
  • dojo.Color.b

    • type
      Number
  • dojo.Color.a

    • type
      Number
  • dojo.Color._set

    • parameters:
      • r
      • g
      • b
      • a
    • type
      Function
  • dojo.Color.setColor

    • parameters:
      • color: (typeof Array|String|Object)
    • returns
      dojo.Color
    • summary
      Takes a named string, hex string, array of rgb or rgba values,
      an object with r, g, b, and a properties, or another <code>dojo.Color</code> object
      and sets this color instance to that value.
    • example
      	var c = new dojo.Color(); // no color
      	c.setColor("#ededed"); // greyish
    • type
      Function
  • dojo.Color.sanitize

    • returns
      dojo.Color
    • summary
      Ensures the object has correct attributes
    • description
      the default implementation does nothing, include dojo.colors to
      augment it with real checks
    • type
      Function
  • dojo.Color.toRgb

    • returns
      Array
    • summary
      Returns 3 component array of rgb values
    • example
      	var c = new dojo.Color("#000000");
       	console.log(c.toRgb()); // [0,0,0]
    • type
      Function
  • dojo.Color.toRgba

    • returns
      Array
    • summary
      Returns a 4 component array of rgba values from the color
      represented by this object.
    • type
      Function
  • dojo.Color.toHex

    • returns
      String
    • summary
      Returns a CSS color string in hexadecimal representation
    • example
       	console.log(new dojo.Color([0,0,0]).toHex()); // #000000
    • type
      Function
  • dojo.Color.toCss

    • parameters:
      • includeAlpha: (typeof Boolean)
    • returns
      String
    • summary
      Returns a css color string in rgb(a) representation
    • example
      	var c = new dojo.Color("#FFF").toCss();
      	console.log(c); // rgb('255','255','255')
    • type
      Function
  • dojo.Color.toString

    • returns
      String
    • summary
      Returns a visual representation of the color
    • type
      Function
  • dojo

    • alias - dojo
  • dojo.Color.named

    • type
      Object
  • dojo.Color.named.black

    • type
      Array
  • dojo.Color.named.silver

    • type
      Array
  • dojo.Color.named.gray

    • type
      Array
  • dojo.Color.named.white

    • type
      Array
  • dojo.Color.named.maroon

    • type
      Array
  • dojo.Color.named.red

    • type
      Array
  • dojo.Color.named.purple

    • type
      Array
  • dojo.Color.named.fuchsia

    • type
      Array
  • dojo.Color.named.green

    • type
      Array
  • dojo.Color.named.lime

    • type
      Array
  • dojo.Color.named.olive

    • type
      Array
  • dojo.Color.named.yellow

    • type
      Array
  • dojo.Color.named.navy

    • type
      Array
  • dojo.Color.named.blue

    • type
      Array
  • dojo.Color.named.teal

    • type
      Array
  • dojo.Color.named.aqua

    • type
      Array
  • dojo.Color.named.transparent

    • type
      Array
  • dojo.blendColors

    • parameters:
      • start: (typeof dojo.Color)
      • end: (typeof dojo.Color)
      • weight: (typeof Number)
      • obj: (typeof dojo.Color)
    • returns
      dojo.Color
    • summary
      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
    • type
      Function
  • dojo.colorFromRgb

    • parameters:
      • color: (typeof String)
      • obj: (typeof dojo.Color)
    • returns
      dojo.Color
    • summary
      Returns a <code>dojo.Color</code> instance from a string of the form
      &quot;rgb(...)&quot; or &quot;rgba(...)&quot;. Optionally accepts a <code>dojo.Color</code>
      object to update with the parsed value and return instead of
      creating a new object.
    • return_summary
      A dojo.Color object. If obj is passed, it will be the return value.
    • type
      Function
  • dojo.colorFromHex

    • parameters:
      • color: (typeof String)
      • obj: (typeof dojo.Color)
    • returns
      dojo.Color
    • summary
      Converts a hex string with a '#' prefix to a color object.
      Supports 12-bit #rgb shorthand. Optionally accepts a
      <code>dojo.Color</code> object to update with the parsed value.
    • return_summary
      A dojo.Color object. If obj is passed, it will be the return value.
    • example
       var thing = dojo.colorFromHex("#ededed"); // grey, longhand
    • example
       var thing = dojo.colorFromHex("#000"); // black, shorthand
    • type
      Function
  • dojo.colorFromArray

    • parameters:
      • a: (typeof Array)
      • obj: (typeof dojo.Color)
    • returns
      dojo.Color
    • summary
      Builds a <code>dojo.Color</code> from a 3 or 4 element array, mapping each
      element in sequence to the rgb(a) values of the color.
    • example
       var myColor = dojo.colorFromArray([237,237,237,0.5]); // grey, 50% alpha
    • return_summary
      A dojo.Color object. If obj is passed, it will be the return value.
    • type
      Function
  • dojo.colorFromString

    • parameters:
      • str: (typeof String)
      • obj: (typeof dojo.Color)
    • summary
      Parses <code>str</code> for a color value. Accepts hex, rgb, and rgba
      style color values.
    • description
      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)"
    • return_summary
      A dojo.Color object. If obj is passed, it will be the return value.
    • type
      Function
  • dojo._base.Color

    • type
      Object
  • dojo._base

    • type
      Object