I was just wondering if it is possible to transform between two shapes using just canvas.
ie: star to a cirle.
this is what I have so far:
var canvas,
ctx,
length = 15;
canvas = document.getElementById("star");
ctx = canvas.getContext("2d");
ctx.translate(30, 30);
ctx.rotate((Math.PI * 1 / 10));
for (var i = 5; i--;) {
ctx.lineTo(0, length);
ctx.translate(0, length);
ctx.rotate((Math.PI * 2 / 10));
ctx.lineTo(0, -length);
ctx.translate(0, -length);
ctx.rotate(-(Math.PI * 6 / 10));
}
ctx.lineTo(0, length);
ctx.closePath();
ctx.fill();
Here is a basic transition in pure canvas. Using arcs instead of lines is left as an exercise for the reader 😉
http://jsfiddle.net/pD9CM/