Advertisement
Guest User

Untitled

a guest
May 23rd, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement