pixelsmith
Node based engine for spritesmith built of top of get-pixels and save-pixels.
This can be used for constructing a canvas, placing images on it, and extracting the result image.
Getting Started
Install the module with: npm install pixelsmith
var Pixelsmith = require('pixelsmith');
var pixelsmith = new Pixelsmith();
pixelsmith.createImages(['img1.jpg', 'img2.png'], function handleImages (err, imgs) {
if (err) {
throw err;
}
imgs[0].width;
imgs[0].height;
var canvas = pixelsmith.createCanvas(200, 300);
canvas.addImage(imgs[0], 0, 0);
canvas.addImage(imgs[1], 50, 100);
var resultStream = canvas['export']({format: 'png'});
resultStream;
});
Documentation
This module was built to the specification for spritesmith engines.
Specification version: 2.0.0
https://github.com/twolfson/spritesmith-engine-spec/tree/2.0.0
engine.createImages(images, cb)
Our createImages
methods supports the following types of images:
- image
String
- Filepath to image - image
Object
- Vinyl object with buffer for image (uses buffer) - image
Object
- Vinyl object with stream for image (uses stream) - image
Object
- Vinyl object with null
for image (reads buffer from provided filepath)
canvas.export(options)
Our export
method provides support for the following options:
- options
Object
- background
Number[]
- rgba
array of value for background
- By default, the background is
[0, 0, 0, 0]
(transparent black) [0]
- Red value for background
[1]
- Green value for background
[2]
- Blue value for background
[3]
- Alpha/transparency value for background
- quality
Number
- Optional quality percentage for JPEG images
- This value can range from 0 to 100
Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint via npm run lint
and test via npm test
.
Donating
Support this project and others by twolfson via gratipay.
Unlicense
As of Nov 24 2014, Todd Wolfson has released this repository and its contents to the public domain.
It has been released under the UNLICENSE.