1
0
Fork 0
freesewing/src/part.js

33 lines
693 B
JavaScript
Raw Normal View History

import { macroName } from "./utils";
import point from "./point";
import * as hooklib from "hooks";
2018-07-23 11:12:06 +00:00
function part(id) {
2018-07-23 11:12:06 +00:00
attributes = new Attributes();
this.points = {};
this.paths = {};
this.snippets = {};
this.id = id;
this.render = id.substr(0, 1) === "_" ? false : true;
this.points.origin = new point(0, 0);
for (let k in hooklib) this[k] = hooklib[k];
2018-07-23 11:12:06 +00:00
return this;
this.prototype.macroRunner = function(args) {
2018-07-23 11:12:06 +00:00
let self = this;
let data = args;
let method = function(key, data) {
2018-07-23 11:12:06 +00:00
let macro = macroName(key);
if (typeof self[macro] === "function") {
2018-07-23 11:12:06 +00:00
self[macro](data);
}
};
2018-07-23 11:12:06 +00:00
return method;
};
2018-07-23 11:12:06 +00:00
}
export default part;