jussi-kalliokoski / canvas-history.js

Binds an easy undo/redo API to Canvas 2D Drawing Context.

Home Page:http://niiden.com/canvas-history/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

canvas-history

canvas-history is a nice extension for HTML5 apps that perform drawing.
canvas-history extends the 2D drawing context of the canvas, giving access to easy undo and redo.

Getting started
* include the javascript

Code:
// To save the current state of the canvas (e.g. onmouseup)
context.saveHistory();

// To undo
context.undo();

// To redo
context.redo();

// To adjust the maximum size of the history
context.setHistorySize(15); // Default 10

// To get the maximum size of the history
context.getHistorySize();

Demo:
http://niiden.com/canvas-history/

MIT Licensed

About

Binds an easy undo/redo API to Canvas 2D Drawing Context.

http://niiden.com/canvas-history/


Languages

Language:JavaScript 100.0%