Skip to content

Instantly share code, notes, and snippets.

@Gaboso
Created November 6, 2019 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Gaboso/a2879f41d95d8b445040a455406a3e75 to your computer and use it in GitHub Desktop.
Save Gaboso/a2879f41d95d8b445040a455406a3e75 to your computer and use it in GitHub Desktop.
Random RGB Color JS
function getRandorColorNumber() {
let randomNumber = Math.random() * 255;
return Math.round(randomNumber);
}
function randomRGBA() {
let r = getRandorColorNumber();
let g = getRandorColorNumber();
let b = getRandorColorNumber();
let a = Math.random.toFixed(1);
return 'rgba(' + r + ',' + g + ',' + b + ',' + a + ')';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment