-
-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
56 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Load in dependencies | ||
var fs = require('fs'); | ||
var Spritesmith = require('../'); | ||
|
||
// Generate our spritesheet | ||
var spritesmith = new Spritesmith(); | ||
spritesmith.createImages({ | ||
src: [ | ||
__dirname + '/fork.png', | ||
__dirname + '/github.png', | ||
__dirname + '/twitter.png' | ||
] | ||
}, function handleImages (err, images) { | ||
// If there was an error, throw it | ||
if (err) { | ||
throw err; | ||
} | ||
|
||
// Otherwise, log info | ||
console.log(images[0].width); // Width of image | ||
console.log(images[0].height); // Height of image | ||
|
||
// Create our result | ||
var result = spritesmith.processImages(images); | ||
console.log(JSON.stringify(result.coordinates, null, 2)); // Object mapping filename to {x, y, width, height} of image | ||
console.log(JSON.stringify(result.properties, null, 2)); // Object with metadata about spritesheet {width, height} | ||
|
||
// and output the image | ||
result.image.pipe(fs.createWriteStream(__dirname + '/getting-started-stream.png')); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters