)
}
}
)
(
}
{
)
)
(
)
(
(
{
}
)
(
)
}
)
)
{
(
(
)
)
}
)
(
}

Random Color Strings Not-Golfed

  1. const { random, round } = Math
  2.  
  3. const TICK = 100
  4. const CHUNKS_PER_TICK = 4
  5. const minChunk = 3
  6. const maxChunk = 10
  7. const diffChunk = maxChunk - minChunk
  8.  
  9. const generateChance = .9 // 90% change of string generation
  10. const spaceChance = .8 // 80% chance of space
  11. const breakChance = .1 // 10% chance of line break
  12. const numbersChance = .9
  13.  
  14. const randomChunk = () => round(random() * 0xff).toString(36)
  15.   .replace(random() < numbersChance ? /[0-9]/g : '', '')
  16.  
  17. setInterval(() => {
  18.  
  19.   if (random() < generateChance) {
  20.  
  21.     Array(CHUNKS_PER_TICK).fill(0).forEach(() => { 
  22.  
  23.       const stringLeng = round(minChunk + random() * diffChunk)
  24.       let chunk = ''
  25.  
  26.       Array(stringLeng).fill(0)
  27.         .forEach(() => chunk += randomChunk())
  28.  
  29.       const span = document.createElement('span')
  30.       const hue = round(random() * 360)
  31.  
  32.       span.style.color = `hsl(${hue}, 30%, 50%)`
  33.       document.body.appendChild(span)
  34.       span.innerText = chunk
  35.  
  36.       if (random() < spaceChance) { 
  37.         document.body.appendChild(document.createTextNode(' '))
  38.       }
  39.  
  40.       if (random() < breakChance) {
  41.         const br = document.createElement('br')
  42.         document.body.appendChild(br)
  43.       }
  44.  
  45.     })
  46.   }
  47.  
  48.   scrollTo(0, document.body.scrollHeight)
  49. }, TICK)
  50.  
  51.  
  52. // just a lazy hack since snippet zone quick editor only supports js...
  53. // normally this goes in a separate file... :D
  54. document.body.innerHTML += `
  55. <style>
  56. body, html {
  57.   background: black;
  58.   font-family: Oswald, sans-serif;
  59.   overflow-wrap: break-word;
  60.   text-transform: uppercase;
  61.   letter-spacing: 1;
  62. }
  63.  
  64. br {
  65.   height: 1em;
  66.   display: block;
  67. }
  68. </style>
  69. `

An expansion on a snippet from a few days ago inspired by a friends codepen fork…

snippet.zone ~ 2021-24 /// {s/z}