Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/seleb/draw-1-bit
simple 1-bit 2D canvas drawing interface
https://github.com/seleb/draw-1-bit
1-bit canvas drawing
Last synced: 2 days ago
JSON representation
simple 1-bit 2D canvas drawing interface
- Host: GitHub
- URL: https://github.com/seleb/draw-1-bit
- Owner: seleb
- License: mit
- Created: 2021-05-18T17:57:33.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-05-24T18:23:17.000Z (over 3 years ago)
- Last Synced: 2024-10-11T13:51:19.517Z (about 1 month ago)
- Topics: 1-bit, canvas, drawing
- Language: TypeScript
- Homepage: https://seleb.github.io/draw-1-bit/
- Size: 188 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# `draw-1-bit`
simple 1-bit 2D canvas drawing interface
```sh
npm i draw-1-bit
```example:
```ts
import Draw1Bit from 'draw-1-bit';const draw = new Draw1Bit({ width: 16, height: 16 });
document.body.appendChild(draw.canvas);// set a pixel value
draw.fill(1, 2, true);// lock a pixel
draw.lock(1, 2, true);// retrieve a pixel value
draw.fill(1, 2);// retrieve a locked value
draw.lock(1, 2);// resize drawing grid
draw.resize(32, 32);// setup listeners
draw.addEventListener('drawstart', (event) => {
console.log('Drawing started', event.detail.x, event.detail.y);
});
draw.addEventListener('draw', (event) => {
console.log('Pixel changed during drawing', event.detail.x, event.detail.y, event.detail.value);
});
draw.addEventListener('drawend', (event) => {
console.log('Drawing stopped', event.detail.x, event.detail.y);
});
```