Generate a random linear sRGB color.
npm install random-linear-srgb-colorGenerate a random linear sRGB color.
``bash`
npm install --save random-linear-srgb-color
`javascript
var randomLinearSRGBColor = require('random-linear-srgb-color');
// Generate random linear sRGB color as a string
console.log(randomLinearSRGBColor()); // color(linear-srgb 0.74 0.21 0.45)
console.log(randomLinearSRGBColor(0, 1, 0, 1, 0, 1, 0, 1)); // color(linear-srgb 0.10 0.88 0.42 / 0.62)
// Generate random linear sRGB color as an object
console.log(randomLinearSRGBColor(0, 1, 0, 1, 0, 1, 0, 1, true));
// { red: 0.85, green: 0.37, blue: 0.63, alpha: 0.92 }
`
or
`javascript
import randomLinearSRGBColor from 'random-linear-srgb-color';
// Generate random linear sRGB color as a string
console.log(randomLinearSRGBColor()); // color(linear-srgb 0.74 0.21 0.45)
console.log(randomLinearSRGBColor(0, 1, 0, 1, 0, 1, 0, 1)); // color(linear-srgb 0.10 0.88 0.42 / 0.62)
// Generate random linear sRGB color as an object
console.log(randomLinearSRGBColor(0, 1, 0, 1, 0, 1, 0, 1, true));
// { red: 0.85, green: 0.37, blue: 0.63, alpha: 0.92 }
`
Inspired by random-hex-color by John Otander which is repackaged from a post by Paul Irish.
MIT
1. Fork it
2. Create your feature branch (git checkout -b my-new-feature)git commit -am 'Add some feature'
3. Commit your changes ()git push origin my-new-feature`)
4. Push to the branch (
5. Create new Pull Request
Crafted for generative doings by Adam Morse (@mrmrs_).
*