/
testMultiSprite.js
executable file
·79 lines (64 loc) · 2.06 KB
/
testMultiSprite.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
var path = require('path'),
fs = require('fs'),
log = console.log;
var multiSprite = require('./../index')
/*
* cd multi-sprite/test/ ,then exec 'node testMultiSprite'
*/
var ops = {
rootFontSize: 640/16,
srcCss: 'test/web/src/css',
// List of images to add to sprite (each sub-folder generate 1 image)
srcImg: 'test/web/src/slice',
// Target css file folder, can be the same as source
destCss: 'test/web/dest/css',
// Address of target image's folder, target image's name = source folder's name
destImg: 'test/web/dest/img/sprite',
// OPTIONAL: Image placing algorithm: top-down, left-right, diagonal, alt-diagonal, binary-tree
'algorithm': 'top-down',
// OPTIONAL: Padding between imagesm
'padding': 4,
// OPTIONAL: Rendering engine: auto, canvas, gm
//'engine': 'gm',
// OPTIONAL: Preferences for resulting image
//'exportOpts': {
// // Image format (by default will use png)
// 'format': 'png',
// // Quality of image (gm only)
// 'quality': 90
//},
successCB: function () {
log('all done!')
}
}
multiSprite(ops)
//var spritesmith = require('spritesmith');
//config = {
// "engine": "gm",
// "algorithm": "binary-tree",
// "padding": 4,
// "dest": "test/web/dest/img/sprite/s4game.png",
// "exportOpts": {
// "format": "png",
// "quality": 90
// },
// padding: 4,
// src:[
// "test/web/src/slice/s4game/icon-play-disable.png",
// "test/web/src/slice/s4game/icon-play-live.png"
// ]
//}
//spritesmith(config,function(err, result){
// if (err) { console.error(err); process.abort(); return callback(err); }
// fs.writeFile(config.dest, result.image, { encoding: 'binary' })
//})
//var imageReplaces = {
// "/users/adi/duowan/github/multi-sprite/test/web/src/slice/s4game/icon-play-disable@2x.png":{
// height: 32,
// width: 44,
// sprite: "/Users/adi/duowan/github/multi-sprite/test/web/dest/img/sprite/s4game@2x.png",
// spriteWidth: 128,
// x: 0,
// y: 0
// }
//}