For generating attractive random colors
A tiny script for generating attractive random colors. See the results on the demo.
npm install randomcolor
You can pass an options object to influence the type of color it produces. The options object accepts the following properties:
Hue – Controls the hue of the generated color. You can pass a string representing a color name (e.g. 'orange'). Possible color names are red, orange, yellow, green, blue, purple, pink and monochrome.
Luminosity – Controls the luminosity of the generated color. You can pass a string containing bright, light or dark.
Count – An integer which specifies the number of colors to generate.
Format – A string which specifies the format of the generated color. Possible values are hsl, hslArray, rgb, rgbArray, and hex. The type of the generated color will vary based on the format chosen.
// Returns a hex code for an attractive colorrandomColor;// Returns an array of ten green colorsrandomColorcount: 10hue: 'green';// Returns a hex code for a light bluerandomColorluminosity: 'light'hue: 'blue';// Returns a hex code for a 'truly random' colorrandomColorluminosity: 'random'hue: 'random';// Returns a bright color in RGBrandomColorluminosity: 'bright'format: 'rgb' // e.g. 'rgb(225,200,20)';
This project is licensed under the terms of the MIT license.
More generally, it might be a good idea to consider using other color models.
- When returning an array of multiple colors, try to make each color as distinct as possible. Make sure each color is distinct to its neighbours.
- Improve attractive dark color generation, currently they're a touch murky.
- Improve the color dictionary
- definition of hue values and attractive luminosity bounds
- think about how to store hue aliases (e.g. fuschia) or subranges (e.g teal)
- think about making a little point and click tool for defining your own luminosity bounds and customizing the color dictionary
- Think about using and returning seeds.
- Think about adding feature to return complementary & contrasting colors, as well as color triads, tetrads etc. Other libraries might already do this better though.
- Think about adding a scheme options which would return a dominant color, as well as secondary, tertiary color and primary and secondary text colors. This might be a bad idea.