Home > LayerCake

LayerCake

LayerCake is a project mainly written in PERL and JAVASCRIPT, it's free.

A Javascript Library for managing layers on the HTML5 canvas.

LayerCake: Javascript Library

http://dannytran.me/layercake/

Creating clickable/draggable elements on the canvas is easy.

Grab the root view like so:

var root = LayerCake.bake('canvasId');

Create a rectangle, make it draggable and give it a click callback:

var r1 = new RectView(0,0,200,50);
r1.draggable = true;
r1.click(function(event) {
  alert('you clicked me!');
});

Add it to the rootview:

root.addSubview(r1);

Draw the rootview:

root.draw();

For more detail see the examples:
Example 1: Simple example with one object.
Example 2: Example with multiple nested objects.
Breakout: Brick Breaker game example.

For documentation:
Documentation

Copyright (c) 2010 Danny Tran
MIT License
http://www.opensource.org/licenses/mit-license.php

Previous:sample_app