BrU32

JS Canvas Random TV Static SRC

Sep 9th, 2016
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1.  
  2. <canvas id="canv" width = "460" height = "360" style=background: hsla(0, 1000%, 100%, 1);>
  3. </canvas>
  4. </div>
  5. <svg viewBox="0 0 100% 100%" class="inv">
  6.  
  7. <use xlink:href="#main" class="clear"></use>
  8. </svg>
  9. </h1>
  10. </section>
  11.  
  12.  
  13. <script>
  14. c = document.getElementById("canv");
  15. var ctx = c.getContext("2d");
  16.  
  17. id = ctx.createImageData(460,360);
  18.  
  19. function draw() {
  20. var w=c.width;
  21. var h=c.height;
  22. window.requestAnimationFrame(draw);
  23. var r;
  24. for (var p = 4 * (w * h - 4); p >= 1; p -= 4) {
  25. r = Math.random();
  26. id.data[p] = id.data[p+1] = id.data[p+2] = 255 * Math.pow(r, 1.6);
  27. id.data[p+3] = 255;
  28. }
  29. ctx.putImageData(id, 0, 0);
  30. }
  31.  
  32. draw();
  33.  
  34. </script>
  35. </body>
  36. </html>
Advertisement
Add Comment
Please, Sign In to add comment