-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathconstructor.js
executable file
·39 lines (33 loc) · 1.03 KB
/
constructor.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
"use strict";
const Svg = require("./svg");
const Loader = require("./loader");
const Option = require("./option");
const Processor = require("./processor");
const constants = require("./constants");
const Potrace = function (image, options) {
if (!(this instanceof Potrace)) {
return new Potrace(image, options);
}
this.image = image;
this.canvas = undefined;
this.bitmap = undefined;
this.pathlist = new Array();
this.options = new Option(options);
return this;
};
Potrace.prototype = {
trace: async function () {
var info = this.options.all();
var load = new Loader();
this.image = await load.image(this.image);
this.bitmap = load.bitmap(this.image, info);
this.bitmap.pathlist(this.pathlist);
var process = new Processor(info, this.pathlist);
process.init();
var svg = new Svg(info, this.pathlist, this.bitmap);
var traced = svg.get();
return traced;
},
};
Object.assign(Potrace, constants);
module.exports = Potrace;