SHARE
TWEET

Untitled

a guest May 23rd, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function seededColours(seedString) {
  2.     let charHash = "";
  3.     let i;
  4.     for (i of seedString) {
  5.         charHash += i.charCodeAt(0);
  6.     }
  7.     const hash = parseInt(charHash, 10);
  8.     const rSeed = seededRandom(hash);
  9.     const gSeed = seededRandom(rSeed * hash);
  10.     const bSeed = seededRandom(gSeed * hash);
  11.  
  12.     const r = Math.floor(rSeed * 256);
  13.     const g = Math.floor(gSeed * 256);
  14.     const b = Math.floor(bSeed * 256);
  15.  
  16.     return `rgb(${r},${g},${b})`;
  17. }
  18.  
  19. function seededRandom(seed) {
  20.     return ((seed * 9301 + 49297) % 233280) / 233280;
  21. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top