The CAKE is real

By Darren – April 7, 2011

CAKE is a great JavaScript library for use with the HTML5 canvas element.

Instead of something like this in your HTML:

<canvas id=“canvas” width=“100” height="100"></canvas>

You use just a div tag like this:

<div id="canvas"></div>

When using CAKE, Canvas is an object you can create like so:

Canvas = new Canvas(document.getElementById(‘canvas’), 100, 100)

Shapes are also objects. For example:

var rectangle = new Rectangle(50, 50, {
x:50,
y:50,
fill:‘yellow’
})

Then using addFrameListener you can rotate your shape with ease:

rectangle.addFrameListener(function(t) {
this.rotation = ((t / 3000) % 1) * Math.PI * 2
})