1
0
Fork 0

boom: Patterns are classes now and need to be instantiated

This commit is contained in:
Joost De Cock 2018-12-07 15:55:23 +01:00
parent 39088f0876
commit b9760ab58e
4 changed files with 922 additions and 918 deletions

File diff suppressed because it is too large Load diff

View file

@ -17,11 +17,11 @@ export default {
babel({ babel({
exclude: "node_modules/**" exclude: "node_modules/**"
}), }),
terser({ //terser({
output: { // output: {
preamble: `/**\n * ${name} | v${version}\n * ${description}\n * (c) ${new Date().getFullYear()} ${author}\n * @license ${license}\n */` // preamble: `/**\n * ${name} | v${version}\n * ${description}\n * (c) ${new Date().getFullYear()} ${author}\n * @license ${license}\n */`
} // }
}) //})
], ],
external: [ external: [
"freesewing", "freesewing",

View file

@ -4,7 +4,6 @@ var front = {
draft: function(part) { draft: function(part) {
// prettier-ignore // prettier-ignore
let {utils, store, sa, Point, points, Path, paths, Snippet, snippets, options, measurements, complete, paperless, macro} = part.shorthand(); let {utils, store, sa, Point, points, Path, paths, Snippet, snippets, options, measurements, complete, paperless, macro} = part.shorthand();
// Handle stretch // Handle stretch
for(let i in points) points[i].x = points[i].x * (1 - options.stretchFactor); for(let i in points) points[i].x = points[i].x * (1 - options.stretchFactor);

View file

@ -1,5 +1,5 @@
import freesewing from "freesewing"; import freesewing from "freesewing";
import brian from "@freesewing/brian"; import Brian from "@freesewing/brian";
import pluginBundle from "@freesewing/plugin-bundle"; import pluginBundle from "@freesewing/plugin-bundle";
import config from "../config/config"; import config from "../config/config";
@ -8,24 +8,29 @@ import { version } from "../package.json";
import back from "./back"; import back from "./back";
import front from "./front"; import front from "./front";
var pattern = new freesewing.Pattern({ version: version, ...config }) export default class Aaron extends freesewing.Pattern {
.with(pluginBundle);
pattern.draft = function() { constructor(settings = false) {
this.parts.base = this.draftBase(new pattern.Part()); super({ version: version, ...config }).with(pluginBundle);
if(settings !== false) {
for (let key of Object.keys(settings)) this.settings[key] = settings[key];
}
}
_draft() {
this.parts.base = this.draftBase(new this.Part());
if (!this.needs("base", true)) this.parts.base.render = false; if (!this.needs("base", true)) this.parts.base.render = false;
if (this.needs(["back", "front"])) { if (this.needs(["back", "front"])) {
this.parts.front = this.draftFront(new pattern.Part().copy(this.parts.base)); this.parts.front = this.draftFront(new this.Part().copy(this.parts.base));
} }
if (this.needs(["back"])) { if (this.needs(["back"])) {
this.parts.back = this.draftBack(new pattern.Part().copy(this.parts.front)); this.parts.back = this.draftBack(new this.Part().copy(this.parts.front));
} }
return pattern; return this;
}; };
pattern.draftBase = part => freesewing.patterns.brian.draftBase(part); draftBase(part) { return new Brian(this.settings).draftBase(part); }
pattern.draftFront = part => front.draft(part); draftFront(part) { return front.draft(part); }
pattern.draftBack = part => back.draft(part); draftBack(part) { return back.draft(part); }
}
export default pattern;