javascript - How to get random light color -



javascript - How to get random light color -

this question has reply here:

random color generator in javascript 33 answers

i want randomly generate color hex code javascript. color needs lite plenty place black font on it.

what best way ensure lite color beingness generated? help limit letters in next function?

function getrandomcolor() { var letters = '0123456789abcdef'.split(''), color = '#'; for(var = 0; < 6; i++ ) { color += letters[math.floor(math.random() * 16)]; } homecoming color; }

this stack answer seems work you. 1 such reply uses:

var randomcolor = (function lol(m, s, c) { homecoming s[m.floor(m.random() * s.length)] + (c && lol(m, s, c - 1)); })(math, '3456789abcdef', 4);

js fiddle reply above.

edit: alter line alter how light/dark you'd random color (changing abcdef create them lighter):

})(math, '3456789abcdef', 4);

javascript colors

Comments

Popular posts from this blog

python - How to add an model instance to a django queryset? -

Using Android Volley to post an array to PHP -

angularjs - No 'Access-Control-Allow-Origin' error from local domain to public API -