Add undo/redo functions to CanvasRenderingContext2D
Switch branches/tags
Clone or download
Permalink
Failed to load latest commit information.
.gitignore add files Sep 5, 2017
LICENSE Initial commit Sep 4, 2017
README.md v0.1.3 Sep 8, 2017
demo.html change canvas id of demo.html Sep 5, 2017
demo2.html add touch events to demo2 Sep 8, 2017
index.js add serialize/deserialize Sep 8, 2017
package.json v0.1.3 Sep 8, 2017
test.html add files Sep 5, 2017
test.web.js add files Sep 5, 2017
undo-canvas.js add serialize/deserialize Sep 8, 2017

README.md

undo-canvas

Add undo/redo functions to CanvasRenderingContext2D

Online Demo 1 / Demo 2

<script src="https://cdn.rawgit.com/magicien/undo-canvas/v0.1.3/undo-canvas.js"></script>
<script>
const canvas = document.createElement('canvas')
const context = canvas.getContext('2d')
UndoCanvas.enableUndo(context)

context.strokeStyle = '#ff0000'
context.beginPath()
context.moveTo(0, 0)
context.lineTo(30, 30)
context.closePath()
context.stroke()

context.undo() // erase the line

context.redo() // redraw the line

UndoCanvas.disableUndo(context)
</script>

Install

Node

npm install --save undo-canvas

Browser

<script src="https://cdn.rawgit.com/magicien/undo-canvas/v0.1.3/undo-canvas.js"></script>