<script> window.onload = function() { var canvas = document.getElementById("myCanvas"); var context = canvas.getContext("2d"); for (var i=0; i<100; i++) { var x = i; var y = i; var w = 50+i*10; var h = 50+i*10; var a = Math.PI*2*i/100; square(x,y,w,h,a); } ///////////////////////// FUNCTION function square(x,y,w,h,a) { context.save(); context.translate(x,y); context.translate(w/2, h/2); context.rotate(a); context.rect(-w/2,-w/2,w,h); context.stroke(); context.restore(); } }; </script>