1 | var MapSlicer = require("./MapSlicer"),
|
2 | path = require("path");
|
3 |
|
4 | module.exports = function client(options) {
|
5 | var mapSlicer = new MapSlicer(options);
|
6 |
|
7 | mapSlicer.on("start", function(files, options) {
|
8 | console.info("Starting to process "+files+" files.");
|
9 | console.info("Single Tile Size: "+options.tileSize+"x"+options.tileSize+"px");
|
10 | });
|
11 |
|
12 | mapSlicer.on("levels", function(levels) {
|
13 | var maxLevel = levels[levels.length-1],
|
14 | minLevel = levels[0];
|
15 |
|
16 | for(var i=0; i<levels.length; ++i) {
|
17 | var level = levels[i];
|
18 | console.info("Level #"+level.level+": "+level.size+"x"+level.size+", "+level.width+"x"+level.height);
|
19 | }
|
20 | });
|
21 |
|
22 | mapSlicer.on("inputSize", function(width, height) {
|
23 | console.info("Input Size: "+width+"x"+height);
|
24 | });
|
25 |
|
26 | mapSlicer.on("error", function(err) {
|
27 | process.stdout.write("\n");
|
28 | console.error(err);
|
29 | });
|
30 |
|
31 | mapSlicer.on("progress", function(progress, total, current, file) {
|
32 | process.stdout.clearLine();
|
33 | process.stdout.cursorTo(0);
|
34 | var parts = 20,
|
35 | result = "Progress: [";
|
36 | step = 1/parts;
|
37 | for(var i=1/parts; i<1;i+=step) {
|
38 | result += (i < progress) ? "#" : " ";
|
39 | }
|
40 | process.stdout.write(result +"] "+Math.round(progress*100)+"% - Image "+current+" of "+total+" "+(file?path.relative(".",file):""));
|
41 | });
|
42 |
|
43 | mapSlicer.on("end", function() {
|
44 | process.stdout.write("\n");
|
45 | console.info("Finished processing slices.");
|
46 | });
|
47 |
|
48 | mapSlicer.start();
|
49 | }; |
\ | No newline at end of file |