1
0
Fork 0

tada: Initial commit

This commit is contained in:
Joost De Cock 2018-09-04 16:51:39 +02:00
parent b5d269710e
commit ebf8d9ddc5
17 changed files with 8125 additions and 2 deletions

3
packages/bruce/.babelrc Normal file
View file

@ -0,0 +1,3 @@
{
"plugins": ["transform-object-rest-spread"]
}

View file

@ -0,0 +1,13 @@
# editorconfig.org
root = true
[*]
indent_size = 2
indent_style = space
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.md]
trim_trailing_whitespace = false

62
packages/bruce/.gitignore vendored Normal file
View file

@ -0,0 +1,62 @@
dist
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
# nyc test coverage
.nyc_output
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# TypeScript v1 declaration files
typings/
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
# next.js build output
.next

View file

@ -0,0 +1,2 @@
src
.editorconfig

View file

@ -1,6 +1,6 @@
MIT License
Copyright (c) 2018 freesewing
Copyright (c) 2018 Joost De Cock
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View file

@ -1,2 +1,27 @@
<p align="center">
<a title="Go to freesewing.org" href="https://freesewing.org/"><img src="https://freesewing.org/img/logo/black.svg" align="center" width="150px" alt="Freesewing logo"/></a>
</p>
<h4 align="center"><em>&nbsp;<a title="Go to freesewing.org" href="https://freesewing.org/">freesewing</a></em>
<br><sup>a library for made-to-measure sewing patterns</sup>
</h4>
<p align="center">
<a href="https://www.npmjs.com/package/@freesewing/brian"><img src="https://badgen.net/npm/v/@freesewing/brian" alt="Version"></a>
<a href="https://www.npmjs.com/package/@freesewing/brian"><img src="https://badgen.net/npm/license/@freesewing/brian" alt="License"></a>
<a href="https://gitter.im/freesewing/freesewing"><img src="https://badgen.net/badge/chat/on%20Gitter/cyan" alt="Chat on Gitter"></a>
<a href="https://freesewing.org/patrons/join"><img src="https://badgen.net/badge/become/a%20Patron/FF5B77" alt="Become a Patron"></a>
</p>
# bruce
Port of the freesewing Bruce Boxer Briefs pattern to nodejs
Bruce is a [freesewing](https://github.com/freesewing/freesewing) pattern
for a boxer briefs.
See [freesewing.org/patterns/bruce](https://freesewing.org/patterns/bruce)
for more info and examples.
## Install
```
npm i --save @freesewing/bruce
```

View file

@ -0,0 +1,47 @@
export default {
name: "bruce",
measurements: [
"hipsCircumference",
"upperLegCircumference",
"hipsToUpperLeg"
],
options: {
// Constants
/* Ratio of different parts at the hips
* Take care to keep this sum of this = 1 (side counts double) */
hipRatioFront: 0.245,
hipRatioSide: 0.22,
hipRatioBack: 0.315,
/** Ratio of different parts at the legs
* Take care to keep this sum of this = 1 */
legRatioInset: 0.3,
legRatioSide: 0.38,
legRatioBack: 0.32,
/** Gusset widht in relation to waist = 6.66% */
gussetRatio: 0.0666,
/** Part of crotch seam length that is attached
* to the inset (rest goes in the tusks) */
gussetInsetRatio: 0.6,
/** Height distribution between inset and front */
heightRatioInset: 0.65,
heightRatioFront: 0.35,
// Degrees
bulge: { deg: 20, min: 0, max: 40 },
// Millimeters
elasticWidth: { mm: 35, min: 10, max: 70 },
// Percentages
legBonus: { pct: 0, min: 0, max: 70},
rise: { pct: 35, min: -30, max: 50},
stretch: { pct: 14, min: 4, max: 24},
legStretch: { pct: 40, min: 25, max: 45},
backRise: { pct: 2.5, min: 0, max: 5},
}
};

67
packages/bruce/index.html Normal file
View file

@ -0,0 +1,67 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Bruce</title>
<script type="text/javascript" src="node_modules/freesewing/dist/browser.js"></script>
<script type="text/javascript" src="node_modules/@freesewing/plugin-bundle/dist/browser.js"></script>
<script type="text/javascript" src="dist/browser.js"></script>
<script type="text/javascript" src="node_modules/@freesewing/plugin-theme/dist/browser.js"></script>
<script type="text/javascript" src="node_modules/@freesewing/plugin-designer/dist/browser.js"></script>
<script type="text/javascript" src="node_modules/@freesewing/plugin-debug/dist/browser.js"></script>
<script type="text/javascript" src="node_modules/@freesewing/plugin-validate/dist/browser.js"></script>
<script type="text/javascript" src="node_modules/@freesewing/models/dist/browser.js"></script>
<script type="text/javascript" src="node_modules/@freesewing/antman/dist/browser.js"></script>
</head>
<body>
<div id="svg"></div>
<script>
var pattern = freesewing.patterns.bruce
.with(freesewing.plugins.debug)
.with(freesewing.plugins.theme)
.with(freesewing.plugins.designer)
.with(freesewing.plugins.validate)
;
pattern.settings.measurements = {
hipsCircumference: 985,
upperLegCircumference: 630,
hipsToUpperLeg: 220
}
// Uncomment this line to enable paperless
pattern.settings.paperless = true;
// Some default settings
pattern.settings.sa = 10;
pattern.settings.units = 'metric';
pattern.options.bulge = 15;
pattern.settings.oly = ['front'];
//pattern.sampleOption('chestEase');
//pattern.sampleMeasurement('chestCircumference');
//pattern.sampleModels(freesewing.models.men);
//pattern.sampleModels(freesewing.models.antman);
pattern.draft();
document.getElementById("svg").innerHTML = pattern.render();
function pointHover(evt) {
var point = evt.target;
var id = point.id;
var cx = point.getAttribute('x');
var cy = point.getAttribute('y');
var name = point.getAttribute('data-point');
var part = point.getAttribute('data-part');
console.log(name+' ('+cx+', '+cy+') @ '+part);
var scale = 2;
cx = cx-scale*cx;
cy = cy-scale*cy;
point.setAttribute("transform", 'matrix('+scale+', 0, 0, '+scale+', '+cx+', '+cy+')');
pointUnhover(id);
}
function pointUnhover(id) {
setTimeout(function(){
document.getElementById(id).removeAttribute("transform", '');
}, 500);
}
</script>
</body>
</html>

7145
packages/bruce/package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,86 @@
{
"version": "0.0.1",
"name": "@freesewing/bruce",
"description": "A freesewing pattern for boxer briefs",
"author": "Joost De Cock <joost@decock.org> (https://github.com/joostdecock)",
"license": "MIT",
"homepage": "https://github.com/freesewing/bruce#readme",
"repository": "github:freesewing/bruce",
"bugs": {
"url": "https://github.com/freesewing/bruce/issues"
},
"keywords": [
"freesewing",
"pattern",
"sewing",
"menswear",
"boxers"
],
"main": "dist/index.js",
"module": "dist/index.mjs",
"unpkg": "dist/browser.js",
"scripts": {
"precommit": "npm run pretty && lint-staged",
"patch": "npm version patch -m ':bookmark: v%s' && npm run build",
"minor": "npm version minor -m ':bookmark: v%s' && npm run build",
"major": "npm version major -m ':bookmark: v%s' && npm run build",
"test": "echo \"Error: no test specified\" && exit 1",
"clean": "rimraf dist",
"pretty": "npx prettier --write 'src/*.js'",
"lint": "eslint --fix 'src/*.js'",
"watch": "npx webpack --watch",
"browserbuild": "rollup -c rollup.js -o dist/browser.js -f iife -n freesewing_patterns_bruce --footer 'freesewing.patterns.bruce = freesewing_patterns_bruce;'",
"nodebuild": "rollup -c rollup.js -o dist/index.js -f cjs",
"modulebuild": "rollup -c rollup.js -o dist/index.mjs -f es",
"build": "npm run clean && npm run browserbuild && npm run nodebuild && npm run modulebuild"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"*.{js,json}": [
"prettier --write",
"git add"
]
},
"dependencies": {
"@freesewing/plugin-bundle": "0.1.8",
"freesewing": "^0.13"
},
"devDependencies": {
"@babel/core": "7.0.0-beta.56",
"@babel/plugin-proposal-object-rest-spread": "7.0.0-beta.56",
"@babel/preset-env": "7.0.0-beta.56",
"@freesewing/antman": "0.2.0",
"@freesewing/models": "0.4.0",
"@freesewing/plugin-debug": "0.0.1",
"@freesewing/plugin-designer": "0.7.1",
"@freesewing/plugin-theme": "^0.13.1",
"@freesewing/plugin-validate": "0.0.1",
"babel-core": "^6.26.3",
"babel-eslint": "^8.2.6",
"babel-loader": "^8.0.0-beta.4",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"eslint": "5.3.0",
"eslint-config-prettier": "^2.9.0",
"eslint-plugin-prettier": "^2.6.2",
"husky": "^0.14.3",
"lint-staged": "^7.2.0",
"prettier": "1.14.0",
"rimraf": "^2.6.2",
"rollup-plugin-babel": "^3.0.7",
"rollup-plugin-commonjs": "9.1.3",
"rollup-plugin-filesize": "^4.0.1",
"rollup-plugin-json": "^3.0.0",
"rollup-plugin-node-resolve": "^3.3.0",
"rollup-plugin-terser": "^1.0.1"
},
"files": [
"dist/*",
"README.md",
"package-lock.json",
"package.json"
]
}

33
packages/bruce/rollup.js Normal file
View file

@ -0,0 +1,33 @@
import { terser } from "rollup-plugin-terser";
import babel from "rollup-plugin-babel";
import resolve from "rollup-plugin-node-resolve";
import commonjs from "rollup-plugin-commonjs";
import json from "rollup-plugin-json";
import path from "path";
import { name, version, description, author, license } from "./package.json";
export default {
input: "src/index.js",
plugins: [
resolve({
browser: true
}),
json(),
commonjs(),
babel({
exclude: "node_modules/**"
}),
//terser({
// output: {
// preamble: `/**\n * ${name} | v${version}\n * ${description}\n * (c) ${new Date().getFullYear()} ${author}\n * @license ${license}\n */`
// }
//})
],
external: ["freesewing", "@freesewing/plugin-bundle"],
output: {
globals: {
freesewing: "freesewing",
"@freesewing/plugin-bundle": "freesewing.plugins.bundle"
}
}
};

148
packages/bruce/src/back.js Normal file
View file

@ -0,0 +1,148 @@
import { init } from "./shared";
var back = {
draft: function(part) {
// prettier-ignore
let {store, sa, Point, points, Path, paths, Snippet, snippets, options, measurements, final, paperless, macro, utils} = part.shorthand();
// Initialize
init(part);
// Center back
points.defaultCenter = new Point(0,0);
points.elasticCenter = new Point(0, options.rise * -1 * store.get('yScale'));
points.center = new Point(0, points.elasticCenter.y + options.elasticWidth);
// Sides top
points.sideRight = new Point(store.get('hipsBack') / 2, points.center.y);
points.sideLeft = points.sideRight.flipX(points.center);
// Gusset
points.gussetTop = new Point(0, store.get('riseLength'));
points.gussetBottom = new Point(0, points.gussetTop.y + store.get('gusset'));
points.gussetRight = new Point(store.get('gusset') / 2, points.gussetBottom.y);
points.gussetLeft = points.gussetRight.flipX(points.center);
points.gussetCpRight = new Point(points.gussetRight.x, points.gussetTop.y);
points.gussetCpLeft = new Point(points.gussetLeft.x, points.gussetTop.y);
// Find leg edge
let isect = utils.circlesIntersect(points.gussetRight, store.get('legBack'), points.sideRight, store.get('fullLength'));
points.legRight = isect[1];
points.legLeft = points.legRight.flipX(points.center);
// Store back seam length and (half of the) crotch seam length
store.set('backSeamLength', points.sideRight.dist(points.legRight));
store.set('crotchSeamLength', new Path()
.move(points.gussetTop)
.curve(points.gussetCpRight, points.gussetRight, points.gussetRight)
.length()
);
// Handle back rise
points.center = points.center.shift(90, store.get('backRise'));
points.sideRight = points.sideRight.shift(90, store.get('sideRise'));
points.sideLeft = points.sideLeft.shift(90, store.get('sideRise'));
points.centerCpRight = new Point(points.sideRight.x/2, points.center.y);
points.centerCpLeft = points.centerCpRight.flipX(points.center);
paths.seam = new Path()
.move(points.gussetTop)
.curve(points.gussetCpRight, points.gussetRight, points.gussetRight)
.line(points.legRight)
.line(points.sideRight)
.curve(points.sideRight, points.centerCpRight, points.center)
.line(points.gussetTop)
.close()
.attr('class', 'fabric');
// Final?
if (final) {
if(sa) {
let sa1 = new Path()
.move(points.legRight)
.line(points.sideRight)
.curve(points.sideRight, points.centerCpRight, points.center)
.offset(sa);
let sa2 = new Path()
.move(points.gussetTop)
.curve(points.gussetCpRight, points.gussetRight, points.gussetRight)
.offset(sa)
let hemSa = new Path()
.move(points.gussetRight)
.line(points.legRight)
.offset(sa * 2)
paths.sa = new Path()
.move(points.gussetTop)
.line(sa2.start())
.join(sa2)
.join(hemSa)
.join(sa1)
.line(points.center)
.attr('class', 'fabric sa');
}
points.title = new Point(points.sideRight.x * 0.6, points.gussetTop.y * 0.6);
macro('title', {
at: points.title,
nr: 1,
title: 'back'
});
macro('cutonfold', {
from: points.center,
to: points.gussetTop,
grainline: true
});
snippets.logo = new Snippet(
'logo',
points.title.shift(90, 50)
);
}
// Paperless?
if (paperless) {
macro('vd', {
from: points.gussetTop,
to: points.center,
x: points.center.x - 15
});
macro('vd', {
from: points.gussetRight,
to: points.center,
x: points.center.x - 30
});
macro('vd', {
from: points.legRight,
to: points.sideRight,
x: points.legRight.x + 15 + sa
});
macro('vd', {
from: points.legRight,
to: points.center,
x: points.legRight.x + 30 + sa
});
macro('hd', {
from: points.center,
to: points.sideRight,
y: points.center.y - 15 - sa
});
macro('hd', {
from: points.gussetTop,
to: points.gussetRight,
y: points.gussetRight.y + 15 + sa * 2
});
macro('hd', {
from: points.gussetTop,
to: points.legRight,
y: points.gussetRight.y + 30 + sa * 2
});
macro('ld', {
from: points.gussetRight,
to: points.legRight,
d: -15 - sa * 2
});
}
return part;
}
};
export default back;

250
packages/bruce/src/front.js Normal file
View file

@ -0,0 +1,250 @@
import { init } from "./shared";
function tuskDelta(part) {
let {Path, points, store} = part.shorthand();
let len = new Path()
.move(points.midRight)
.curve(points.curveRightCpTop, points.curveRightCpBottom, points.rightTuskRight)
.length();
return len - store.get('curve');
}
function tweakTusk(delta, part) {
let {Path, points, store} = part.shorthand();
let factor;
if (Math.abs(delta) > 2) factor = 3;
else factor = 5;
points.rightTuskRight = points.rightTuskRight.shift(90, delta/factor);
points.rightTuskLeft = points.rightTuskLeft.shift(90, delta/factor);
points.curveRightCpBottom = points.curveRightCpBottom.shift(90, delta/factor);
}
var front = {
draft: function(part) {
// prettier-ignore
let {store, sa, Point, points, Path, paths, Snippet, snippets, options, measurements, final, paperless, macro, utils, debug} = part.shorthand();
// Initialize
init(part);
points.topRight = new Point(store.get('hipsFront')/2, 0);
points.topLeft = points.topRight.flipX();
points.midMid = new Point(0, store.get('heightFront'));
points.midRight = new Point(points.topRight.x + store.get('heightFront') * 0.05, points.midMid.y);
points.midLeft = points.midRight.flipX();
// Store this length for a notch on the side part
store.set('frontNotch', points.topRight.dist(points.midRight));
points.bottomMid = new Point(0, store.get('riseLength'));
points.rightTuskRight = new Point(
store.get('gusset') * ( 1 - store.get('gussetInsetRatio') ),
points.bottomMid.y
);
points.rightTuskLeft = points.bottomMid.clone();
points.curveRightCpTop = new Point(points.midRight.x - store.get('gusset') * 1.3, points.midRight.y);
points.curveRightCpBottom = new Point(points.rightTuskRight.x, points.rightTuskRight.y - store.get('gusset')*1.3);
// Adjust tusk length to fit inset curve
let delta = tuskDelta(part);
let count = 0;
while (Math.abs(delta) > 1) { // Below 1mm is good enough
tweakTusk(delta, part);
delta = tuskDelta(part);
count++;
if(count>150) throw("We got stuck trying to calculate an optimal tusk length. Please report this.");
debug(`Tusk tweak ${count}, delta is ${delta}`);
}
debug(`After ${count} iterations, tusk curve length is ${utils.round(delta)}mm off.`);
// Adjust midMid to new length
points.bottomMid = new Point(0, points.rightTuskLeft.y);
// Front dart only if bulge > 0
if(options.bulge > 0) {
// Rotate tusk according to bulge option
for (let pid of ['curveRightCpTop', 'curveRightCpBottom', 'rightTuskRight', 'rightTuskLeft']) {
points[pid] = points[pid].rotate(options.bulge, points.midRight);
}
// Dart join point
points.dartJoin = new Point(0, points.midMid.y + 0.65 * points.midMid.dist(points.bottomMid));
// Dart control point
points.dartCpRight = new Point(0, points.dartJoin.y + points.dartJoin.dist(points.bottomMid) * (options.bulge/30));
points.dartCpRight = points.dartCpRight.rotate(options.bulge, points.dartJoin);
// Flip control point to left side
points.dartCpLeft = points.dartCpRight.flipX();
} else {
points.dartJoin = points.rightTuskLeft;
}
// Flip points to left side
points.leftTuskRight = points.rightTuskLeft.flipX();
points.leftTuskLeft = points.rightTuskRight.flipX();
points.curveLeftCpBottom = points.curveRightCpBottom.flipX();
points.curveLeftCpTop = points.curveRightCpTop.flipX();
// Handle back rise
points.topMid = new Point(0, points.topLeft.y);
points.topLeft = points.topLeft.shift(90, store.get('frontRise'));
points.topRight = points.topRight.shift(90, store.get('frontRise'));
points.topMidCpRight = new Point(points.topRight.x / 2, points.topMid.y);
points.topMidCpLeft = points.topMidCpRight.flipX();
if(options.bulge > 0) {
paths.trimBase = new Path()
.move(points.rightTuskLeft)
.curve(points.rightTuskLeft, points.dartCpRight, points.dartJoin)
.curve(points.dartCpLeft, points.leftTuskRight, points.leftTuskRight)
paths.seamStart = new Path()
.move(points.midLeft)
.line(points.topLeft)
.curve(points.topLeft, points.topMidCpLeft, points.topMid)
.curve(points.topMidCpRight, points.topRight, points.topRight)
.line(points.midRight)
.curve(points.curveRightCpTop, points.curveRightCpBottom, points.rightTuskRight)
.line(points.rightTuskLeft);
paths.seamEnd = new Path()
.move(points.leftTuskRight)
.line(points.leftTuskLeft)
.curve(points.curveLeftCpBottom, points.curveLeftCpTop, points.midLeft);
paths.seamStart.render = false;
paths.trimBase.render = false;
paths.seamEnd.render = false;
paths.seam = paths.seamStart.join(paths.trimBase).join(paths.seamEnd);
} else {
paths.seam = new Path()
.move(points.midLeft)
.line(points.topLeft)
.curve(points.topLeft, points.topMidCpLeft, points.topMid)
.curve(points.topMidCpRight, points.topRight, points.topRight)
.line(points.midRight)
.curve(points.curveRightCpTop, points.curveRightCpBottom, points.rightTuskRight)
.line(points.leftTuskLeft)
.curve(points.curveLeftCpBottom, points.curveLeftCpTop, points.midLeft);
}
paths.seam.close().attr('class', 'fabric');
// Final?
if (final) {
if(sa) {
if(options.bulge > 0) {
let saStart = paths.seamStart.offset(sa * -1);
let saTrim = paths.trimBase.offset(sa * -1).trim();
let saEnd = paths.seamEnd.offset(sa * -1);
paths.sa = saStart.join(saTrim).join(saEnd);
} else {
paths.sa = paths.seam.offset(sa * -1).trim();
}
}
macro('title', {
at: points.midMid,
nr: 2,
title: 'front'
});
macro('grainline', {
from: points.dartJoin,
to: points.topMid
});
}
// Paperless?
if (paperless) {
macro('hd', {
from: points.topLeft,
to: points.topRight,
y: points.topLeft.y - 15 - sa
});
macro('hd', {
from: points.midLeft,
to: points.midRight,
y: points.topLeft.y - 30 - sa
});
macro('vd', {
from: points.midLeft,
to: points.topMid,
x: points.midLeft.x - 15 - sa
});
macro('vd', {
from: points.midLeft,
to: points.topLeft,
x: points.midLeft.x - 30 - sa
});
if(options.bulge === 0) {
macro('hd', {
from: points.leftTuskLeft,
to: points.rightTuskRight,
y: points.leftTuskLeft.y + 15 + sa
});
macro('vd', {
from: points.leftTuskLeft,
to: points.topLeft,
x: points.midLeft.x - 45 - sa
});
} else {
macro('vd', {
from: points.leftTuskLeft,
to: points.topLeft,
x: points.midLeft.x - 45 - sa
});
macro('vd', {
from: points.leftTuskRight,
to: points.topLeft,
x: points.midLeft.x - 60 - sa
});
points.narrowRight = new Path()
.move(points.midRight)
.curve(points.curveRightCpTop, points.curveRightCpBottom, points.rightTuskRight)
.edge('left');
points.narrowLeft = new Path()
.move(points.midLeft)
.curve(points.curveLeftCpTop, points.curveLeftCpBottom, points.leftTuskLeft)
.attr('class', 'various stroke-xl lashed')
.edge('right');
macro('hd', {
from: points.narrowLeft,
to: points.narrowRight,
y: points.narrowLeft.y
});
macro('hd', {
from: points.leftTuskRight,
to: points.rightTuskLeft,
y: points.rightTuskLeft.y + 15 + sa
});
macro('hd', {
from: points.leftTuskLeft,
to: points.rightTuskRight,
y: points.rightTuskLeft.y + 30 + sa
});
macro('ld', {
from: points.rightTuskLeft,
to: points.rightTuskRight,
d: -15 - sa
});
macro('vd', {
from: points.narrowRight,
to: points.topRight,
x: points.topRight.x + 15 + sa
});
macro('vd', {
from: points.dartJoin,
to: points.topRight,
x: points.topRight.x + 30 + sa
});
}
}
return part;
}
};
export default front;

View file

@ -0,0 +1,33 @@
import freesewing from "freesewing";
import pluginBundle from "@freesewing/plugin-bundle";
import config from "../config/config";
import { version } from "../package.json";
import back from "./back";
import side from "./side";
import front from "./front";
import inset from "./inset";
var pattern = new freesewing.Pattern({ version: version, ...config }).with(
pluginBundle
);
pattern.draft = function() {
if(this.needs(['back', 'side', 'front'])) this.parts.back = this.draftBack(new pattern.Part());
if(this.needs('side')) this.parts.side = this.draftSide(new pattern.Part());
if(this.needs(['inset','front'])) this.parts.inset = this.draftInset(new pattern.Part());
if(this.needs(['front'])) this.parts.front = this.draftFront(new pattern.Part());
return pattern;
};
pattern.draftBack = part => back.draft(part);
pattern.draftSide = part => side.draft(part);
pattern.draftInset = part => inset.draft(part);
pattern.draftFront = part => front.draft(part);
export default pattern;

View file

@ -0,0 +1,82 @@
import { init } from "./shared";
var back = {
draft: function(part) {
// prettier-ignore
let {store, sa, Point, points, Path, paths, Snippet, snippets, options, measurements, final, paperless, macro, utils} = part.shorthand();
// Initialize
init(part);
// height is 73.5%
points.topLeft = new Point(0,0);
points.bottomLeft = new Point(0, store.get('heightInset'));
points.bottomRight = new Point(store.get('legInset'), points.bottomLeft.y);
points.tip = new Point(points.bottomRight.x * 1.111, points.bottomRight.y - store.get('gusset'));
points.tip = points.bottomRight.shiftTowards(
points.tip,
store.get('crotchSeamLength') - store.get('gusset') * (1-store.get('gussetInsetRatio'))
);
points.tipCpTop = new Point(store.get('gusset') * 1.2, 0);
points.tipCpBottom = points.tip.shift(points.bottomRight.angle(points.tip)+90, store.get('gusset') * 1.5);
// Store cuve length
store.set('curve', new Path()
.move(points.tip)
.curve(points.tipCpBottom, points.tipCpTop, points.topLeft)
.length()
);
paths.seam = new Path()
.move(points.topLeft)
.line(points.bottomLeft)
.line(points.bottomRight)
.line(points.tip)
.curve(points.tipCpBottom, points.tipCpTop, points.topLeft)
.close()
.attr('class', 'fabric');
// Final?
if (final) {
if(sa) paths.sa = paths.seam.offset(sa).attr('class', 'fabric sa');
points.title = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5);
macro('title', {
at: points.title.shift(-90, 15),
nr: 4,
title: 'inset'
});
macro('grainline', {
from: points.bottomLeft.shift(0, 15),
to: points.topLeft.shift(0, 15),
});
}
// Paperless?
if (paperless) {
macro('vd', {
from: points.bottomLeft,
to: points.topLeft,
x: points.topLeft.x - 15 - sa
});
macro('vd', {
from: points.bottomRight,
to: points.tip,
x: points.tip.x + 15 + sa
});
macro('hd', {
from: points.bottomLeft,
to: points.bottomRight,
y: points.bottomRight.y + 15 + sa
});
macro('hd', {
from: points.bottomLeft,
to: points.tip,
y: points.bottomRight.y + 30 + sa
});
}
return part;
}
};
export default back;

View file

@ -0,0 +1,40 @@
export function init(part) {
let {store, options, measurements, utils} = part.shorthand();
/* Set vertical scale to 1 (no stretch) */
store.setIfUnset('yScale', 1);
/* Set horizontal scale based on stretch */
store.setIfUnset('xScale', utils.stretchToScale(options.stretch));
store.setIfUnset('xScaleLegs', utils.stretchToScale(options.legStretch));
/* Ratio of parts at the hips*/
store.setIfUnset('hips', measurements.hipsCircumference * store.get('xScale'));
store.setIfUnset('hipsFront', store.get('hips') * options.hipRatioFront);
store.setIfUnset('hipsSide', store.get('hips') * options.hipRatioSide);
store.setIfUnset('hipsBack', store.get('hips') * options.hipRatioBack);
/* Ratio of parts at the legs*/
store.setIfUnset('leg', measurements.upperLegCircumference * store.get('xScaleLegs'));
store.setIfUnset('legInset', store.get('leg') * options.legRatioInset);
store.setIfUnset('legSide', store.get('leg') * options.legRatioSide);
store.setIfUnset('legBack', store.get('leg') * options.legRatioBack);
/* Gusset */
store.setIfUnset('gusset', measurements.hipsCircumference * options.gussetRatio);
store.setIfUnset('gussetInsetRatio', options.gussetInsetRatio);
/* Length helper */
store.setIfUnset('length', measurements.hipsToUpperLeg * store.get('yScale'));
store.setIfUnset('riseLength', (measurements.hipsToUpperLeg + options.rise) * store.get('yScale'));
store.setIfUnset('fullLength', (measurements.hipsToUpperLeg + options.rise) + options.legBonus * store.get('yScale'));
/* Height ratio front/inset */
store.setIfUnset('heightInset', store.get('fullLength') * options.heightRatioInset);
store.setIfUnset('heightFront', store.get('fullLength') * options.heightRatioFront);
/* Absolute amount to raise the back */
store.setIfUnset('backRise', measurements.hipsCircumference * options.backRise);
store.setIfUnset('sideRise', store.get('backRise') * 0.75);
store.setIfUnset('frontRise', store.get('backRise') * 0.25);
}

View file

@ -0,0 +1,87 @@
import { init } from "./shared";
var back = {
draft: function(part) {
// prettier-ignore
let {store, sa, Point, points, Path, paths, Snippet, snippets, options, measurements, final, paperless, macro, utils} = part.shorthand();
// Initialize
init(part);
// Top left
points.defaultTopLeft = new Point(0, 0);
points.elasticTopLeft = new Point(0, options.rise * -1 * store.get('yScale'));
points.topLeft = new Point(0, points.elasticTopLeft.y + options.elasticWidth);
// Top right
points.topRight = new Point(store.get('hipsSide'), points.topLeft.y);
// Bottom right
points.bottomRight = points.topRight.shift(-90, store.get('fullLength'));
// Find bottom left
let isect = utils.circlesIntersect(points.bottomRight, store.get('legSide'), points.topLeft, store.get('backSeamLength'));
points.bottomLeft = isect[0];
// Store side seam length
store.set('sideSeamLength', points.topRight.dist(points.bottomRight));
// Handle back rise
points.topLeft = points.topLeft.shift(90, store.get('sideRise'));
points.topRight = points.topRight.shift(90, store.get('frontRise'));
paths.seam = new Path()
.move(points.topLeft)
.line(points.topRight)
.line(points.bottomRight)
.line(points.bottomLeft)
.line(points.topLeft)
.close()
.attr('class', 'fabric');
// Final?
if (final) {
points.title = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5);
macro('title', {
at: points.title.shift(90, 30),
nr: 3,
title: 'side'
});
if(sa) {
paths.sa = paths.seam.offset(sa * -1).attr('class', 'fabric sa');
}
macro('grainline', {
from: new Point(points.bottomRight.x / 2, points.bottomRight.y),
to: new Point(points.bottomRight.x / 2, points.topRight.y)
});
}
// Paperless?
if (paperless) {
macro('vd', {
from: points.bottomLeft,
to: points.topLeft,
x: points.topLeft.x - 15 - sa
});
macro('vd', {
from: points.bottomRight,
to: points.topRight,
x: points.topRight.x + 15 + sa
});
macro('hd', {
from: points.topLeft,
to: points.topRight,
y: points.topLeft.y - 15 - sa
});
macro('hd', {
from: points.bottomLeft,
to: points.bottomRight,
y: points.bottomLeft.y + 15 + sa
});
}
return part;
}
};
export default back;