test apr 1
How does it work? Why Canvas and HTML5 video of course:
JAVASCRIPT:
- for (var i=0;i<12;i++){
- var can = document.getElementById('c'+(i+1));
- var ctx = can.getContext('2d');
- pieces_can.push(can);
- pieces_ctx.push(ctx);
- }
- i = setInterval(function(){
- var sWidth = dWidth = 160;
- var sHeight = dHeight = 120;
- dx = dy = 0;
- var source = document.getElementById('puzzle_image');
- for(var i=0;i<12;i++) {
- sx = (i*sWidth)%640;
- sy = ((Math.floor(i/4))*sHeight);
- pieces_ctx[i].drawImage(source, sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight);
- }
- }, 30);
Comments