1
0
Fork 0

construction: More sleevecap work

This commit is contained in:
Joost De Cock 2018-08-08 14:38:19 +02:00
parent 69f724faea
commit 36b1669583
6 changed files with 32 additions and 29 deletions

View file

@ -17,7 +17,6 @@ export default {
options: [
// Constants
{ id: "shoulderSlopeReduction", val: 0, type: "constant" },
{ id: "sleevecapEase", val: 5, type: "constant" },
{ id: "collarFactor", val: 4.8, type: "constant" },
// Measures
@ -52,5 +51,6 @@ export default {
{ id: "sleevecapQ3Spread2", val: 8, type: "%", min: 0, max: 7 },
{ id: "sleevecapQ4Spread1", val: 7, type: "%", min: 0, max: 7 },
{ id: "sleevecapQ4Spread2", val: 7, type: "%", min: 0, max: 7 },
{ id: "sleevecapEase", val: 1, type: "%", min: 0, max: 10 },
]
};

View file

@ -18,9 +18,8 @@
var debug = {
name: 'debug',
hooks: {
debug: function debugPlugin(next, data) {
if(typeof data === 'string') console.log('%cDebug', 'color: #dd69dd', data);
else console.log(data);
debug: function (next, d='',e='',b='',u='',g='') {
console.log('%cDebug', 'color: #dd69dd; font-weight: bold', d,e,b,u,g);
next();
}
}

View file

@ -6,7 +6,7 @@ var back = {
let part = new pattern.Part().copy(pattern.parts.base);
// prettier-ignore
let {store, sa, Point, points, Path, paths, Snippet, snippets, final, paperless, macro} = freesewing.utils.shorthand(part);
let {store, sa, Point, points, Path, paths, Snippet, snippets, final, paperless, macro} = part.shorthand();
// Seamline
paths.seam = shared.seamLine("back", points, Path);

View file

@ -6,7 +6,7 @@ var base = {
part.render = false;
// prettier-ignore
let {measurements, options, points, paths, snippets, Path, Point, Snippet, utils, final, paperless, sa, macro} = freesewing.utils.shorthand(part);
let {measurements, options, points, paths, snippets, Path, Point, Snippet, utils, final, paperless, sa, macro} = part.shorthand();
// Center back (cb) vertical axis
points.cbNeck = new Point(

View file

@ -7,7 +7,7 @@ var front = {
let part = new pattern.Part().copy(pattern.parts.back);
// prettier-ignore
let {store, sa, Point, points, Path, paths, Snippet, snippets, options, measurements, final, paperless, macro} = freesewing.utils.shorthand(part);
let {store, sa, Point, points, Path, paths, Snippet, snippets, options, measurements, final, paperless, macro} = part.shorthand();
// Cut arm a bit deeper at the front
let deeper = measurements.chestCircumference * options.frontArmholeDeeper;

View file

@ -1,26 +1,23 @@
import freesewing from "freesewing";
/** Calculates the differece between actual and optimal sleevecap length
* Positive values mean sleevecap is longer than armhole
*/
function sleevecapDelta(store) {
// Positive values mean sleevecap is longer than armhole
return (
store.get("sleevecapLength") -
(store.get("frontArmholeLength") + store.get("backArmholeLength"))
);
return store.get("sleevecapLength") - store.get("sleevecapTarget");
}
function sleevecapAdjust(store) {
let delta = sleevecapDelta(store);
let factor = store.get("sleeveFactor");
if (delta > 50) factor = factor * 0.95;
else if (delta > 0) factor = factor * 0.995;
else if (delta < 50) factor = factor * 1.05;
else factor = factor * 1.005;
if (delta > 0) factor = factor * 0.98;
else factor = factor * 1.02;
store.set("sleeveFactor", factor);
}
function draftSleevecap(part) {
function draftSleevecap(part, run) {
// prettier-ignore
let {debug, store, measurements, options, Point, points, Path, paths} = freesewing.utils.shorthand(part);
let {debug, units, store, measurements, options, Point, points, Path, paths} = part.shorthand();
// Sleeve center axis
points.centerCap = new Point(0, 0);
points.centerWrist = new Point(
@ -40,11 +37,6 @@ function draftSleevecap(part) {
((measurements.bicepsCircumference * (1 + options.bicepsEase)) / 2) *
store.get("sleeveFactor")
);
// Make sure we draft a sleeve that fits the biceps
if (points.leftBiceps.x * -1 < measurements.bicepsCircumference / 1.95) {
points.leftBiceps.x = measurements.bicepsCircumference / 1.95;
part.debug("Warning: Forced sleeve to fit biceps");
}
points.rightBiceps = points.leftBiceps.flipX(points.centerBiceps);
// Pitch points
@ -150,27 +142,39 @@ function draftSleevecap(part) {
.line(points.rightBiceps)
.join(sleevecap, true);
// Uncomment this line to see all sleevecap iterations
//paths[run] = paths.seam;
// Store sleevecap length
store.set("sleevecapLength", sleevecap.length());
if (run === 1) {
let armholeLength =
store.get("frontArmholeLength") + store.get("backArmholeLength");
let sleevecapEase = armholeLength * options.sleevecapEase;
store.set("sleevecapEase", sleevecapEase);
store.set("sleevecapTarget", armholeLength + sleevecapEase);
debug("Sleevecap ease is", units(sleevecapEase));
}
}
var sleeve = {
draft: function(pattern) {
let part = new pattern.Part();
// prettier-ignore
let {debug, store, sa, measurements, options, Point, points, Path, paths, Snippet, snippets, final, paperless, macro} = freesewing.utils.shorthand(part);
let {debug, store, units, sa, measurements, options, Point, points, Path, paths, Snippet, snippets, final, paperless, macro} = part.shorthand();
store.set("sleeveFactor", 1);
let run = 1;
do {
draftSleevecap(part);
part.debug(
`Sleevecap draft ${run}, sleevecap delta is ${sleevecapDelta(store)}`
draftSleevecap(part, run);
debug(
`Sleevecap draft ${run}, sleevecap delta is ${units(
sleevecapDelta(store)
)}`
);
sleevecapAdjust(store);
run++;
} while (Math.abs(sleevecapDelta(store)) > 2 && run < 10);
} while (Math.abs(sleevecapDelta(store)) > 2 && run < 100);
// Anchor point for sampling
points.gridAnchor = points.origin;