Skip to content

Instantly share code, notes, and snippets.

@monkianer
Created June 10, 2017 10:37
Show Gist options
  • Save monkianer/c97ec4885f93353a6ed51f5b758a7305 to your computer and use it in GitHub Desktop.
Save monkianer/c97ec4885f93353a6ed51f5b758a7305 to your computer and use it in GitHub Desktop.
generate colors based on RGB or HSL
function randomRGBColor(){
var r = Math.floor(Math.random()*256);
var g = Math.floor(Math.random()*256);
var b = Math.floor(Math.random()*256);
return "rgb("+ r + "," + g + "," + b +")";
}
function randomHSLColor(){
var h = Math.floor(Math.random()*360);
var s = Math.floor(Math.random()*360);
var l = Math.floor(Math.random()*360);
return "hsl("+ h + "," + s + "%," + l +"%)";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment