art: Rewrote index file to avoid use of JS classes
This commit is contained in:
parent
bd7110b3da
commit
79461b3ba3
2 changed files with 316 additions and 51 deletions
|
@ -8,54 +8,62 @@ import front from "./front";
|
|||
import sleevecap from "./sleevecap";
|
||||
import sleeve from "./sleeve";
|
||||
|
||||
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];
|
||||
}
|
||||
const Brian = function(settings = false) {
|
||||
// Make this a new freesewing.Pattern instance
|
||||
freesewing.Pattern.call(this, { version: version, ...config });
|
||||
// Load plugins
|
||||
this.with(pluginBundle);
|
||||
// Inject settings passed to the constructor
|
||||
if (settings !== false) {
|
||||
for (let key of Object.keys(settings)) {
|
||||
this.settings[key] = settings[key];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Setup inheritance
|
||||
Brian.prototype = Object.create(freesewing.Pattern.prototype);
|
||||
Brian.prototype.constructor = Brian;
|
||||
|
||||
// Draft method
|
||||
Brian.prototype._draft = function() {
|
||||
this.parts.base = this.draftBase(this.createPart());
|
||||
if (!this.needs("base", true)) this.parts.base.render = false;
|
||||
if (this.needs(["back", "front", "sleeve", "sleevecap"])) {
|
||||
this.parts.back = this.draftBack(this.createPart().copy(this.parts.base));
|
||||
}
|
||||
if (this.needs(["front", "sleeve", "sleevecap"])) {
|
||||
this.parts.front = this.draftFront(this.createPart().copy(this.parts.back));
|
||||
}
|
||||
if (this.needs(["sleeve", "sleevecap"])) {
|
||||
this.parts.sleevecap = this.draftSleevecap(this.createPart());
|
||||
// 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(
|
||||
this.createPart().copy(this.parts.sleevecap)
|
||||
);
|
||||
}
|
||||
|
||||
_draft() {
|
||||
this.parts.base = this.draftBase(this.createPart());
|
||||
if (!this.needs("base", true)) this.parts.base.render = false;
|
||||
if (this.needs(["back", "front", "sleeve", "sleevecap"])) {
|
||||
this.parts.back = this.draftBack(this.createPart().copy(this.parts.base));
|
||||
}
|
||||
if (this.needs(["front", "sleeve", "sleevecap"])) {
|
||||
this.parts.front = this.draftFront(
|
||||
this.createPart().copy(this.parts.back)
|
||||
);
|
||||
}
|
||||
if (this.needs(["sleeve", "sleevecap"])) {
|
||||
this.parts.sleevecap = this.draftSleevecap(this.createPart());
|
||||
// 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(
|
||||
this.createPart().copy(this.parts.sleevecap)
|
||||
);
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
return this;
|
||||
}
|
||||
// Per-part draft methods
|
||||
Brian.prototype.draftBase = function(part) {
|
||||
return base.draft(part);
|
||||
};
|
||||
Brian.prototype.draftBack = function(part) {
|
||||
return back.draft(part);
|
||||
};
|
||||
Brian.prototype.draftFront = function(part) {
|
||||
return front.draft(part);
|
||||
};
|
||||
Brian.prototype.draftSleevecap = function(part) {
|
||||
return sleevecap.draft(part);
|
||||
};
|
||||
Brian.prototype.draftSleeve = function(part) {
|
||||
return sleeve.draft(part);
|
||||
};
|
||||
|
||||
draftBase(part) {
|
||||
return base.draft(part);
|
||||
}
|
||||
draftBack(part) {
|
||||
return back.draft(part);
|
||||
}
|
||||
draftFront(part) {
|
||||
return front.draft(part);
|
||||
}
|
||||
draftSleevecap(part) {
|
||||
return sleevecap.draft(part);
|
||||
}
|
||||
draftSleeve(part) {
|
||||
return sleeve.draft(part);
|
||||
}
|
||||
}
|
||||
export default Brian;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue