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

Low Resolution Sine Table

  1. const sin = [
  2. 0,1,1,2,2,3,3,4,4,5,5,6,6,6,7,7,7,8,8,8,8,9,9,9,9,9,9,9,
  3. 9,9,9,9,9,9,9,9,9,9,9,8,8,8,8,7,7,7,6,6,5,5,5,4,4,3,3,2,2,
  4. 1,1,0,0,-1,-1,-2,-2,-3,-3,-4,-4,-4,-5,-5,-6,-6,-7,-7,-7,-8,
  5. -8,-8,-9,-9,-9,-9,-10,-10,-10,-10,-10,-10,-10,-10,-10,-10,
  6. -10,-10,-10,-10,-10,-10,-10,-10,-9,-9,-9,-9,-8,-8,-8,-7,-7,
  7. -6,-6,-6,-5,-5,-4,-4,-3,-3,-2,-2,-1,-1,0];
  8.  
  9. const c = document.body.appendChild(
  10.   document.createElement('canvas')
  11. ).getContext('2d');
  12.  
  13. const size = 200;
  14. c.canvas.width = c.canvas.height = size;
  15.  
  16. let x = 0;
  17. let tick = 0;
  18. let xOff = 30;
  19. let lines = 14;
  20. let pad = 10;
  21. let stagger = 8;
  22.  
  23. const loop = () => {
  24.   tick++;
  25.   c.fillStyle = 'red';
  26.   c.fillRect(0, 0, size, size);
  27.   c.fillStyle = 'white';
  28.  
  29.   for (let i = 0; i < size; i++) {
  30.     for (let j = 1; j < lines; j++) { 
  31.       x = xOff + sin[(i + j * stagger + tick) % 125];
  32.       c.fillRect(x + j * pad, i, 1, 1);
  33.     }
  34.   }
  35.   requestAnimationFrame(loop);
  36. };
  37. loop()

This is a low resolution sine table. I created this array to run on the original gameboy sometime last year… worked great for that…

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