Tour API Demos Download Tests
Aperture version 1.0
Generated by: JsDoc Toolkit 2.4.0

Class aperture.Color

Represents a color with support for runtime access of channel values. Since Aperture supports the use of CSS color string values, Color objects are used primarily for efficient manipulation of color, such as in mapping or filter operations. Colors are designed to be immutable.

Color values may be specified in hexadecimal, RGB, RGBA, HSL, HSLA, or named color form. Named colors include any colors configured in aperture.palette along with the standard 17 defined by CSS 2.1.

Class Summary
Constructor Attributes Constructor Name and Description
 

Method Summary

Class Detail

aperture.Color(color)
Parameters:
{String} color
a name or css color value string.
Returns:
{this} a new Color

Method Detail

  • {Array} band(toColor, bands)
    Returns an array of interpolated colors between this color and the toColor suitable for use in a map key. The first color will be this color and the last will be the toColor.
    Parameters:
    {aperture.Color} toColor
    the end color to interpolate to
    {Number} bands
    the number of colors to create
    Returns:
    {Array} an array of colors, of length bands
  • <static> {Array} aperture.Color.band(colors, bands)
    Returns an array of interpolated colors between the first and last color in the set of colors supplied, suitable for use in a map key. This is a convenience function for rebanding colors (or banding colors from a scalar color map key) which simply calls the band function on the first color with the last color.
    Parameters:
    {Array} colors
    the colors to band or reband between.
    {Number} bands
    the number of colors to create
    Returns:
    {Array} an array of colors, of length bands
  • {aperture.Color} blend(color, weight)
    Blends this color with the supplied color and returns a resulting color. Blending provides comprehensive coverage of color derivation use cases in one function by intuitively specifying what the destination is and how much weight should be given the destination versus the source. For instance, rather than darken or lighten a foreground color blend it to the background color so it better adapts to a different color scheme.

    If the color is supplied as a string value a Color object will be created for it, so in cases where this method is called frequently with the same color value but different weights it is better to pre-construct the color as an object and pass that in instead.

    Parameters:
    {Color|String} color
    the color to blend with.
    {Number} weight
    the weighting of the supplied color in the blend process, as a value from 0.0 to 1.0.
    Returns:
    {aperture.Color} a blended color
  • {Number|aperture.Color} brightness(value)
    Gets the brightness as a value between 0 and 1, or if an argument is supplied returns a new color with the brightness given but the same hue and saturation as this color.
    Parameters:
    value
    Returns:
    {Number|aperture.Color} a value for brightness, or a new color with the brightness specified.
  • {String} css()
    Returns the color value as a valid CSS color string.
    Returns:
    {String} a CSS color string.
  • <static> {aperture.Color} aperture.Color.fromHSL(h, s, l, a)
    Constructs a new color from numeric hue/ saturation/ lightness values. Alternatively, the class constructor can be used to construct a color from an hsl[a] string.
    Parameters:
    {Number} h
    the hue as a number in degrees (0-360), or an object with h,s,l[,a] properties.
    {Number} s
    the saturation as a number from 0-1
    {Number} l
    the lightness as a number from 0-1
    {Number} a Optional
    the alpha value as a number from 0-1
    Returns:
    {aperture.Color} the new color
  • <static> {aperture.Color} aperture.Color.fromRGB(r, g, b, a)
    Constructs a new color from numeric red/ green /blue values. Alternatively, the class constructor can be used to construct a color from an rgb[a] string.
    Parameters:
    {Number} r
    the red component as a number from 0-255, or an object with r,g,b[,a] properties.
    {Number} g
    the green component as a number from 0-255
    {Number} b
    the blue component as a number from 0-255
    {Number} a Optional
    the alpha value as a number from 0-1
    Returns:
    {aperture.Color} the new color
  • {Number|aperture.Color} hue(value)
    Gets the hue as a value between 0 and 360, or if an argument is supplied returns a new color with the hue given but the same saturation and lightness.
    Parameters:
    value
    Returns:
    {Number|aperture.Color} a value for hue, or a new color with the hue specified.
  • {Number|aperture.Color} lightness(value)
    Gets the lightness as a value between 0 and 1, or if an argument is supplied returns a new color with the lightness given but the same hue and saturation as this color.
    Parameters:
    value
    Returns:
    {Number|aperture.Color} a value for lightness, or a new color with the lightness specified.
  • {Number|aperture.Color} saturation(value)
    Gets the saturation as a value between 0 and 1, or if an argument is supplied returns a new color with the saturation given but the same hue and lightness as this color.
    Parameters:
    value
    Returns:
    {Number|aperture.Color} a value for saturation, or a new color with the saturation specified.
  • {String} toString()
    Overrides Object.toString() to return the value of css().
    Returns:
    {String} a CSS color string.