Skip to content

Instantly share code, notes, and snippets.

@JavaScript-Packer
Created August 20, 2015 05:27
Show Gist options
  • Select an option

  • Save JavaScript-Packer/9d230d1b9da736605742 to your computer and use it in GitHub Desktop.

Select an option

Save JavaScript-Packer/9d230d1b9da736605742 to your computer and use it in GitHub Desktop.
TV Static in HTML5 canvas. Random black and white static effect http://www.whak.ca/animated-gif/
<body>
<canvas id='c'></canvas>
<script>
function a(){var t,e,n,i,r=0;for(t=0;d>t;t++)for(e=0;g>e;e++)n=.5<Math.random()?255:0,h.data[r]=n,h.data[r+1]=n,h.data[r+2]=n,r+=4;k.putImageData(h,0,0),l++,setTimeout(a,0)}var h,n,p,q,t=document.getElementById("c"),k=t.getContext("2d"),d=t.width=320,g=t.height=240,m=(new Date).getTime(),l=0;for(h=k.createImageData(d,g),p=n=0;d>p;p++)for(q=0;g>q;q++)h.data[n+3]=255,n+=4;a();
</script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment