Created
March 22, 2019 05:24
-
-
Save TokenChingy/91459ffb1e88421c1b3ed086c9de3ce9 to your computer and use it in GitHub Desktop.
Seeded random color generator in 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
function seededRandomColor(seed) { | |
function LCG(s) { | |
return (Math.imul(741103597, s) >>> 0) / 2 ** 32; | |
} | |
const symbols = '0123456789ABCDEF'; | |
let color = '#'; | |
for (let i = 0; i < 6; i++) { | |
color += symbols[Math.round(LCG(seed + i) * 16)]; | |
} | |
return color; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment