Show:

ia.ColorPalette Class

Module: ia

Palette for colors.

Constructor

ia.ColorPalette

(
  • c
)

Parameters:

  • c String

    A list of colors.

Methods

addColor

(
  • c
)

Adds a color to this ia.ColorPalette.

Parameters:

  • c String

    The name of the color.

getColor

(
  • f
)
String

Gets the color corresponding to the interpolation fraction.

Parameters:

  • f Number

    An interpolation fraction as a value between 0 and 1.

Returns:

String: The color corresponding to the fraction.

getColorAtIndex

(
  • index
)
String

Gets the color at the given index into the palette.

Parameters:

  • index Number

    the Index of the color

Returns:

String: the name of the color

getColorList

() String

Gets the list of colors.

Returns:

String: The color list.

getColors

(
  • numberOfColors
)
String

Returns the list of colors. If more colors are requested than are contained in the palette, random colours are generated to complete the list.

Parameters:

  • numberOfColors Number

    The number of colors required.

Returns:

String: An array of color values.

getInterpolatedColors

(
  • numberOfColors
)
String

Returns a list of colors uniformly interpolated from the color property list. If only one color is requested it
will be interpolated from the center of the color property list. If two colors are requested the first and last colors in the color property list will be returned.

Parameters:

  • numberOfColors Number

    The number of colors required.

Returns:

String: An array of color values.

getMatchingColors

(
  • values
)
String

Returns the colors that are matched against the given values in the matchColorsToValues hash.

If no match is found the next color in the palette is used.

If more colors are requested than are contained in the palette, random colours are generated to complete the list.

Parameters:

  • values String

    The values array.

Returns:

String: An array of color values.

setColorAtIndex

(
  • index
  • c
)

Sets the color at the given index into the palette.

Parameters:

  • index Number

    The index of the color

  • c String

    The name of the color.

setColorList

(
  • value
)

Sets the list of colors.

Parameters:

  • value String

    The color list.

Properties

CATEGORY_COLORS

String final static

A set of 20 colors for categoric color schemes.

Default: [ '#B4371F', '#FFBB78', '#2CA02C','#98DF8A', '#D62728', '#FF9896', '#9467BD', '#C5B0D5', '#8C564B', '#C49C94', '#E377C2', '#F7B6D2', '#7F7F7F', '#C7C7C7', '#BCBD22','#DBDB8D', '#17BECF', '#9EDAE5', '#AEC7E8', '#9EDAE5' ]

id

String

The id of the palette.

Default: ""

matchColorsToValues

Associative Array

A hash that matches colors to values. The key is the value to match against - the value is the color.

NUMERIC_COLORS

String final static

A blue numeric color scheme.

Default: ['#ece7f2', '#74a9cf', '#023858']