Last active
December 7, 2019 12:55
-
-
Save emukupa/54e7dbd3e1d4aaf8f63e9d55aacac6c0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const rgbColor = () => Math.floor(Math.random() * 256); // numbers betweer 0 - 255 | |
| // rgba === red, green, blue and alpha | |
| // rgba examples: white rgba(255, 255, 255, 1), black rgba(0, 0, 0, 1)... etc | |
| const randomRGBColor = (alpha = 1) => `rgba(${rgbColor()}, ${rgbColor()}, ${rgbColor()}, ${alpha})`; | |
| // RESULTS | |
| // rgba(204, 36, 145, 1), all values are random between 0 - 255, last value is definitely 1 | |
| console.log(randomColor()); | |
| // rgba(219, 106, 175, 0.5), all values are random between 0 - 255, last value is definitely 0.5 | |
| console.log(randomColor(0.5)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment