Last active
March 16, 2023 11:51
-
-
Save brookjordan/5616bf5effe7c59310b6ea36e4bfef24 to your computer and use it in GitHub Desktop.
Functions to get random colours string in hex or RGB
This file contains 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 byteNumber = () => Math.random() * 2 ** 8 >> 0; | |
export const randomHex = () => | |
'#' + (2 ** (2 ** 3 * 3) * Math.random() >> 0).toString(16).padStart(6,'0') | |
; | |
export const randomRGB = () => | |
`rgb(${[byteNumber(),byteNumber(),byteNumber()]})` | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment