Generate TV static in an HTML5 canvas element
View the demo online http://bahamas10.github.com/tvstatic/
<script src="tvstatic.js"></script>
<script>
var canvas, ctx;
window.addEventListener('load', load, false);
function load() {
canvas = document.getElementById('canvas');
ctx = canvas.getContext('2d');
ctx.fillStyle = '#000';
requestAnimationFrame(render);
}
function render() {
requestAnimationFrame(render);
ctx.clearRect(0, 0, canvas.width, canvas.height);
tvstatic(canvas, ctx, 2);
}
</script>
canvas
: the canvas object on which to overlay staticctx
: the 2d context of the canvas abovescale
: the scale to use when drawing pixels, defaults to 1
MIT