spritesmith
Advanced tools
Comparing version 0.8.1 to 0.9.0
@@ -1,5 +0,6 @@ | ||
Spritesmith Changelog | ||
===================== | ||
# spritesmith changelog | ||
0.9.0 - Added `properties` to output (i.e. spritesheet `height` and `width`) | ||
0.8.0 - Added support for `engineOpts` and upgraded `gmsmith` to `0.2.0` for `imagemagick` `engineOpt` | ||
0.7.1 - See `git log` |
{ | ||
"name": "spritesmith", | ||
"version": "0.8.1", | ||
"version": "0.9.0", | ||
"description": "Utility that takes images and creates a spritesheet with JSON sprite data", | ||
@@ -15,2 +15,3 @@ "main": "src/smith.js", | ||
"author": "Todd Wolfson <todd@twolfson.com>", | ||
"contributors": "Alex Bain <alex@alexba.in", | ||
"license": "MIT", | ||
@@ -34,2 +35,2 @@ "dependencies": { | ||
} | ||
} | ||
} |
@@ -54,2 +54,5 @@ Spritesmith [](https://www.gittip.com/twolfson/) | ||
* @returns {Object} callback[1].coordinates Map from file name to an object containing x, y, height, and width information about the source image | ||
* @returns {Object} callback[1].properties Properties about the spritesheet itself | ||
* @returns {Object} callback[1].properties.width Width of the spritesheet | ||
* @returns {Object} callback[1].properties.height Height of the spritesheet | ||
*/ | ||
@@ -97,2 +100,3 @@ ``` | ||
result.coordinates; // Object mapping filename to {x, y, width, height} of image | ||
result.properties; // Object with metadata about spritesheet {width, height} | ||
}); | ||
@@ -99,0 +103,0 @@ ``` |
@@ -45,2 +45,3 @@ // Load in modules and set up routes | ||
'has the proper coordinates': 'assertCoordinates', | ||
'has the proper properties': 'assertProps', | ||
'when converted from left to right': [function () { | ||
@@ -95,2 +96,3 @@ this.namespace = 'leftRight.'; | ||
fs.writeFileSync(__dirname + '/actual_files/' + namespace + 'coordinates.json', JSON.stringify(result.coordinates, null, 4)); | ||
fs.writeFileSync(__dirname + '/actual_files/' + namespace + 'properties.json', JSON.stringify(result.properties, null, 4)); | ||
} | ||
@@ -132,3 +134,11 @@ | ||
assert.deepEqual(expectedCoords, normCoords, "Actual coordinates do not match expected coordinates"); | ||
}, | ||
assertProps: function () { | ||
// Load in the properties | ||
var actualProps = this.result.properties, | ||
expectedProps = require(expectedDir + '/' + this.namespace + 'properties.json'); | ||
// Assert that the returned properties equals the expected properties | ||
assert.deepEqual(expectedProps, actualProps, "Actual properties do not match expected properties"); | ||
} | ||
}; | ||
}; |
@@ -6,7 +6,9 @@ // Generate basic outlines | ||
"renders a top-down spritesheet": true, | ||
"has the proper coordinates": true | ||
"has the proper coordinates": true, | ||
"has the proper properties": true | ||
}, | ||
"when converted from left to right": { | ||
"renders a left-right spritesheet": true, | ||
"has the proper coordinates": true | ||
"has the proper coordinates": true, | ||
"has the proper properties": true | ||
} | ||
@@ -18,3 +20,4 @@ } | ||
"renders an empty spritesheet": true, | ||
"returns an empty coordinate mapping": true | ||
"returns an empty coordinate mapping": true, | ||
"has the proper properties": true | ||
} | ||
@@ -48,2 +51,2 @@ } | ||
// Export the outlines | ||
module.exports = outlines; | ||
module.exports = outlines; |
@@ -95,6 +95,14 @@ var async = require('async'), | ||
function generateCanvas (cb) { | ||
// Grab and fallback the width/height | ||
var width = Math.max(packedObj.width || 0, 0), | ||
height = Math.max(packedObj.height || 0, 0); | ||
// Export the total width and height of the generated canvas | ||
retObj.properties = { | ||
width: width, | ||
height: height | ||
}; | ||
// If there are items, generate the canvas | ||
if (packedObj.items.length) { | ||
var width = packedObj.width, | ||
height = packedObj.height; | ||
engine.createCanvas(width, height, cb); | ||
@@ -174,2 +182,2 @@ } else { | ||
// Export Spritesmith | ||
module.exports = Spritesmith; | ||
module.exports = Spritesmith; |
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
633888
30
480
112
4