Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/magicien/undo-canvas
- Owner: magicien
- License: mit
- Created: 2017-09-04T02:06:26.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-10-29T03:19:49.000Z (about 5 years ago)
- Last Synced: 2024-10-28T22:43:49.896Z (2 months ago)
- Topics: canvas, canvasrenderingcontext2d, undo-redo
- Language: JavaScript
- Size: 18.6 KB
- Stars: 36
- Watchers: 2
- Forks: 9
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
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
``````