1
0
Fork 0

sparkles: Spit up front right based on settings

This commit is contained in:
Joost De Cock 2018-12-22 15:15:49 +01:00
parent f72ddf53cb
commit 275a1611f9
14 changed files with 2343 additions and 1928 deletions

View file

@ -1,31 +1,36 @@
import { calculateReduction } from "./shared";
export default part => {
// prettier-ignore
let {store, measurements, utils, sa, Point, points, Path, paths, Snippet, snippets, complete, paperless, macro, options} = part.shorthand();
const collarDelta = () => paths.collar.length() * 2 + store.get("backCollarLength") - store.get("collarLength");
// Populare store with data we need
calculateReduction(part);
store.set("frontArmholeLength", new Path()
store.set(
"frontArmholeLength",
new Path()
.move(points.armhole)
.curve(points.armholeCp2, points.armholeHollowCp1, points.armholeHollow)
.curve(points.armholeHollowCp2, points.armholePitchCp1, points.armholePitch)
.curve(
points.armholeHollowCp2,
points.armholePitchCp1,
points.armholePitch
)
.curve(points.armholePitchCp2, points.shoulderCp1, points.shoulder)
.length());
store.set("collarLength", measurements.neckCircumference * (1+options.collarEase));
.length()
);
// Waist shaping
let reduce = store.get('waistReduction');
if(reduce/4 > options.minimalDartShaping) reduce = reduce/8;
else reduce = reduce/4;
let reduce = store.get("waistReduction");
if (reduce / 4 > options.minimalDartShaping) reduce = reduce / 8;
else reduce = reduce / 4;
points.waist = points.waist.shift(180, reduce);
points.waistCp1 = points.waist.shift(-90, measurements.naturalWaistToHip * 0.5);
points.waistCp2 = points.waist.shift(90, points.armhole.dy(points.waist)/2);
points.hipsCp2 = points.hips.shift(90, points.waist.dy(points.hips)/4);
points.waistCp1 = points.waist.shift(
-90,
measurements.naturalWaistToHip * 0.5
);
points.waistCp2 = points.waist.shift(90, points.armhole.dy(points.waist) / 2);
points.hipsCp2 = points.hips.shift(90, points.waist.dy(points.hips) / 4);
// Draft hem
paths.saBaseFromHips = new Path()
@ -39,10 +44,13 @@ export default part => {
.curve(points.armholePitchCp2, points.shoulderCp1, points.shoulder)
.line(points.neck)
.curve(points.neckCp2Front, points.cfNeckCp1, points.cfNeck);
switch(options.hemStyle) {
switch (options.hemStyle) {
case "baseball":
points.bballStart = points.cfHem.shiftFractionTowards(points.hem, 0.5);
points.bballEnd = points.hem.shiftFractionTowards(points.hips, options.hemCurve);
points.bballEnd = points.hem.shiftFractionTowards(
points.hips,
options.hemCurve
);
points.bballCp1 = points.bballStart.shiftFractionTowards(points.hem, 0.5);
points.bballCp2 = new Point(points.bballCp1.x, points.bballEnd.y);
paths.saBase = new Path()
@ -50,7 +58,7 @@ export default part => {
.line(points.hips)
.join(paths.saBaseFromHips);
paths.hemBase = new Path()
paths.hemBase = new Path()
.move(points.cfHem)
.line(points.bballStart)
.curve(points.bballCp1, points.bballCp2, points.bballEnd);
@ -61,11 +69,9 @@ export default part => {
to: points.cfHem,
via: points.hem,
radius: points.hips.dist(points.hem) * options.hemCurve,
prefix: "slash",
prefix: "slash"
});
paths.saBase = new Path()
.move(points.hips)
.join(paths.saBaseFromHips);
paths.saBase = new Path().move(points.hips).join(paths.saBaseFromHips);
paths.hemBase = new Path()
.move(points.cfHem)
.line(points.slashEnd)
@ -84,7 +90,10 @@ export default part => {
paths.saBaseFromHips.render = false;
paths.saBaseFromArmhole.render = false;
paths.hemBase.render = false;
paths.seam = paths.hemBase.join(paths.saBase).join(paths.saBaseFromArmhole).close().attr('class', 'fabric');
paths.seam = paths.hemBase
.join(paths.saBase)
.join(paths.saBaseFromArmhole)
.attr("class", "fabric");
// Complete pattern?
if (complete) {
@ -94,21 +103,33 @@ export default part => {
to: points.cfNeck.shift(0, 45)
});
macro("title", { at: points.title, nr: "X", title: "front" });
macro("sprinkle", {
snippet: "notch",
on: [
"waist",
"armholePitch",
"shoulder",
"neck",
"hips",
"cfHips",
"cfWaist",
"armhole",
"cfArmhole"
]
});
if(sa) {
paths.saFrench = paths.saBase.offset(sa*2).attr('class', 'fabric sa');
paths.saFromArmhole = paths.saBaseFromArmhole.offset(sa).attr('class', 'fabric sa');
paths.hemSa = paths.hemBase.offset(sa*3).attr('class', 'fabric sa');
if (sa) {
paths.saFrench = paths.saBase.offset(sa * 2).attr("class", "fabric sa");
paths.saFromArmhole = paths.saBaseFromArmhole
.offset(sa)
.attr("class", "fabric sa");
paths.hemSa = paths.hemBase.offset(sa * 3).attr("class", "fabric sa");
paths.saConnect = new Path()
.move(points.cfHem)
.line(paths.hemSa.start())
.move(paths.hemSa.end())
.line(paths.saFrench.start())
.move(paths.saFrench.end())
.line(paths.saFromArmhole.start())
.move(paths.saFromArmhole.end())
.line(points.cfNeck)
.attr('class', 'fabric sa');
.attr("class", "fabric sa");
delete paths.sa;
}
}

View file

@ -0,0 +1,95 @@
export default part => {
// prettier-ignore
let {store, measurements, utils, sa, Point, points, Path, paths, Snippet, snippets, complete, paperless, macro, options} = part.shorthand();
let width = options.buttonPlacketWidth;
if (options.buttonHoleType === "seperate") {
} else {
points.placketTopIn = utils.lineIntersectsCurve(
new Point(width / -2, points.cfNeck.y + 20),
new Point(width / -2, points.cfNeck.y - 20),
points.cfNeck,
points.cfNeckCp1,
points.neckCp2Front,
points.neck
);
points.placketTopOut = points.cfNeck.shift(0, width / 2);
points.placketTopEdge = points.cfNeck.shift(0, width * 1.5);
points.placketBottomIn = points.cfHem.shift(180, width / 2);
points.placketBottomOut = points.cfHem.shift(0, width / 2);
points.placketBottomEdge = points.cfHem.shift(0, width * 1.5);
paths.seam
.line(points.placketTopEdge)
.line(points.placketBottomEdge)
.line(points.cfHem)
.close();
}
// Complete pattern?
if (complete) {
// Placket help lines
paths.frontCenter = new Path()
.move(points.cfNeck)
.line(points.cfHem)
.attr("class", "help");
paths.placketInnerFold = new Path()
.move(points.placketTopIn)
.line(points.placketBottomIn)
.attr("class", "dotted");
paths.placketOuterFold = new Path()
.move(points.placketTopOut)
.line(points.placketBottomOut)
.attr("class", "dotted");
macro("sprinkle", {
snippet: "notch",
on: [
"placketTopIn",
"placketTopOut",
"cfNeck",
"placketBottomIn",
"placketBottomOut",
"cfHem"
]
});
// Buttons
let len =
points.cfNeck.dist(points.cfHips) * (1 - options.buttonFreeLength);
for (let i = 1; i <= options.buttons; i++) {
points["button" + i] = points.cfNeck.shift(
-90,
(len / options.buttons) * i
);
snippets["button" + i] = new Snippet("button", points["button" + i]);
}
if (options.extraTopButton === "yes")
snippets.topButton = new Snippet(
"button",
points.cfNeck.shift(-90, len / options.buttons / 2)
);
// Title
macro("title", { at: points.title, nr: 1, title: "frontRight" });
if (sa) {
paths.saFromArmhole
.line(
new Point(points.placketTopEdge.x + sa, points.placketTopEdge.y - sa)
)
.line(
new Point(
points.placketBottomEdge.x + sa,
points.placketBottomEdge.y + sa * 3
)
)
.line(paths.hemSa.start());
}
}
// Paperless?
if (paperless) {
}
return part;
};

View file

@ -0,0 +1,35 @@
export default part => {
// prettier-ignore
let {store, measurements, utils, sa, Point, points, Path, paths, Snippet, snippets, complete, paperless, macro, options} = part.shorthand();
let width = options.buttonPlacketWidth;
if (options.buttonHoleType === "seperate") {
} else {
points.placketTopIn = utils.lineIntersectsCurve(
new Point(width / -2, points.cfNeck.y + 20),
new Point(width / -2, points.cfNeck.y - 20),
points.cfNeck,
points.cfNeckCp1,
points.neckCp2Front,
points.neck
);
points.placketBottomIn = points.cfHem.shift(180, width / 2);
paths.seam = paths.seam.split(points.placketTopIn)[0];
paths.seam.ops[0].to = points.placketBottomIn;
paths.seam.close().attr("class", "fabric");
}
// Complete pattern?
if (complete) {
// Title
macro("title", { at: points.title, nr: 1, title: "rightFront" });
if (sa) paths.saFromArmhole.line(paths.hemSa.start());
}
// Paperless?
if (paperless) {
}
return part;
};

View file

@ -0,0 +1,47 @@
export default part => {
// prettier-ignore
let {store, measurements, utils, sa, Point, points, Path, paths, Snippet, snippets, complete, paperless, macro, options} = part.shorthand();
let width = options.buttonPlacketWidth;
if (options.buttonHoleType === "seperate") {
} else {
points.placketTopIn = utils.lineIntersectsCurve(
new Point(width / -2, points.cfNeck.y + 20),
new Point(width / -2, points.cfNeck.y - 20),
points.cfNeck,
points.cfNeckCp1,
points.neckCp2Front,
points.neck
);
points.placketTopOut = points.cfNeck.shift(0, width / 2);
points.placketTopEdge = points.cfNeck.shift(0, width * 1.5);
points.placketBottomIn = points.cfHem.shift(180, width / 2);
points.placketBottomOut = points.cfHem.shift(0, width / 2);
points.placketBottomEdge = points.cfHem.shift(0, width * 1.5);
paths.placketInnerFold = new Path()
.move(points.placketTopIn)
.line(points.placketBottomIn)
.attr("class", "help");
paths.placketOuterFold = new Path()
.move(points.placketTopOut)
.line(points.placketBottomOut)
.attr("class", "help");
paths.tmp = new Path()
.move(points.placketTopEdge)
.line(points.placketBottomEdge);
}
// Complete pattern?
if (complete) {
if (sa) {
}
}
// Paperless?
if (paperless) {
}
return part;
};

View file

@ -0,0 +1,47 @@
export default part => {
// prettier-ignore
let {store, measurements, utils, sa, Point, points, Path, paths, Snippet, snippets, complete, paperless, macro, options} = part.shorthand();
let width = options.buttonPlacketWidth;
if (options.buttonHoleType === "seperate") {
} else {
points.placketTopIn = utils.lineIntersectsCurve(
new Point(width / -2, points.cfNeck.y + 20),
new Point(width / -2, points.cfNeck.y - 20),
points.cfNeck,
points.cfNeckCp1,
points.neckCp2Front,
points.neck
);
points.placketTopOut = points.cfNeck.shift(0, width / 2);
points.placketTopEdge = points.cfNeck.shift(0, width * 1.5);
points.placketBottomIn = points.cfHem.shift(180, width / 2);
points.placketBottomOut = points.cfHem.shift(0, width / 2);
points.placketBottomEdge = points.cfHem.shift(0, width * 1.5);
paths.placketInnerFold = new Path()
.move(points.placketTopIn)
.line(points.placketBottomIn)
.attr("class", "help");
paths.placketOuterFold = new Path()
.move(points.placketTopOut)
.line(points.placketBottomOut)
.attr("class", "help");
paths.tmp = new Path()
.move(points.placketTopEdge)
.line(points.placketBottomEdge);
}
// Complete pattern?
if (complete) {
if (sa) {
}
}
// Paperless?
if (paperless) {
}
return part;
};

View file

@ -0,0 +1,17 @@
import frontRightClassicSeperate from "./frontright-classic-seperate";
import frontRightClassicCuton from "./frontright-classic-cuton";
import frontRightSeamlessSeperate from "./frontright-seamless-seperate";
import frontRightSeamlessCuton from "./frontright-seamless-cuton";
export default part => {
let { macro, options } = part.shorthand();
macro("flip");
return options.buttonPlacketStyle === "seamless"
? options.buttonPlacketType === "seperate"
? frontRightSeamlessSeperate(part)
: frontRightSeamlessCuton(part)
: options.buttonPlacketType === "seperate"
? frontRightClassicSeperate(part)
: frontRightClassicCuton(part);
};

View file

@ -1,18 +1,16 @@
import freesewing from "freesewing";
import Brian from "@freesewing/brian";
import pluginBundle from "@freesewing/plugin-bundle";
import plugins from "@freesewing/plugin-bundle";
import flipPlugin from "@freesewing/plugin-flip";
import buttonPlugin from "@freesewing/plugin-buttons";
import config from "../config/config";
import { version } from "../package.json";
// Parts
import draftBack from "./back";
import draftFront from "./front";
import draftFrontRight from "./frontright";
//import draftSleevecap from "./sleevecap";
//import draftSleeve from "./sleeve";
// backBlock: ".Back block"
// frontBlock: ".Front block"
// sleeveBlock: ".Sleeve block"
// block: ".Block"
// frontAndBackBlock: ".Front and back block"
// frontRight: "Front right"
// frontLeft: "Front left"
// buttonPlacket: "Button placket."
@ -28,33 +26,34 @@ import draftFront from "./front";
// barrelCuff: "Barrel cuff"
// frenchCuff: "French cuff"
// Constructor boilerplate
const Simon = function(settings = false) {
freesewing.Pattern.call(this, { version: version, ...config });
this.with(pluginBundle);
if (settings !== false) this.mergeSettings(settings);
// Constructor
const Simon = function(settings) {
freesewing.Pattern.call(this, config);
this.use(plugins)
.use(flipPlugin)
.use(buttonPlugin)
.apply(settings);
return this;
};
// Inheritance boilerplate
// Set up inheritance
Simon.prototype = Object.create(freesewing.Pattern.prototype);
Simon.prototype.constructor = Simon;
// Attach per-part draft methods to prototype
Simon.prototype.draftBase = function (part) {
Simon.prototype.draftBase = function(part) {
return new Brian(this.settings).draftBase(part);
}
Simon.prototype.draftFrontBase = function (part) {
};
Simon.prototype.draftFrontBase = function(part) {
return new Brian(this.settings).draftFront(part);
}
Simon.prototype.draftBackBase = function (part) {
};
Simon.prototype.draftBackBase = function(part) {
return new Brian(this.settings).draftBack(part);
}
};
Simon.prototype.draftBack = draftBack;
Simon.prototype.draftFront = draftFront;
Simon.prototype.draftFrontRight = draftFrontRight;
//Brian.prototype.draftFront = draftFront;
//Brian.prototype.draftSleevecap = draftSleevecap;