Skip to content

Instantly share code, notes, and snippets.

@kettuniko
Last active October 5, 2023 20:32
Show Gist options
  • Save kettuniko/1b72bd4862797f1039c8 to your computer and use it in GitHub Desktop.
Save kettuniko/1b72bd4862797f1039c8 to your computer and use it in GitHub Desktop.
Random RGBA colors with javascript
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(',')})`
@nayrban
Copy link

nayrban commented Sep 11, 2019

thank you so much :)

@huuvan023
Copy link

thanks bro :>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment