1
0
Fork 0

sparkles: Initial commit

This commit is contained in:
Joost De Cock 2019-03-16 11:39:06 +01:00
parent d4eeb104e5
commit f6905dcb1e
27 changed files with 5673 additions and 2 deletions

View file

@ -0,0 +1,83 @@
/**
* This calculates a bunch of helper variables and stores them
*/
export const calculateRatios = part => {
let { store, measurements, options } = part.shorthand();
if (store.get("ratiosCalculated")) return true;
// Make sure collar height makes sense
if (options.collarHeight * 2 < options.rollLineCollarHeight) options.rollLineCollarHeight = options.collarHeight * 2;
// Calculate different values for reducing from chest to hips via waist
store.set("chest", measurements.chestCircumference * (1 + options.chestEase));
store.set("waist", measurements.naturalWaist * (1 + options.waistEase));
store.set("hips", measurements.hipsCircumference * (1 + options.hipsEase));
store.set("waistReduction", store.get("chest") - store.get("waist"));
store.set("hipsReduction", store.get("chest") - store.get("hips"));
store.set("waistReductionBack", store.get("waistReduction") * options.waistReductionRatioBack);
store.set("waistReductionFront", store.get("waistReduction") * options.waistReductionRatioFront);
store.set("waistReductionSide", store.get("waistReduction") * (1 - options.waistReductionRatioFront - options.waistReductionRatioBack));
store.set("hipsReductionBack", store.get("hipsReduction") * options.hipsReductionRatioBack);
store.set("hipsReductionFront", store.get("hipsReduction") * options.hipsReductionRatioFront);
store.set("hipsReductionSide", store.get("hipsReduction") * (1 - options.hipsReductionRatioFront - options.hipsReductionRatioBack));
store.set("ratiosCalculated", true);
// FIXME: Still needed?
// Prevent chest shaping from being 0, because that will get read as 360 degrees
// if($this->o('chestShaping') == 0) $this->setOptionIfUnset('chestShaping', 0.0001);
};
/**
* Draws the line seperating side panel (back-side boundary, aka bs)
* Note that this is without shaping, but rather the style line
* that will be the starting point for shaping the back/side seam
*
* On the back, this will be drawn as-is. On the front, it will be
* drawn, than mirrored so the part that's cut off from the back is
* added to the front (to become the side later).
*
* The optional flip parameter mirrors this for the front part
*/
export const backSideBoundary = (part, flip=false) => {
let { points, Point, paths, Path } = part.shorthand();
points.bsArmholeHollow = points.armholeHollow.clone();
points.bsArmholeHollowCp2 = points.armholeHollowCp2.rotate(90, points.armholeHollow);
points.bsWaist = new Point(
points.bsArmholeHollowCp2.x,
points.waist.y
);
points.bsHips = new Point(points.bsWaist.x, points.hips.y);
points.bsHem = new Point(points.bsWaist.x, points.hem.y);
if (flip) {
points.bsArmholeHollowCp1 = points.armholeHollowCp1.clone();
points.bsArmholeCp2 = points.armholeCp2.clone();
for (let p of [
"bsArmholeHollow",
"bsArmholeHollowCp2",
"bsWaist",
"bsHips",
"bsHem",
"bsArmholeHollowCp1",
"bsArmholeCp2"
]) {
points[p] = points[p].flipX(points.armhole);
}
}
/** Uncomment this to see the style line without shaping
*/
paths.bs = new Path()
.move(points.bsHem)
.line(points.bsWaist)
._curve(points.bsArmholeHollowCp2, points.bsArmholeHollow)
.attr("class", "stroke-xl lining lashed")
if (flip) paths.bs.curve(points.bsArmholeHollowCp1, points.bsArmholeCp2, points.armhole);
}