2018-07-26 10:03:19 +00:00
|
|
|
import freesewing from "freesewing";
|
2018-08-11 14:13:40 +02:00
|
|
|
import pluginBundle from "@freesewing/plugin-bundle";
|
2018-07-26 10:03:19 +00:00
|
|
|
import config from "../config/config";
|
2018-08-05 13:57:24 +02:00
|
|
|
import { version } from "../package.json";
|
2018-08-05 16:32:19 +02:00
|
|
|
import base from "./base";
|
2018-07-24 10:16:31 +00:00
|
|
|
import back from "./back";
|
2018-08-03 17:44:55 +02:00
|
|
|
import front from "./front";
|
2018-08-20 14:33:29 +02:00
|
|
|
import sleevecap from "./sleevecap";
|
2018-08-06 16:19:12 +02:00
|
|
|
import sleeve from "./sleeve";
|
2018-07-26 13:43:45 +00:00
|
|
|
|
2018-12-07 15:56:48 +01:00
|
|
|
export default class Brian extends freesewing.Pattern {
|
|
|
|
constructor(settings = false) {
|
|
|
|
super({ version: version, ...config }).with(pluginBundle);
|
|
|
|
if (settings !== false) {
|
|
|
|
for (let key of Object.keys(settings)) {
|
|
|
|
this.settings[key] = settings[key];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
_draft() {
|
2018-12-08 15:44:46 +01:00
|
|
|
this.parts.base = this.draftBase(this.createPart());
|
2018-12-07 15:56:48 +01:00
|
|
|
if (!this.needs("base", true)) this.parts.base.render = false;
|
|
|
|
if (this.needs(["back", "front", "sleeve", "sleevecap"])) {
|
2018-12-08 15:44:46 +01:00
|
|
|
this.parts.back = this.draftBack(this.createPart().copy(this.parts.base));
|
2018-12-07 15:56:48 +01:00
|
|
|
}
|
|
|
|
if (this.needs(["front", "sleeve", "sleevecap"])) {
|
2018-12-08 15:44:46 +01:00
|
|
|
this.parts.front = this.draftFront(
|
|
|
|
this.createPart().copy(this.parts.back)
|
|
|
|
);
|
2018-12-07 15:56:48 +01:00
|
|
|
}
|
|
|
|
if (this.needs(["sleeve", "sleevecap"])) {
|
2018-12-08 15:44:46 +01:00
|
|
|
this.parts.sleevecap = this.draftSleevecap(this.createPart());
|
2018-12-07 15:56:48 +01:00
|
|
|
// Don't render sleevecap unless specifically requested
|
|
|
|
if (!this.needs("sleevecap", true)) this.parts.sleevecap.render = false;
|
|
|
|
}
|
|
|
|
if (this.needs("sleeve")) {
|
|
|
|
this.parts.sleeve = this.draftSleeve(
|
2018-12-08 15:44:46 +01:00
|
|
|
this.createPart().copy(this.parts.sleevecap)
|
2018-12-07 15:56:48 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
2018-07-15 18:57:27 +02:00
|
|
|
|
2018-12-07 15:56:48 +01:00
|
|
|
draftBase(part) {
|
|
|
|
return base.draft(part);
|
2018-08-20 14:33:29 +02:00
|
|
|
}
|
2018-12-07 15:56:48 +01:00
|
|
|
draftBack(part) {
|
|
|
|
return back.draft(part);
|
2018-08-20 14:33:29 +02:00
|
|
|
}
|
2018-12-07 15:56:48 +01:00
|
|
|
draftFront(part) {
|
|
|
|
return front.draft(part);
|
2018-08-20 14:33:29 +02:00
|
|
|
}
|
2018-12-07 15:56:48 +01:00
|
|
|
draftSleevecap(part) {
|
|
|
|
return sleevecap.draft(part);
|
2018-08-20 14:33:29 +02:00
|
|
|
}
|
2018-12-07 15:56:48 +01:00
|
|
|
draftSleeve(part) {
|
|
|
|
return sleeve.draft(part);
|
|
|
|
}
|
|
|
|
}
|