randomColor icon indicating copy to clipboard operation
randomColor copied to clipboard

"Truly Random" isn't actually random?

Open bryc opened this issue 3 years ago • 1 comments

randomColor({hue: 'random',luminosity: 'random',count: 54});

More of a pet peeve than an severe issue: On the demo page, you have the above code for Truly Random colors, but it produces dark colors more often than not, so it appears biased and/or constrained to certain saturations and luminosities (which means its not truly random).

Comparison of randomColor on the left, to fully random RGB values (on the right).

image

bryc avatar Mar 02 '21 20:03 bryc

Hmm, good catch, I had wondered that myself. I'm not sure why this is happening, it should picking between 0 and 100 for both Saturation and Brightness in the HSB color space. Will investigate.

Code for Brightness: https://github.com/davidmerfield/randomColor/blob/master/randomColor.js#L172-L174 Code for Saturation: https://github.com/davidmerfield/randomColor/blob/master/randomColor.js#L129-L131

davidmerfield avatar Mar 02 '21 22:03 davidmerfield