Packageflare.util.palette
Classpublic class ColorPalette
InheritanceColorPalette Inheritance Palette

Palette for color values, including utility methods for generating both categorical and ordinal color palettes.



Public Properties
 PropertyDefined by
  keyframes : Array
[read-only] Keyframes at which color values change in the palette.
ColorPalette
 Inheritedsize : int
The number of values in the palette.
Palette
 Inheritedvalues : Array
Array of palette values.
Palette
Protected Properties
 PropertyDefined by
 Inherited_values : Array
Array of palette values.
Palette
Public Methods
 MethodDefined by
  
ColorPalette(colors:Array = null, keyframes:Array = null)
Creates a new ColorPalette.
ColorPalette
  
category(size:int = 20, colors:Array = null, alpha:Number = 1.0):ColorPalette
[static] Generates a categorical color palette
ColorPalette
  
cool(size:int):ColorPalette
[static] Generates a color palette that uses a "cool", blue-heavy color scheme.
ColorPalette
  
diverging(min:uint = 0xffd73027, mid:uint = 0xffffffbf, max:uint = 0xff1a9850, f:Number = 0.5, size:int):ColorPalette
[static] Generates a color palette of color ramps diverging from a central value.
ColorPalette
  
getColor(v:Number):uint
Retrieves the color corresponding to input interpolation fraction.
ColorPalette
  
getColorByIndex(idx:int):uint
Retrieves the color corresponding to the input array index.
ColorPalette
 Inherited
getValue(f:Number):Object
Retrieves the palette value corresponding to the input interpolation fraction.
Palette
  
hot(size:int):ColorPalette
[static] Generates a color palette that moves from black to red to yellow to white.
ColorPalette
  
ramp(min:uint = 0xfff1eef6, max:uint = 0xff045a8d, size:int):ColorPalette
[static] Generates a color palette that "ramps" from one color to another.
ColorPalette
Public Constants
 ConstantDefined by
  CATEGORY_COLORS_10 : Array
[static] A set of 10 colors for encoding category values.
ColorPalette
  CATEGORY_COLORS_20 : Array
[static] A set of 20 colors for encoding category values.
ColorPalette
  CATEGORY_COLORS_ALT_19 : Array
[static] An alternative set of 19 colors for encoding category values.
ColorPalette
  DEFAULT_SIZE : int = 64
[static] Default size of generated color palettes.
ColorPalette
Property detail
keyframesproperty
keyframes:Array  [read-only]

Keyframes at which color values change in the palette. Useful for configuring gradient paint fills.

Implementation
    public function get keyframes():Array
Constructor detail
ColorPalette()constructor
public function ColorPalette(colors:Array = null, keyframes:Array = null)

Creates a new ColorPalette.

Parameters
colors:Array (default = null) — an array of colors defining the palette
 
keyframes:Array (default = null) — array of keyframes of color interpolations
Method detail
category()method
public static function category(size:int = 20, colors:Array = null, alpha:Number = 1.0):ColorPalette

Generates a categorical color palette

Parameters
size:int (default = 20) — the number of colors to include
 
colors:Array (default = null) — an array of category colors to use. If null, a default category color palette will be used.
 
alpha:Number (default = 1.0) — the alpha value for this palette's colors

Returns
ColorPalette — the categorical color palette
cool()method 
public static function cool(size:int):ColorPalette

Generates a color palette that uses a "cool", blue-heavy color scheme.

Parameters
size:int — the size of the color palette

Returns
ColorPalette — the color palette
diverging()method 
public static function diverging(min:uint = 0xffd73027, mid:uint = 0xffffffbf, max:uint = 0xff1a9850, f:Number = 0.5, size:int):ColorPalette

Generates a color palette of color ramps diverging from a central value.

Parameters
min:uint (default = 0xffd73027) — the color corresponding to the minimum scale value
 
mid:uint (default = 0xffffffbf) — the color corresponding to the central scale value
 
max:uint (default = 0xff1a9850) — the color corresponding to the maximum scale value
 
f:Number (default = 0.5) — an interpolation fraction specifying the position of the central value
 
size:int — the size of the color palette

Returns
ColorPalette — the color palette
getColor()method 
public function getColor(v:Number):uint

Retrieves the color corresponding to input interpolation fraction.

Parameters
v:Number — an interpolation fraction

Returns
uint — the color corresponding to the input fraction
getColorByIndex()method 
public function getColorByIndex(idx:int):uint

Retrieves the color corresponding to the input array index.

Parameters
idx:int — an integer index. The actual index value used is the modulo of the input index by the length of the palette.

Returns
uint — the color in the palette at the given index
hot()method 
public static function hot(size:int):ColorPalette

Generates a color palette that moves from black to red to yellow to white.

Parameters
size:int — the size of the color palette

Returns
ColorPalette — the color palette
ramp()method 
public static function ramp(min:uint = 0xfff1eef6, max:uint = 0xff045a8d, size:int):ColorPalette

Generates a color palette that "ramps" from one color to another.

Parameters
min:uint (default = 0xfff1eef6) — the color corresponding to the minimum scale value
 
max:uint (default = 0xff045a8d) — the color corresponding to the maximum scale value
 
size:int — the size of the color palette

Returns
ColorPalette — the color palette
Constant detail
CATEGORY_COLORS_10constant
public static const CATEGORY_COLORS_10:Array

A set of 10 colors for encoding category values.

CATEGORY_COLORS_20constant 
public static const CATEGORY_COLORS_20:Array

A set of 20 colors for encoding category values. Includes the colors of CATEGORY_COLORS_10 plus lighter shades of each.

CATEGORY_COLORS_ALT_19constant 
public static const CATEGORY_COLORS_ALT_19:Array

An alternative set of 19 colors for encoding category values.

DEFAULT_SIZEconstant 
public static const DEFAULT_SIZE:int = 64

Default size of generated color palettes.