SaveText.Ru

MatricaKod
  1. const CV = document.createElement("canvas");
  2. while (document.body.firstChild) {
  3. document.body.removeChild(document.body.firstChild);
  4. }
  5. document.body.appendChild(CV);
  6. const
  7. C = document.querySelector("canvas"),
  8. S = C.getContext("2d"),
  9. W = C.width = innerWidth,
  10. H = C.height = innerHeight,
  11. font = 13,
  12. str = "А+B0В-h1O=Е2T YQS n4N К5L М6Н О7P Р8С Т9У F! Х Z? Ч J.&#,* Ь:@D;A";
  13. let col = W / font,
  14. arr = [],
  15. matrix = str.split('');
  16. for(let i = 0; i < col; i++) arr[i] = 1;
  17. function draw() {
  18. S.fillStyle = "rgba(0, 0, 0, .5)";
  19. S.fillRect(0, 0, W, H);
  20. S.fillStyle = "#0f0";
  21. S.font = font + "px system-ui";
  22. for (let i = 0; i < arr.length; i++) {
  23. let txt = matrix[Math.floor(Math.random() * matrix.length)];
  24. S.fillText(txt, i * font, arr[i] * font);
  25. if (arr[i] * font > H && Math.random() > 0.9) arr[i] = 0;
  26. arr[i]++;
  27. }
  28. }
  29. setInterval(draw, 120);
  30. window.addEventListener(
  31. 'resize', () => location.reload()
  32. );

Share with your friends:

Print