1
0
Fork 0

tada: Initial commit

This commit is contained in:
Joost De Cock 2019-03-03 16:04:24 +01:00
parent ba89295a6f
commit a8edde019a
19 changed files with 4922 additions and 2 deletions

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/huey/.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

2
packages/huey/.npmignore Normal file
View file

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

21
packages/huey/LICENSE Normal file
View file

@ -0,0 +1,21 @@
MIT License
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
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View file

@ -1,2 +1,20 @@
# huey
Port of the Huey Hoodie pattern to JS
<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>
# freesewing / patterns / huey
Huey is a [freesewing](https://github.com/freesewing/freesewing) pattern
for a zip-up hoodie.
See [freesewing.org/patterns/huey](https://freesewing.org/patterns/huey)
for more info and examples.
## Install
```
npm i --save @freesewing/huey
```

View file

@ -0,0 +1,98 @@
import { version } from "../package.json";
export default {
name: "huey",
version: version,
measurements: [
"bicepsCircumference",
"centerBackNeckToWaist",
"chestCircumference",
"headCircumference",
"hipsCircumference",
"naturalWaist",
"naturalWaistToHip",
"neckCircumference",
"shoulderSlope",
"shoulderToShoulder",
"shoulderToWrist",
"wristCircumference"
],
dependencies: {
backBlock: "base",
frontBlock: "backBlock",
sleevecap: "frontBlock",
sleeveBlock: "sleevecap",
back: "backBlock",
front: "frontBlock",
sleeve: "sleeveBlock",
pocket: "front"
},
inject: {
backBlock: "base",
frontBlock: "backBlock",
sleeveBlock: "sleevecap",
back: "backBlock",
front: "frontBlock",
sleeve: "sleeveBlock",
pocket: "front"
},
hide: ["base", "sleevecap", "backBlock", "frontBlock", "sleeveBlock"],
parts: ["hood", "waistband", "cuff"],
options: {
// Constants
brianFitSleeve: true,
brianFitCollar: true,
collarFactor: 4.8,
// Options inherited from Brian
acrossBackFactor: { pct: 97, min: 93, max: 100 },
armholeDepthFactor: { pct: 65, min: 50, max: 70 },
backNeckCutout: { pct: 5, min: 2, max: 8 },
bicepsEase: { pct: 20, min: 0, max: 50 },
chestEase: { pct: 8, min: -4, max: 20 },
collarEase: { pct: 25, min: 20, max: 30 },
cuffEase: { pct: 20, min: 0, max: 200 },
frontArmholeDeeper: { pct: 0.5, min: 0, max: 1.5 },
lengthBonus: { pct: 10, min: 5, max: 15 },
shoulderEase: { pct: 0, min: -2, max: 6 },
shoulderSlopeReduction: { pct: 0, min: 0, max: 8 },
sleeveLengthBonus: { pct: 0, min: -40, max: 10 },
sleevecapEase: { pct: 0, min: 0, max: 10 },
sleevecapTopFactorX: { pct: 50, min: 25, max: 75 },
sleevecapTopFactorY: { pct: 100, min: 35, max: 165 },
sleevecapBackFactorX: { pct: 60, min: 35, max: 65 },
sleevecapBackFactorY: { pct: 33, min: 35, max: 65 },
sleevecapFrontFactorX: { pct: 55, min: 35, max: 65 },
sleevecapFrontFactorY: { pct: 33, min: 35, max: 65 },
sleevecapQ1Offset: { pct: 3, min: 0, max: 7 },
sleevecapQ2Offset: { pct: 5.5, min: 0, max: 7 },
sleevecapQ3Offset: { pct: 4.5, min: 0, max: 7 },
sleevecapQ4Offset: { pct: 1, min: 0, max: 7 },
sleevecapQ1Spread1: { pct: 6, min: 4, max: 20 },
sleevecapQ1Spread2: { pct: 15, min: 4, max: 20 },
sleevecapQ2Spread1: { pct: 15, min: 4, max: 20 },
sleevecapQ2Spread2: { pct: 10, min: 4, max: 20 },
sleevecapQ3Spread1: { pct: 10, min: 4, max: 20 },
sleevecapQ3Spread2: { pct: 8, min: 4, max: 20 },
sleevecapQ4Spread1: { pct: 7, min: 4, max: 20 },
sleevecapQ4Spread2: { pct: 7, min: 4, max: 20 },
sleeveWidthGuarantee: { pct: 90, min: 25, max: 100 },
// Options specific to Huey
ribbing: { bool: true },
pocket: { bool: true },
ribbingWidth: { pct: 10, min: 5, max: 15 },
pocketHeight: { pct: 30, min: 25, max: 35 },
pocketWidth: { pct: 60, min: 50, max: 70 },
waistEase: { pct: 12, min: 4, max: 20 },
hipsEase: { pct: 8, min: 4, max: 12 },
hoodHeight: { pct: 59, min: 55, max: 65 },
hoodCutback: { pct: 10, min: 5, max: 15 },
hoodClosure: { pct: 13.5, min: 10, max: 15 },
hoodDepth: { pct: 8.5, min: 5, max: 12 },
ribbingStretch: { pct: 15, min: 0, max: 30 },
hoodAngle: { deg: 5, min: 2, max: 8 }
}
};

85
packages/huey/index.html Normal file
View file

@ -0,0 +1,85 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Huey</title>
<style>
.two {
display: inline-block;
max-width: 95%;
margin: auto;
}
</style>
</head>
<body>
<div id="svg"></div>
<div id="svg1" class="two"></div>
<div id="svg2" class="two"></div>
<script type="text/javascript" src="../../freesewing/dist/browser.js"></script>
<script type="text/javascript" src="../brian/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="../../plugins/plugin-validate/dist/browser.js"></script>
<script type="text/javascript" src="node_modules/@freesewing/plugin-i18n/dist/browser.js"></script>
<script type="text/javascript" src="node_modules/@freesewing/models/dist/browser.js"></script>
<script>
let settings = {
"complete": true,
"idPrefix": "fs-",
"locale": "en",
"options": {
"frontStyle": "rounded",
//"hemStyle": "rounded",
},
//"embed": true,
"sa": 10,
"paperless": true,
"measurements": {
"bicepsCircumference": 335,
"centerBackNeckToWaist": 520,
"chestCircumference": 1080,
"hipsCircumference": 990,
"naturalWaist": 925,
"naturalWaistToHip": 145,
"neckCircumference": 420,
"shoulderSlope": 55,
"shoulderToShoulder": 465,
"shoulderToWrist": 680,
"wristCircumference": 190,
"shoulderToElbow": 410,
"headCircumference": 590
},
};
var pattern = new freesewing.patterns.huey(settings);
pattern.use(freesewing.plugins.theme);
pattern.use(freesewing.plugins.designer);
pattern.use(freesewing.plugins.validate);
pattern.draft();
//pattern.sampleOption("pocketHeight");
document.getElementById("svg1").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>

3739
packages/huey/package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,80 @@
{
"version": "0.0.1",
"name": "@freesewing/huey",
"description": "Freesewing pattern for a zip-up hoodie with optional front pockets",
"author": "Joost De Cock <joost@decock.org> (https://github.com/joostdecock)",
"license": "MIT",
"homepage": "https://github.com/freesewing/huey#readme",
"repository": "github:freesewing/huey",
"bugs": {
"url": "https://github.com/freesewing/huey/issues"
},
"keywords": [
"freesewing",
"block",
"sloper",
"sewing"
],
"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": "nodemon -w src -w config --exec 'rollup -c rollup.js -o dist/browser.js -f iife -m true -n freesewing_patterns_huey --footer \"freesewing.patterns.huey = freesewing_patterns_huey;\"'",
"browserbuild": "rollup -c rollup.js -o dist/browser.js -f iife -m true -n freesewing_patterns_huey --footer 'freesewing.patterns.huey = freesewing_patterns_huey;'",
"nodebuild": "rollup -c rollup.js -o dist/index.js -f cjs -m true",
"modulebuild": "rollup -c rollup.js -o dist/index.mjs -f es -m true",
"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/brian": "latest",
"@freesewing/plugin-bundle": "latest",
"freesewing": "latest"
},
"devDependencies": {
"@babel/core": "latest",
"@freesewing/antman": "latest",
"@freesewing/models": "latest",
"@freesewing/plugin-debug": "latest",
"@freesewing/plugin-designer": "latest",
"@freesewing/plugin-i18n": "latest",
"@freesewing/plugin-theme": "latest",
"@freesewing/plugin-validate": "latest",
"eslint": "latest",
"eslint-config-prettier": "latest",
"eslint-plugin-prettier": "latest",
"husky": "latest",
"lint-staged": "latest",
"prettier": "latest",
"rimraf": "latest",
"rollup": "latest",
"rollup-plugin-babel": "latest",
"rollup-plugin-babel-minify": "latest",
"rollup-plugin-json": "latest",
"rollup-plugin-node-resolve": "latest"
},
"files": [
"dist/*",
"README.md",
"package-lock.json",
"package.json"
]
}

26
packages/huey/rollup.js Normal file
View file

@ -0,0 +1,26 @@
import babel from "rollup-plugin-babel";
import resolve from "rollup-plugin-node-resolve";
import json from "rollup-plugin-json";
import minify from "rollup-plugin-babel-minify";
import { name, version, description, author, license } from "./package.json";
export default {
input: "src/index.js",
plugins: [
resolve({ browser: true }),
json(),
babel({ exclude: "node_modules/**" }),
minify({
comments: false,
sourceMap: true,
banner: `/**\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"
}
}
};

94
packages/huey/src/back.js Normal file
View file

@ -0,0 +1,94 @@
import { sharedDimensions } from "./shared";
export default function(part) {
let {
store,
macro,
Point,
Path,
points,
paths,
complete,
paperless,
snippets,
Snippet,
sa,
options,
measurements
} = part.shorthand();
// Clear paths from Brian
for (let p of Object.keys(paths)) delete paths[p];
// Shorten body to take ribbing into account
if (options.ribbing) {
let rh =
options.ribbingWidth *
(measurements.centerBackNeckToWaist + measurements.naturalWaistToHip);
for (let p of ["hem", "cbHem"]) points[p] = points[p].shift(90, rh);
store.set("ribbingHeight", rh);
}
// Shape side seam
points.waist.x = (measurements.naturalWaist * (1 + options.waistEase)) / 4;
points.hips.x = (measurements.hipsCircumference * (1 + options.hipsEase)) / 4;
points.hem.x = points.hips.x;
// Store length of the neck seam
store.set(
"backNeckSeamLength",
new Path()
.move(points.neck)
.curve_(points.neckCp2, points.cbNeck)
.length()
);
// Paths
paths.saBase = new Path()
.move(points.hem)
.curve_(points.waist, points.armhole)
.curve(points.armholeCp2, points.armholeHollowCp1, points.armholeHollow)
.curve(points.armholeHollowCp2, points.armholePitchCp1, points.armholePitch)
.curve(points.armholePitchCp2, points.shoulderCp1, points.shoulder)
.line(points.neck)
.curve_(points.neckCp2, points.cbNeck)
.attr("class", "note stroke-xxl");
paths.hemBase = new Path()
.move(points.cbHem)
.line(points.hem)
.attr("class", "note stroke-xxl");
paths.saBase.render = false;
paths.hemBase.render = false;
paths.seam = paths.saBase
.clone()
.line(points.cbHem)
.join(paths.hemBase)
.close()
.attr("class", "fabric");
// Complete?
if (complete) {
macro("cutonfold", {
from: points.cbNeck,
to: points.cbHem,
grainline: true
});
if (sa) {
paths.sa = paths.hemBase
.offset(options.ribbing ? sa : 3 * sa)
.join(paths.saBase.offset(sa));
paths.sa
.move(paths.sa.end())
.line(points.cbNeck)
.move(paths.sa.start())
.line(points.cbHem)
.attr("class", "fabric sa");
}
}
// Paperless?
if (paperless) sharedDimensions(part, "back");
return part;
}

24
packages/huey/src/cuff.js Normal file
View file

@ -0,0 +1,24 @@
import { draftRibbing } from "./shared";
export default part => {
let { complete, points, measurements, options, macro } = part.shorthand();
if (!options.ribbing) return part;
draftRibbing(
part,
measurements.wristCircumference *
(1 + options.cuffEase) *
(1 - options.ribbingStretch)
);
// Complete pattern?
if (complete) {
macro("title", {
at: points.title,
nr: 7,
title: "cuff"
});
}
return part;
};

120
packages/huey/src/front.js Normal file
View file

@ -0,0 +1,120 @@
import { sharedDimensions } from "./shared";
export default function(part) {
let {
utils,
store,
macro,
Point,
Path,
points,
paths,
complete,
paperless,
snippets,
Snippet,
sa,
options,
measurements
} = part.shorthand();
// Clear paths from Brian
for (let p of Object.keys(paths)) delete paths[p];
// Shorten body to take ribbing into account
if (options.ribbing) {
for (let p of ["hem", "cfHem"])
points[p] = points[p].shift(90, store.get("ribbingHeight"));
}
// Shape side seam
points.waist.x = (measurements.naturalWaist * (1 + options.waistEase)) / 4;
points.hips.x = (measurements.hipsCircumference * (1 + options.hipsEase)) / 4;
points.hem.x = points.hips.x;
// Front pocket
points.pocketCfTop = points.cfNeck.shiftFractionTowards(
points.cfHem,
1 - options.pocketHeight
);
points.pocketTopRight = points.pocketCfTop.shift(
0,
points.waist.x * options.pocketWidth
);
points.pocketTip = new Point(
points.pocketTopRight.x * 1.2,
points.waist.y + points.waist.dy(points.hem) * 0.7
);
points.pocketHem = new Point(
points.pocketTopRight.x + points.pocketTopRight.dx(points.pocketTip) / 2,
points.hem.y
);
points.pocketTipCp2 = utils.beamsIntersect(
points.pocketTopRight,
points.pocketTopRight.shift(90, 10),
points.pocketTip,
points.pocketHem.rotate(-90, points.pocketTip)
);
// Store length of the neck seam
store.set(
"frontNeckSeamLength",
new Path()
.move(points.neck)
.curve(points.neckCp2Front, points.cfNeckCp1, points.cfNeck)
.length()
);
// Paths
paths.saBase = new Path()
.move(points.hem)
.curve_(points.waist, points.armhole)
.curve(points.armholeCp2, points.armholeHollowCp1, points.armholeHollow)
.curve(points.armholeHollowCp2, points.armholePitchCp1, points.armholePitch)
.curve(points.armholePitchCp2, points.shoulderCp1, points.shoulder)
.line(points.neck)
.curve(points.neckCp2, points.cfNeckCp1, points.cfNeck)
.attr("class", "note stroke-xxl");
paths.hemBase = new Path()
.move(points.cfHem)
.line(points.hem)
.attr("class", "note stroke-xxl");
paths.saBase.render = false;
paths.hemBase.render = false;
paths.seam = paths.saBase
.clone()
.line(points.cfHem)
.join(paths.hemBase)
.close()
.attr("class", "fabric");
// Complete?
if (complete) {
if (options.pocket) {
paths.pocket = new Path()
.move(points.pocketHem)
.line(points.pocketTip)
.curve_(points.pocketTipCp2, points.pocketTopRight)
.line(points.pocketCfTop)
.attr("class", "fabric dashed stroke-sm");
}
if (sa) {
paths.sa = paths.hemBase
.offset(options.ribbing ? sa : 3 * sa)
.join(paths.saBase.offset(sa));
paths.sa
.move(paths.sa.end())
.line(points.cfNeck)
.move(paths.sa.start())
.line(points.cfHem)
.attr("class", "fabric sa");
}
}
// Paperless?
if (paperless) sharedDimensions(part, "front");
return part;
}

115
packages/huey/src/hood.js Normal file
View file

@ -0,0 +1,115 @@
export default function(part) {
let {
store,
macro,
Point,
Path,
points,
paths,
complete,
paperless,
snippets,
Snippet,
sa,
options,
measurements
} = part.shorthand();
let base = store.get("frontNeckSeamLength") + store.get("backNeckSeamLength");
points.cfBottom = new Point(0, 0);
points.cbBottom = points.cfBottom
.shift(0, base)
.rotate(options.hoodAngle, points.cfBottom);
points.cfHeightLeft = points.cfBottom.shift(
90,
measurements.headCircumference * options.hoodHeight
);
points.cfHeightRight = points.cfHeightLeft.shift(0, base);
points.cfTop = points.cfBottom
.shift(90, measurements.headCircumference * options.hoodClosure)
.rotate(options.hoodAngle, points.cfBottom);
points.frontTop = points.cfHeightLeft.shift(
0,
measurements.headCircumference * options.hoodCutback
);
points.frontTopCp2 = new Point(points.frontTop.x, points.cfTop.y);
points.backPitch = new Point(
points.cbBottom.x + measurements.headCircumference * options.hoodDepth,
points.cfHeightRight.y * 0.6
);
points.backPitchCp1 = points.backPitch.shift(
-90,
measurements.headCircumference * 0.1
);
points.backPitchCp2 = points.backPitchCp1.flipY(points.backPitch);
// Paths
paths.seam = new Path()
.move(points.cfBottom)
.line(points.cbBottom)
._curve(points.backPitchCp1, points.backPitch)
.curve(points.backPitchCp2, points.cfHeightRight, points.frontTop)
.curve_(points.frontTopCp2, points.cfTop)
.line(points.cfBottom)
.close()
.attr("class", "fabric");
// Complete?
if (complete) {
points.logo = points.frontTop.shiftFractionTowards(points.cbBottom, 0.7);
points.title = points.frontTop.shiftFractionTowards(points.cbBottom, 0.3);
snippets.logo = new Snippet("logo", points.logo);
macro("title", {
at: points.title,
nr: 5,
title: "hood"
});
if (sa) paths.sa = paths.seam.offset(sa).attr("class", "fabric sa");
}
// Paperless?
if (paperless) {
macro("hd", {
from: points.cfBottom,
to: points.cbBottom,
y: points.cfBottom.y + sa + 15
});
macro("hd", {
from: points.cbBottom,
to: points.backPitch,
y: points.cfBottom.y + sa + 15
});
macro("hd", {
from: points.cfTop,
to: points.backPitch,
y: points.cfBottom.y + sa + 30
});
macro("hd", {
from: points.frontTop,
to: points.backPitch,
y: points.frontTop.y - sa - 15
});
macro("ld", {
from: points.cfBottom,
to: points.cfTop,
d: -15
});
macro("ld", {
from: points.cfBottom,
to: points.cbBottom,
d: 15
});
macro("vd", {
from: points.cfTop,
to: points.frontTop,
x: points.cfBottom.x - sa - 15
});
macro("vd", {
from: points.cfBottom,
to: points.frontTop,
x: points.cfBottom.x - sa - 30
});
}
return part;
}

View file

@ -0,0 +1,43 @@
import freesewing from "freesewing";
import plugins from "@freesewing/plugin-bundle";
import Brian from "@freesewing/brian";
import config from "../config";
// Parts
import draftBack from "./back";
import draftFront from "./front";
import draftSleeve from "./sleeve";
import draftPocket from "./pocket";
import draftHood from "./hood";
import draftWaistband from "./waistband";
import draftCuff from "./cuff";
// Create new design
const Huey = new freesewing.Design(config, plugins);
// Attach draft methods from Brian to prototype
Huey.prototype.draftBase = function(part) {
return new Brian(this.settings).draftBase(part);
};
Huey.prototype.draftFrontBlock = function(part) {
return new Brian(this.settings).draftFront(part);
};
Huey.prototype.draftBackBlock = function(part) {
return new Brian(this.settings).draftBack(part);
};
Huey.prototype.draftSleevecap = function(part) {
return new Brian(this.settings).draftSleevecap(part);
};
Huey.prototype.draftSleeveBlock = function(part) {
return new Brian(this.settings).draftSleeve(part);
};
// Attach own draft methods to prototype
Huey.prototype.draftBack = draftBack;
Huey.prototype.draftFront = draftFront;
Huey.prototype.draftSleeve = draftSleeve;
Huey.prototype.draftPocket = draftPocket;
Huey.prototype.draftHood = draftHood;
Huey.prototype.draftWaistband = draftWaistband;
Huey.prototype.draftCuff = draftCuff;
export default Huey;

View file

@ -0,0 +1,85 @@
export default function(part) {
let {
store,
macro,
Point,
Path,
points,
paths,
complete,
paperless,
snippets,
Snippet,
sa,
options,
measurements
} = part.shorthand();
if (!options.pocket) return part;
// Clear paths, apart from the pocket
for (let p of Object.keys(paths)) delete paths[p];
// Paths
paths.seam = new Path()
.move(points.cfHem)
.line(points.pocketHem)
.line(points.pocketTip)
.curve_(points.pocketTipCp2, points.pocketTopRight)
.line(points.pocketCfTop)
.line(points.cfHem)
.close()
.attr("class", "fabric");
// Complete?
if (complete) {
points.logo = points.pocketCfTop.shiftFractionTowards(
points.pocketHem,
0.3
);
points.title = points.pocketCfTop.shiftFractionTowards(
points.pocketHem,
0.5
);
snippets.logo = new Snippet("logo", points.logo);
macro("title", {
at: points.title,
nr: 4,
title: "pocket"
});
if (sa) {
paths.sa = paths.seam.offset(sa).attr("class", "fabric sa");
}
}
// Paperless?
if (paperless) {
macro("hd", {
from: points.cfHem,
to: points.pocketHem,
y: points.cfHem.y + sa + 15
});
macro("hd", {
from: points.cfHem,
to: points.pocketTip,
y: points.cfHem.y + sa + 30
});
macro("hd", {
from: points.pocketCfTop,
to: points.pocketTopRight,
y: points.pocketCfTop.y - sa - 15
});
macro("vd", {
from: points.cfHem,
to: points.pocketCfTop,
x: points.cfHem.x - sa - 15
});
macro("vd", {
from: points.pocketHem,
to: points.pocketTip,
x: points.pocketTip.x + sa + 15
});
}
return part;
}

179
packages/huey/src/shared.js Normal file
View file

@ -0,0 +1,179 @@
export const sharedDimensions = function(part, s) {
let {
macro,
Point,
Path,
points,
paths,
complete,
paperless,
snippets,
Snippet,
sa
} = part.shorthand();
if (s === "front") {
points.cHem = points.cfHem;
points.cNeck = points.cfNeck;
} else {
points.cHem = points.cbHem;
points.cNeck = points.cbNeck;
}
macro("hd", {
from: points.cHem,
to: points.hem,
y: points.cHem.y + 3 * sa + 15
});
macro("ld", {
from: new Point(0, points.armholePitch.y),
to: points.armholePitch
});
macro("hd", {
from: points.cNeck,
to: points.neck,
y: points.neck.y - sa - 15
});
macro("hd", {
from: points.cNeck,
to: points.shoulder,
y: points.neck.y - sa - 30
});
macro("hd", {
from: points.cNeck,
to: points.armhole,
y: points.neck.y - sa - 45
});
macro("ld", {
from: points.neck,
to: points.shoulder,
d: -15
});
macro("vd", {
from: points.hem,
to: points.armhole,
x: points.armhole.x + sa + 15
});
macro("vd", {
from: points.armhole,
to: points.armholePitch,
x: points.armhole.x + sa + 15
});
macro("vd", {
from: points.armholePitch,
to: points.shoulder,
x: points.armhole.x + sa + 15
});
macro("vd", {
from: points.armhole,
to: points.shoulder,
x: points.armhole.x + sa + 30
});
macro("vd", {
from: points.armhole,
to: points.neck,
x: points.armhole.x + sa + 45
});
macro("vd", {
from: points.cNeck,
to: points.neck,
x: points.cNeck.x - 15
});
macro("vd", {
from: points.cHem,
to: points.cNeck,
x: points.cNeck.x - 15
});
macro("vd", {
from: points.cHem,
to: points.neck,
x: points.cNeck.x - 30
});
};
export const draftRibbing = function(part, length) {
let {
store,
measurements,
options,
points,
paths,
Path,
Point,
sa,
complete,
paperless,
macro,
units
} = part.shorthand();
if (typeof store.get("ribbingHeight") === "undefined") {
store.set(
"ribbingHeight",
(measurements.centerBackNeckToWaist + measurements.naturalWaistToHip) *
options.ribbingHeight
);
}
let height = store.get("ribbingHeight");
let gap = 25;
let lead = 50;
if (length < 125) lead = length / 3;
points.topLeft = new Point(0, 0);
points.topRight = new Point(height * 2, 0);
points.leftGapStart = new Point(0, lead);
points.rightGapEnd = new Point(points.topRight.x, lead);
points.leftGapEnd = new Point(0, lead + gap);
points.rightGapStart = new Point(points.topRight.x, lead + gap);
points.bottomLeft = new Point(0, gap + 2 * lead);
points.bottomRight = new Point(points.topRight.x, gap + 2 * lead);
paths.seam = new Path()
.move(points.rightGapEnd)
.line(points.topRight)
.line(points.topLeft)
.line(points.leftGapStart)
.move(points.leftGapEnd)
.line(points.bottomLeft)
.line(points.bottomRight)
.line(points.rightGapStart)
.attr("class", "various");
paths.hint = new Path()
.move(points.leftGapStart)
.line(points.leftGapEnd)
.move(points.rightGapStart)
.line(points.rightGapEnd)
.attr("class", "various dashed");
if (complete) {
points.title = new Point(
points.bottomRight.x / 2,
points.bottomRight.y / 2
);
if (sa) {
paths.sa = new Path()
.move(points.topLeft)
.line(points.bottomLeft)
.line(points.bottomRight)
.line(points.topRight)
.line(points.topLeft)
.close()
.offset(sa)
.attr("class", "various sa");
}
macro("vd", {
from: points.bottomRight,
to: points.topRight,
x: points.topRight.x - 25,
text: units(length)
});
}
if (paperless) {
macro("hd", {
from: points.topLeft,
to: points.topRight,
y: points.topRight.y - sa - 15
});
}
};

View file

@ -0,0 +1,93 @@
export default function(part) {
let {
Point,
Path,
points,
paths,
store,
options,
measurements,
utils,
complete,
sa,
paperless,
macro
} = part.shorthand();
// Clear paths from Brian, but keep sleevecap
for (let p of Object.keys(paths)) {
if (p !== "sleevecap") delete paths[p];
}
// Shorten sleeve to take ribbing into account
if (options.ribbing) {
for (let p of ["wristLeft", "wristRight"])
points[p] = points[p].shift(90, store.get("ribbingHeight"));
}
// Paths
paths.saBase = new Path()
.move(points.wristRight)
.line(points.bicepsRight)
.join(paths.sleevecap)
.line(points.wristLeft)
.attr("class", "various stroke-xxl");
paths.hemBase = new Path()
.move(points.wristLeft)
.line(points.wristRight)
.attr("class", "various stroke-xxl");
paths.saBase.render = false;
paths.hemBase.render = false;
paths.seam = paths.saBase
.join(paths.hemBase)
.close()
.attr("class", "fabric");
// Complete?
if (complete) {
macro("grainline", {
from: new Point(0, points.wristLeft.y),
to: new Point(0, points.backPitch.y)
});
if (sa) {
if (options.ribbing) paths.sa = paths.seam.offset(sa);
else {
paths.sa = paths.saBase
.clone()
.offset(sa)
.join(paths.hemBase.offset(3 * sa))
.close();
}
paths.sa.attr("class", "fabric sa");
}
}
// Paperless?
if (paperless) {
let hemSa = sa;
if (!options.ribbing) hemSa = 3 * sa;
macro("hd", {
from: points.wristLeft,
to: points.wristRight,
y: points.wristLeft.y + hemSa + 15
});
macro("hd", {
from: points.bicepsLeft,
to: points.bicepsRight,
y: points.sleeveTip.y - sa - 15
});
macro("vd", {
from: points.wristLeft,
to: points.bicepsLeft,
x: points.bicepsLeft.x - sa - 15
});
macro("vd", {
from: points.wristLeft,
to: points.sleeveTip,
x: points.bicepsLeft.x - sa - 30
});
}
return part;
}

View file

@ -0,0 +1,23 @@
import { draftRibbing } from "./shared";
export default function(part) {
let { complete, points, measurements, options, macro } = part.shorthand();
if (!options.ribbing) return part;
draftRibbing(
part,
measurements.hipsCircumference *
(1 + options.hipsEase) *
(1 - options.ribbingStretch)
);
// Complete pattern?
if (complete) {
macro("title", {
at: points.title,
nr: 6,
title: "waistband"
});
}
return part;
}