1.0.1 • Published 5 years ago

colour-range v1.0.1

Weekly downloads
2
License
ISC
Repository
github
Last release
5 years ago

colourRange(range, options) ⇒ Array.<string>

Get as wide a list of unique colours as possible, based on shifting the hue of the colours

Samples from the 'colour wheel' at equally spaced intervals, where red (#ff0000 / rgb(255, 0, 0) / hsl(0, 1, 0.5)) is the starting point.

colour wheel

For example: calling colourRange(3) will give you 3 colours as wide apart as possible, in this case red, blue, and green [ 'ff0000', '00ff00', '0000ff' ]

This works for providing up to 360 unique colours

Kind: global function
Returns: Array.<string> - - List of unique hex values

ParamTypeDefaultDescription
rangenumber1Number of unique colours to produce, maximum is 360
optionsObject
options.saturationnumber1Saturation of colours
options.lightnessnumber0.5Lightness of colours
options.prefixbooleanfalsePrefix the colours with a '#'

Example

import colourRange from 'colour-range'

colourRange(3)
// [ 'ff0000', '00ff00', '0000ff' ] (RGB)
colourRange(3, { prefix: true })
// [ '#ff0000', '#00ff00', '#0000ff' ]
colourRange(3, { saturation: 0.6, lightness: 0.2, prefix: true })
// [ '#521414', '#145214', '#141452' ]
colourRange(360)
// [ 'ff0000', ..., 'ff0004' ]