<script>

var canvas = document.getElementById('myCanvas');
var context = canvas.getContext('2d');

var canvas2 = document.createElement('canvas');
var context2 = canvas2.getContext('2d');

canvas2.width = canvas.width;
canvas2.height = canvas.height;

for (var i=0; i<=4; i+=0.05) {

context2.beginPath();
context2.rect(0,0,i*30,i*30);
context2.closePath();
context2.fillStyle = "red";
context2.strokeStyle = "green";
context2.fill();
context2.stroke();

context.save();
context.translate(canvas.width/2, canvas.height/2);
context.rotate(-Math.PI*i);
context.drawImage(canvas2,0,0);
context.restore();
}

</script>