Skip to content

Instantly share code, notes, and snippets.

@brookjordan
Last active March 16, 2023 11:51
Show Gist options
  • Save brookjordan/5616bf5effe7c59310b6ea36e4bfef24 to your computer and use it in GitHub Desktop.
Save brookjordan/5616bf5effe7c59310b6ea36e4bfef24 to your computer and use it in GitHub Desktop.
Functions to get random colours string in hex or RGB
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