2018-12-21 18:19:21 +01:00
|
|
|
export const calculateReduction = function(part) {
|
|
|
|
let { store, measurements, options } = part.shorthand();
|
2018-12-22 17:30:12 +01:00
|
|
|
if (store.get("reduction") === true) return;
|
2018-12-21 18:19:21 +01:00
|
|
|
|
2018-12-22 17:30:12 +01:00
|
|
|
let chest = measurements.chestCircumference * (1 + options.chestEase);
|
|
|
|
let waist = measurements.naturalWaist * (1 + options.waistEase);
|
|
|
|
let hips = measurements.hipsCircumference * (1 + options.hipsEase);
|
2018-12-21 18:19:21 +01:00
|
|
|
let waistReduction = chest - waist;
|
|
|
|
let hipsReduction = chest - hips;
|
|
|
|
|
|
|
|
// If your waist > chest, this pattern is not going to work for you as-is.
|
|
|
|
if (waistReduction < 0) waistReduction = 0;
|
|
|
|
if (hipsReduction < 0) hipsReduction = 0;
|
|
|
|
store.set("waistReduction", waistReduction);
|
|
|
|
store.set("hipsReduction", hipsReduction);
|
|
|
|
store.set("reduction", true);
|
2018-12-22 17:30:12 +01:00
|
|
|
};
|
2018-12-21 18:19:21 +01:00
|
|
|
|
2018-12-23 12:13:37 +01:00
|
|
|
export const addButtons = function(
|
|
|
|
part,
|
|
|
|
origin = "cfNeck",
|
|
|
|
snippet = "button"
|
|
|
|
) {
|
2018-12-22 17:30:12 +01:00
|
|
|
let { points, options, snippets, Snippet } = part.shorthand();
|
|
|
|
let len = points.cfNeck.dist(points.cfHips) * (1 - options.buttonFreeLength);
|
|
|
|
for (let i = 1; i <= options.buttons; i++) {
|
2018-12-23 12:13:37 +01:00
|
|
|
points["button" + i] = points[origin].shift(
|
2018-12-22 17:30:12 +01:00
|
|
|
-90,
|
|
|
|
(len / options.buttons) * i
|
|
|
|
);
|
2018-12-23 12:13:37 +01:00
|
|
|
snippets[snippet + i] = new Snippet(snippet, points["button" + i]);
|
2018-12-22 17:30:12 +01:00
|
|
|
}
|
|
|
|
if (options.extraTopButton === "yes")
|
2018-12-23 12:13:37 +01:00
|
|
|
snippets["top" + snippet] = new Snippet(
|
|
|
|
snippet,
|
|
|
|
points[origin].shift(-90, len / options.buttons / 2)
|
2018-12-22 17:30:12 +01:00
|
|
|
);
|
|
|
|
};
|
2018-12-23 12:13:37 +01:00
|
|
|
|
|
|
|
export const addButtonHoles = part =>
|
|
|
|
addButtons(part, "placketCfNeck", "buttonhole");
|