diff --git a/lib/css-sprite.js b/lib/css-sprite.js index 51eb635..932e811 100644 --- a/lib/css-sprite.js +++ b/lib/css-sprite.js @@ -134,8 +134,8 @@ module.exports = function (opt) { name: sprite.relative, type: 'sprite', image: (!opt.base64) ? url.resolve(opt.cssPath.replace(/\\/g, '/'), sprite.relative) + cachebuster : 'data:' + imageinfo(sprite.buffer).mimeType + ';base64,' + sprite.buffer.toString('base64'), - total_width: sprite.canvas.width, - total_height: sprite.canvas.height + total_width: sprite.canvas.width(), + total_height: sprite.canvas.height() }); return json2css(sprites, {'format': 'sprite', formatOpts: {'cssClass': opt.prefix, 'processor': opt.processor, 'template': opt.template}}); diff --git a/lib/templates/json.mustache b/lib/templates/json.mustache new file mode 100644 index 0000000..ab9a4f0 --- /dev/null +++ b/lib/templates/json.mustache @@ -0,0 +1,20 @@ +{{=<% %>=}}{"frames": { + <% #items %> +"<% name %>": +{ + "frame": {"x":<% x %>,"y":<% y %>,"w":<% width %>,"h":<% height %>}, + "rotated": false, + "trimmed": false, + "spriteSourceSize": {"x":0,"y":0,"w":<% width %>,"h":<% height %>}, + "sourceSize": {"w":<% width %>,"h":<% height %>} +}, +<% /items %> +"meta": { + "app": "css-sprite", + "version": "1.0", + "image": "<% sprite.name %>", + "format": "RGBA8888", + "size": {"w":<% sprite.total_width %>,"h":<% sprite.total_height %>}, + "scale": "1" +} +}<%={{ }}=%> diff --git a/lib/templates/plist.mustache b/lib/templates/plist.mustache new file mode 100644 index 0000000..4bd9e08 --- /dev/null +++ b/lib/templates/plist.mustache @@ -0,0 +1,35 @@ +{{=<% %>=}} + + + + frames + + <% #items %> + <% name %> + + frame + {{<% x %>,<% y %>},{<% width %>,<% height %>}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{<% width %>,<% height %>}} + sourceSize + {<% width %>,<% height %>} + + <% /items %> + + metadata + + format + 2 + realTextureFileName + <% sprite.name %> + size + {<% sprite.total_width %>,<% sprite.total_height %>} + textureFileName + <% sprite.name %> + + +<%={{ }}=%> diff --git a/lib/templates/sprite.js b/lib/templates/sprite.js index 8bd6755..6eac619 100644 --- a/lib/templates/sprite.js +++ b/lib/templates/sprite.js @@ -10,7 +10,9 @@ var tmpl = { 'scss': fs.readFileSync(__dirname + '/scss.mustache', 'utf8'), 'sass': fs.readFileSync(__dirname + '/sass.mustache', 'utf8'), 'less': fs.readFileSync(__dirname + '/less.mustache', 'utf8'), - 'stylus': fs.readFileSync(__dirname + '/stylus.mustache', 'utf8') + 'stylus': fs.readFileSync(__dirname + '/stylus.mustache', 'utf8'), + 'json': fs.readFileSync(__dirname + '/json.mustache', 'utf8'), + 'plist': fs.readFileSync(__dirname + '/plist.mustache', 'utf8'), }; // Define our css template fn ({items, options}) -> css