Skip to content

Loaders#

  canvas({
    width: "1920",
    height:"1080",
    oncreate: (e) => {
      const c = e.target
      const x = c.getContext("2d")
      const S = Math.sin
      const C = Math.cos
      const T = Math.tan
      const R = (r,g,b,a = 1) => `rgba(${r}, ${g}, ${b}, ${a})`
      const start = Date.now()
      let t = 0
      const loopFunc = () => {
        t = (Date.now() - start) / 1000
        // code from dwitter https://www.dwitter.net/d/17835
        c.width|=f=(X,Y,w)=>X*X+Y*Y<=2e6*S(t/9)**2?w>9&&f(X,Y,w/=2)|f(X+w,Y,w)|f(X,Y+w,w)|f(X+w,Y+w,w):x.strokeRect(X,Y,w,w);f(x.lineWidth=4,4,1072)
        if (document.contains(c)) requestAnimationFrame(loopFunc)
      }
      const loop = requestAnimationFrame(loopFunc)
    }
  })