colour-range
v1.0.1
Published
Get a wide list of unique colours, based on shifting the hue of the colours
Downloads
10
Maintainers
Readme
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.
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
| Param | Type | Default | Description | | --- | --- | --- | --- | | range | number | 1 | Number of unique colours to produce, maximum is 360 | | options | Object | | | | [options.saturation] | number | 1 | Saturation of colours | | [options.lightness] | number | 0.5 | Lightness of colours | | [options.prefix] | boolean | false | Prefix 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' ]