Generating Random Colors

This is a companion discussion topic for the original entry at
1 Like

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.

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

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);

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

But I dig the lite brite :smiley:


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

1 Like

White is overrated.

1 Like

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

1 Like

That is cool haha.

Too Cool! LOL :cool: