Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/magicien/undo-canvas

Add undo/redo functions to CanvasRenderingContext2D
https://github.com/magicien/undo-canvas

canvas canvasrenderingcontext2d undo-redo

Last synced: about 2 months ago
JSON representation

Add undo/redo functions to CanvasRenderingContext2D

Awesome Lists containing this project

README

        

# undo-canvas
Add undo/redo functions to CanvasRenderingContext2D

[Online Demo 1](https://magicien.github.io/undo-canvas/demo.html) / [Demo 2](https://magicien.github.io/undo-canvas/demo2.html)

```

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)

```

## Install

### Node
```
npm install --save undo-canvas
```

### Browser
```

```