Skip to main content

Function: createPerceptuallyUniformScale()

createPerceptuallyUniformScale(startColor, endColor, steps): Color[]

Creates a perceptually uniform sequential color scale.

This function generates a color scale where the perceived difference between each step is uniform. It's crucial for accurate representation of data in visualizations.

Parameters​

ParameterTypeDescription
startColorColorThe starting color of the scale.
endColorColorThe ending color of the scale.
stepsnumberThe number of colors to generate in the scale.

Returns​

Color[]

An array of Color objects representing the perceptually uniform sequential scale.

Example​

const uniformScale = createPerceptuallyUniformScale(
new Color('#ffffcc'), // Light yellow
new Color('#800026'), // Dark red
7
);
// Returns an array of 7 Color objects with perceptually uniform steps between light yellow and dark red

Defined in​

scales/components/perceptually-uniform-scale.ts:24