https://github.com/minecraftts/buffered-image
A simple wrapper on top of node-canvas to make handling images easier
https://github.com/minecraftts/buffered-image
Last synced: 2 months ago
JSON representation
A simple wrapper on top of node-canvas to make handling images easier
- Host: GitHub
- URL: https://github.com/minecraftts/buffered-image
- Owner: minecraftts
- License: mit
- Created: 2022-10-12T00:51:59.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2022-11-08T08:31:26.000Z (over 2 years ago)
- Last Synced: 2025-02-21T14:49:49.754Z (3 months ago)
- Language: TypeScript
- Size: 13.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# buffered-image
Not to be confused with Java BufferedImages, I just couldn't think of a better name (lawl). This is just a thin wrapper on top of `node-canvas`
### Usage
```ts
import { BufferedImage } from "@minecraftts/buffered-image"const bufferedImage = new BufferedImage(200, 200);
const graphics = bufferedImage.getGraphics();graphics.fillStyle = "red";
graphics.fillRect(50, 50, 100, 100);// before querying pixels you have to do this
bufferedImage.refresh();let pixel = bufferedImage.getPixel(0, 0);
console.log(pixel); // => { r: 0, g: 0, b: 0, a: 0 }
pixel = bufferedImage.getPixel(100, 100);
console.log(pixel); // => { r: 255, g: 0, b: 0, a: 255 }
```### Installation
Run
```
npm install @minecraftts/buffered-image
```### License
Everything here is licensed under the MIT license