Project Name | Stars | Downloads | Repos Using This | Packages Using This | Most Recent Commit | Total Releases | Latest Release | Open Issues | License | Language |
---|---|---|---|---|---|---|---|---|---|---|
Randomcolor | 5,994 | 1,237 | 660 | 2 months ago | 15 | July 14, 2020 | 12 | cc0-1.0 | JavaScript | |
A tiny script for generating attractive colors | ||||||||||
Randomcolor.php | 226 | 41 | 7 | a year ago | 6 | October 13, 2022 | 2 | mit | PHP | |
A color generator for PHP | ||||||||||
Placekit | 143 | 3 | 7 years ago | 2 | March 24, 2015 | 1 | mit | Objective-C | ||
Content placeholders, randomized data and other helpers for early dev, testing and proto work. | ||||||||||
Huelightdj | 66 | 22 days ago | 1 | mit | C# | |||||
Hue Light DJ using Hue Entertainment API | ||||||||||
Randomcolor | 47 | 18 | 3 | 3 years ago | 7 | February 27, 2021 | mit | Dart | ||
Random color generator for Flutter | ||||||||||
Uniqolor | 37 | 10 months ago | 3 | mit | JavaScript | |||||
Generate unique and beautiful colors from any texts or numbers | ||||||||||
Osram_gspots | 4 | 7 years ago | Groovy | |||||||
DTH for US version of Osram GardenSpot Mini rgb lights | ||||||||||
Postcss Randomcolor | 4 | 5 years ago | mit | JavaScript | ||||||
PostCSS plugin supports function to use random color | ||||||||||
Libnexturn | 3 | 9 years ago | 1 | Python | ||||||
Control library for Yifang SH201 Lightbulbs (Nexturn) | ||||||||||
Wallpaper | 2 | 6 years ago | mit | Swift | ||||||
Put up some Wallpaper! Placeholder images, text, and colors for your apps. |
A tiny script for generating attractive random colors. See the demo for an explanation and some samples. randomColor has been ported to C#, C++, Go, Haskell, Kotlin, Mathematica, PHP, Python, Raku, Objective-C, Java, R, Reason, Dart, Ruby, Rust, Swift and Typescript.
To use randomColor in the browser, download the latest minified version of randomColor and include it on your page. Then call the script:
var color = randomColor(); // a hex code for an attractive color
To use randomColor on the server with node.js, install randomColor from npm then call the script:
npm install randomcolor
var randomColor = require('randomcolor'); // import the script
var color = randomColor(); // a hex code for an attractive color
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: red
, orange
, yellow
, green
, blue
, purple
, pink
and monochrome
are currently supported. If you pass a hexidecimal color string such as #00FFFF
, randomColor will extract its hue value and use that to generate colors.
luminosity
– Controls the luminosity of the generated color. You can specify a string containing bright
, light
or dark
.
count
– An integer which specifies the number of colors to generate.
seed
- An integer or string which when passed will cause randomColor to return the same color each time.
format
– A string which specifies the format of the generated color. Possible values are rgb
, rgba
, rgbArray
, hsl
, hsla
, hslArray
and hex
(default).
alpha
– A decimal between 0 and 1. Only relevant when using a format with an alpha channel (rgba
and hsla
). Defaults to a random value.
// Returns a hex code for an attractive color
randomColor();
// Returns an array of ten green colors
randomColor({
count: 10,
hue: 'green'
});
// Returns a hex code for a light blue
randomColor({
luminosity: 'light',
hue: 'blue'
});
// Returns a hex code for a 'truly random' color
randomColor({
luminosity: 'random',
hue: 'random'
});
// Returns a bright color in RGB
randomColor({
luminosity: 'bright',
format: 'rgb' // e.g. 'rgb(225,200,20)'
});
// Returns a dark RGB color with random alpha
randomColor({
luminosity: 'dark',
format: 'rgba' // e.g. 'rgba(9, 1, 107, 0.6482447960879654)'
});
// Returns a dark RGB color with specified alpha
randomColor({
luminosity: 'dark',
format: 'rgba',
alpha: 0.5 // e.g. 'rgba(9, 1, 107, 0.5)',
});
// Returns a light HSL color with random alpha
randomColor({
luminosity: 'light',
format: 'hsla' // e.g. 'hsla(27, 88.99%, 81.83%, 0.6450211517512798)'
});