2.1.0-dev.0 • Published 8 days ago

@mapbox/to-color v2.1.0-dev.0

Weekly downloads
64
License
ISC
Repository
github
Last release
8 days ago

@mapbox/to-color

Procedurally generate a deterministic, perceptually distributed color palette.

Build Status

install

npm install @mapbox/to-color

Usage

import toColor from '@mapbox/to-color'

const color = new toColor('tmcw');

// Or a number
// const color = new toColor(1234);
// Or with options
// const color = new toColor('tmcw', { brightness: 0.25, saturation: 1.1 });

const { hsl } = color.getColor();

/*
Returns

{
  raw: [314, 97.95, 50.98],
  formatted: 'hsl(314, 97.95%, 50.98%)'
}
*/

const { hsl } = color.getColor();

/*
Returns

{
  raw: [2, 78.26, 54],
  formatted: 'hsl(2, 78.26%, 54%)'
}
*/

Options

OptionValueDefaultDescription
brightnessNumber0Adjusts brightness percentage from the derived min/max range.
saturationNumber0Adjusts saturation percentage from the derived min/max range.
limitArray[]Limits the higher range of hues for a given color. Options can be red, orange, yellow, green, blue, purple, or pink.

Developing

# Demo site
npm install & npm start

# Run tests
npm run test

Credit v2 is adapted from randomColor.