Skip to content

Commit

Permalink
fixes #17
Browse files Browse the repository at this point in the history
  • Loading branch information
aslansky committed Aug 18, 2014
1 parent b30aea2 commit c1f3ee2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
13 changes: 7 additions & 6 deletions lib/css-sprite.js
Expand Up @@ -63,7 +63,7 @@ module.exports = function (opt) {
var canvas = new Canvas(layerInfo.width, layerInfo.height);
var ctx = canvas.getContext('2d');
lodash.each(layerInfo.items, function (sprite, index) {
ctx.drawImage(sprite.meta.img, sprite.x, sprite.y, sprite.width, sprite.height);
ctx.drawImage(sprite.meta.img, sprite.x + opt.margin, sprite.y + opt.margin, sprite.width - opt.margin * 2, sprite.height - opt.margin * 2);
});
return canvas;
}
Expand All @@ -82,10 +82,10 @@ module.exports = function (opt) {
lodash.each(layerInfo.items, function (sprite, index) {
sprites.push({
'name': sprite.meta.name,
'x': sprite.x,
'y': sprite.y,
'width': sprite.width,
'height': sprite.height,
'x': sprite.x + opt.margin,
'y': sprite.y + opt.margin,
'width': sprite.width - opt.margin * 2,
'height': sprite.height - opt.margin * 2,
'total_width': layerInfo.width,
'total_height': layerInfo.height,
'image': sprite.meta.image
Expand All @@ -100,7 +100,8 @@ module.exports = function (opt) {
total_width: sprite.canvas.width,
total_height: sprite.canvas.height
});
lodash(layerInfo.items).each(function (sprite, i) {

lodash(sprites).each(function (sprite, i) {
sprites[i].x = Math.floor(sprite.x / 2);
sprites[i].y = Math.floor(sprite.y / 2);
sprites[i].width = Math.floor(sprite.width / 2);
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "css-sprite",
"version": "0.8.0-beta1",
"version": "0.8.0-beta2",
"description": "css sprite generator",
"license": "MIT",
"repository": {
Expand Down

0 comments on commit c1f3ee2

Please sign in to comment.