-
Notifications
You must be signed in to change notification settings - Fork 8
/
example.js
51 lines (37 loc) · 1.03 KB
/
example.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
var SpriteData = require("./index");
var XMLObject = require("./lib/xmlobject");
var fs = require("fs");
var config = {
common: "icon",
dims: true,
layout: "diagonal",
render: {
css: true
}
};
// Create instance
var spriter = new SpriteData(config);
// Read a file however you like
var path = "./test/fixtures/fb.svg";
// var path = "./test/fixtures/xml.xml";
// var path = "./test/fixtures/hamburger.svg";
var svg = fs.readFileSync(path, "utf-8");
// var obj = new XMLObject(svg);
// console.log(obj.toString());
// var res;
// obj.root().attr()
// obj.root().attr('width')
// obj.root().attr('width', 299)
// obj.root().attr({'width': 299})
// res = obj.find('@width').forEach(function(node){
// console.log(node.value());
// node.value('984723984723897489237489237489px');
// });
// res.value('500000000000000000px');
// obj.log();
// console.log(res);
// Add the files CONTENTS only.
spriter.add(path, svg).compile(function (err, svg) {
//Do crazy-ass shit with templates etc
console.log(svg);
});