random-linear-srgb-color
v1.0.0
Published
Generate a random linear sRGB color.
Downloads
11
Readme
random-linear-srgb-color
Generate a random linear sRGB color.
Installation
npm install --save random-linear-srgb-color
Usage
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
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 }
Acknowledgements
Inspired by random-hex-color by John Otander which is repackaged from a post by Paul Irish.
License
MIT
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
Crafted for generative doings by Adam Morse (@mrmrs_).