Home Reference Source Repository
import {PaletteManager} from 'leaflet-coverage/'
public class | source

PaletteManager

Manages palettes under common names.

Example:

var palettes = new C.PaletteManager({defaultSteps: 10})
palettes.addLinear('grayscale', ['#FFFFFF', '#000000']) // 10 steps
palettes.addLinear('grayscalehd', ['#FFFFFF', '#000000'], {steps: 200}) // high-resolution palette
palettes.add('breweroranges3', ['#fee6ce', '#fdae6b', '#e6550d']) // palette of those 3 colors
palettes.add('mycustom', {red: [0,255], green: [0,0], blue: [10,20]}) // different syntax

Constructor Summary

Public Constructor
public

constructor(defaultSteps: Integer)

Member Summary

Public Members
public get

Method Summary

Public Methods
public

add(name: string, palette: Palette | Array<string>)

Store a supplied generic palette under the given name.

public

addLinear(name: String, colors: Array<string>, steps: number)

Store a linear palette under the given name created with the given CSS color specifications.

public

get(name: string): Palette

Return the palette stored under the given name, or throw an error if not found.

Public Constructors

public constructor(defaultSteps: Integer) source

Params:

NameTypeAttributeDescription
defaultSteps Integer

The default number of steps when adding palettes with addLinear().

Public Members

public get [Symbol.iterator]: * source

Public Methods

public add(name: string, palette: Palette | Array<string>) source

Store a supplied generic palette under the given name.

Params:

NameTypeAttributeDescription
name string

The unique name of the palette.

palette Palette | Array<string>

A palette object or an array of CSS colors.

Example:

var palettes = new C.PaletteManager()
palettes.add('breweroranges3', ['#fee6ce', '#fdae6b', '#e6550d']) // palette of those 3 colors
palettes.add('mycustom', {red: [0,255], green: [0,0], blue: [10,20]}) // different syntax

public addLinear(name: String, colors: Array<string>, steps: number) source

Store a linear palette under the given name created with the given CSS color specifications.

Params:

NameTypeAttributeDescription
name String

The unique name of the palette

colors Array<string>

An array of CSS color specifications

steps number

Use a different number of steps than the default of this manager.

Example:

var palettes = new C.PaletteManager()
palettes.addLinear('grayscale', ['#FFFFFF', '#000000']) // 10 steps
palettes.addLinear('grayscalehd', ['#FFFFFF', '#000000'], {steps: 200})

public get(name: string): Palette source

Return the palette stored under the given name, or throw an error if not found. The palette is an object with properties steps, red, green, and blue. Each of the color arrays is an Uint8Array of length steps.

Params:

NameTypeAttributeDescription
name string

The unique name of the palette

Return:

Palette