Generating Random Colors


#1
This is a companion discussion topic for the original entry at https://www.kirupa.com/html5/generating_random_colors.htm

#2

Excellent article and very instructive. However, in the section called " The Code", you show

var a_range = [1, 1];

but later you show the following
var color = getRandomColor([0, 360],
[90, 100],
[0, 90],
[0, 1]);
which is confusing because are you really specifying a range of alpha values or just one value. The actual code shows
var a_range = [1, 1];
which I believe will only give you one value of alpha, namely 1.


#3

Thanks for pointing that out! That is a mistake. Fixed it :slight_smile:


#4

I like this code! Yours would have given me more to play with when I built a kind of (don’t tell anyone) Lite-Brite game on CodePen. My random colour code was -

let hex = Math.floor(Math.random() * 0xFFFFFF);
let colr =  "#" + ("000000" + hex.toString(16)).substr(-6);

#5

Careful here, this random color never makes #ffffff :wink:

But I dig the lite brite :smiley:


#6

True, a limitation though I can live with it :wink:
Thank you! :cool:


#7

White is overrated.


#8

Saw this just now, reminded me of yours :beam:

https://gfycat.com/ampleecstaticestuarinecrocodile


#9

That is cool haha.


#10

Too Cool! LOL :cool: