Last active
October 5, 2023 20:32
-
-
Save kettuniko/1b72bd4862797f1039c8 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
thank you so much :)