-
-
Save libesto/cff5a5a4fc77932e2f7f300bedd96a35 to your computer and use it in GitHub Desktop.
Random RGBA colors with javascript
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 randomNumber = (min, max) => Math.floor(Math.random() * (max - min + 1) + min); | |
const randomByte = () => randomNumber(0, 255) | |
const randomPercent = () => (randomNumber(50, 100) * 0.01).toFixed(2) | |
const randomCssRgba = () => `rgba(${[randomByte(), randomByte(), randomByte(), randomPercent()].join(',')})` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment