@@ -63,7 +63,7 @@ module.exports = function (opt) {
6363 var canvas = new Canvas ( layerInfo . width , layerInfo . height ) ;
6464 var ctx = canvas . getContext ( '2d' ) ;
6565 lodash . each ( layerInfo . items , function ( sprite , index ) {
66- ctx . drawImage ( sprite . meta . img , sprite . x , sprite . y , sprite . width , sprite . height ) ;
66+ ctx . drawImage ( sprite . meta . img , sprite . x + opt . margin , sprite . y + opt . margin , sprite . width - opt . margin * 2 , sprite . height - opt . margin * 2 ) ;
6767 } ) ;
6868 return canvas ;
6969 }
@@ -82,10 +82,10 @@ module.exports = function (opt) {
8282 lodash . each ( layerInfo . items , function ( sprite , index ) {
8383 sprites . push ( {
8484 'name' : sprite . meta . name ,
85- 'x' : sprite . x ,
86- 'y' : sprite . y ,
87- 'width' : sprite . width ,
88- 'height' : sprite . height ,
85+ 'x' : sprite . x + opt . margin ,
86+ 'y' : sprite . y + opt . margin ,
87+ 'width' : sprite . width - opt . margin * 2 ,
88+ 'height' : sprite . height - opt . margin * 2 ,
8989 'total_width' : layerInfo . width ,
9090 'total_height' : layerInfo . height ,
9191 'image' : sprite . meta . image
@@ -100,7 +100,8 @@ module.exports = function (opt) {
100100 total_width : sprite . canvas . width ,
101101 total_height : sprite . canvas . height
102102 } ) ;
103- lodash ( layerInfo . items ) . each ( function ( sprite , i ) {
103+
104+ lodash ( sprites ) . each ( function ( sprite , i ) {
104105 sprites [ i ] . x = Math . floor ( sprite . x / 2 ) ;
105106 sprites [ i ] . y = Math . floor ( sprite . y / 2 ) ;
106107 sprites [ i ] . width = Math . floor ( sprite . width / 2 ) ;
0 commit comments