var cloneCanvas = function(self) { var c = document.createElement('canvas'); c.width = self.width; c.height = self.height; var cxt = c.getContext('2d'); cxt.drawImage(self,0,0); return c; }; function blitImage(ctx, image, sx ,sy, sw, sh, dx, dy, dw, dh) { var x; var y; for (x=0;x