tada: Initial commit
This commit is contained in:
parent
d7d6469eca
commit
d6066f78d1
14 changed files with 7414 additions and 2 deletions
13
packages/wahid/.editorconfig
Normal file
13
packages/wahid/.editorconfig
Normal 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/wahid/.gitignore
vendored
Normal file
62
packages/wahid/.gitignore
vendored
Normal 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/wahid/.npmignore
Normal file
2
packages/wahid/.npmignore
Normal file
|
@ -0,0 +1,2 @@
|
|||
src
|
||||
.editorconfig
|
21
packages/wahid/LICENSE
Normal file
21
packages/wahid/LICENSE
Normal 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.
|
|
@ -1,2 +1,20 @@
|
|||
# wahid
|
||||
Port of the Wahid waistcoat 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> <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 / wahid
|
||||
|
||||
Wahid is a [freesewing](https://github.com/freesewing/freesewing) pattern
|
||||
for a classic fitted waistcoat.
|
||||
|
||||
See [freesewing.org/patterns/wahid](https://freesewing.org/patterns/wahid)
|
||||
for more info and examples.
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
npm i --save @freesewing/wahid
|
||||
```
|
||||
|
|
164
packages/wahid/config/index.js
Normal file
164
packages/wahid/config/index.js
Normal file
|
@ -0,0 +1,164 @@
|
|||
import { version } from "../package.json";
|
||||
|
||||
export default {
|
||||
name: "wahid",
|
||||
version,
|
||||
measurements: [
|
||||
"bicepsCircumference",
|
||||
"centerBackNeckToWaist",
|
||||
"chestCircumference",
|
||||
"naturalWaistToHip",
|
||||
"neckCircumference",
|
||||
"shoulderSlope",
|
||||
"shoulderToShoulder",
|
||||
"hipsCircumference",
|
||||
"naturalWaist",
|
||||
"shoulderToWrist",
|
||||
"wristCircumference"
|
||||
],
|
||||
dependencies: {
|
||||
backBlock: "base",
|
||||
frontBlock: "backBlock",
|
||||
front: "frontBlock"
|
||||
},
|
||||
inject: {
|
||||
backBlock: "base",
|
||||
frontBlock: "backBlock",
|
||||
front: "frontBlock"
|
||||
},
|
||||
hide: ["base", "frontBlock"],
|
||||
parts: [
|
||||
//"base",
|
||||
//"backBlock"
|
||||
//"frontBlock",
|
||||
//"waistcoatFrontBlock",
|
||||
//"front",
|
||||
//"back",
|
||||
//"frontFacing",
|
||||
//"frontLining",
|
||||
//"pocketWelt",
|
||||
//"pocketFacing",
|
||||
//"pocketBag",
|
||||
//"pocketInterfacing"
|
||||
],
|
||||
options: {
|
||||
// These are needed because Brian expects them
|
||||
brianFitSleeve: false,
|
||||
brianFitCollar: false,
|
||||
collarFactor: 4.8,
|
||||
backNeckCutout: 0.05,
|
||||
shoulderSlopeReduction: 0,
|
||||
collarEase: 0.035,
|
||||
shoulderEase: 0,
|
||||
bicepsEase: 0.15,
|
||||
armholeDepthFactor: 0.6,
|
||||
acrossBackFactor: 0.97,
|
||||
frontArmholeDeeper: 0.005,
|
||||
|
||||
// Wahid options start here
|
||||
frontOverlap: 0.01,
|
||||
pocketLocation: {
|
||||
pct: 35,
|
||||
min: 25,
|
||||
max: 45
|
||||
},
|
||||
pocketWidth: {
|
||||
pct: 9,
|
||||
max: 12,
|
||||
min: 6
|
||||
},
|
||||
weltHeight: {
|
||||
pct: 12.5,
|
||||
max: 15,
|
||||
min: 10
|
||||
},
|
||||
chestEase: {
|
||||
pct: 2,
|
||||
min: 1,
|
||||
max: 10
|
||||
},
|
||||
waistEase: {
|
||||
pct: 8,
|
||||
min: 2,
|
||||
max: 15
|
||||
},
|
||||
hipsEase: {
|
||||
pct: 8,
|
||||
min: 2,
|
||||
max: 15
|
||||
},
|
||||
lengthBonus: {
|
||||
pct: 1,
|
||||
min: 0,
|
||||
max: 5
|
||||
},
|
||||
backScyeDart: {
|
||||
pct: 2,
|
||||
min: 0,
|
||||
max: 6
|
||||
},
|
||||
frontScyeDart: {
|
||||
deg: 6,
|
||||
min: 0,
|
||||
max: 12
|
||||
},
|
||||
centerBackDart: {
|
||||
pct: 2,
|
||||
min: 0,
|
||||
max: 5
|
||||
},
|
||||
necklineDrop: {
|
||||
pct: 100,
|
||||
min: 50,
|
||||
max: 150
|
||||
},
|
||||
frontStyle: {
|
||||
dflt: "classic",
|
||||
list: ["classic", "rounded"]
|
||||
},
|
||||
hemStyle: {
|
||||
dflt: "classic",
|
||||
list: ["classic", "rounded"]
|
||||
},
|
||||
hemRadius: {
|
||||
pct: 6,
|
||||
min: 0,
|
||||
max: 10
|
||||
},
|
||||
buttons: {
|
||||
count: 6,
|
||||
min: 4,
|
||||
max: 12
|
||||
},
|
||||
neckInset: {
|
||||
pct: 3,
|
||||
min: 0,
|
||||
max: 5
|
||||
},
|
||||
backInset: {
|
||||
pct: 4,
|
||||
min: 2,
|
||||
max: 8
|
||||
},
|
||||
frontInset: {
|
||||
pct: 15,
|
||||
min: 0,
|
||||
max: 25
|
||||
},
|
||||
shoulderInset: {
|
||||
pct: 15,
|
||||
min: 0,
|
||||
max: 25
|
||||
},
|
||||
neckInset: {
|
||||
pct: 5,
|
||||
min: 0,
|
||||
max: 15
|
||||
},
|
||||
pocketAngle: {
|
||||
deg: 5,
|
||||
min: 0,
|
||||
max: 5
|
||||
}
|
||||
}
|
||||
};
|
81
packages/wahid/index.html
Normal file
81
packages/wahid/index.html
Normal file
|
@ -0,0 +1,81 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Wahid</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": {
|
||||
//"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,
|
||||
},
|
||||
};
|
||||
var pattern = new freesewing.patterns.wahid(settings);
|
||||
pattern.use(freesewing.plugins.theme);
|
||||
pattern.use(freesewing.plugins.designer);
|
||||
pattern.use(freesewing.plugins.validate);
|
||||
pattern.draft();
|
||||
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>
|
6314
packages/wahid/package-lock.json
generated
Normal file
6314
packages/wahid/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
83
packages/wahid/package.json
Normal file
83
packages/wahid/package.json
Normal file
|
@ -0,0 +1,83 @@
|
|||
{
|
||||
"version": "0.0.2",
|
||||
"name": "@freesewing/wahid",
|
||||
"description": "Freesewing pattern for a classic fitted waistcoat",
|
||||
"author": "Joost De Cock <joost@decock.org> (https://github.com/joostdecock)",
|
||||
"license": "MIT",
|
||||
"homepage": "https://github.com/freesewing/wahid#readme",
|
||||
"repository": "github:freesewing/wahid",
|
||||
"bugs": {
|
||||
"url": "https://github.com/freesewing/wahid/issues"
|
||||
},
|
||||
"keywords": [
|
||||
"freesewing",
|
||||
"pattern",
|
||||
"sewing",
|
||||
"menswear",
|
||||
"waistcoat"
|
||||
],
|
||||
"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'",
|
||||
"browserbuild": "rollup -c rollup.js -o dist/browser.js -f iife -m true -n freesewing_patterns_wahid --footer 'freesewing.patterns.wahid = freesewing_patterns_wahid;'",
|
||||
"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": "0.22.13",
|
||||
"@freesewing/plugin-bundle": "0.7.3",
|
||||
"@freesewing/plugin-buttons": "0.1.0",
|
||||
"@freesewing/plugin-round": "0.2.0",
|
||||
"freesewing": "0.30.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "7.2.2",
|
||||
"@babel/preset-env": "7.3.1",
|
||||
"@freesewing/antman": "0.2.0",
|
||||
"@freesewing/models": "0.4.0",
|
||||
"@freesewing/plugin-debug": "0.5.2",
|
||||
"@freesewing/plugin-designer": "0.10",
|
||||
"@freesewing/plugin-theme": "0.18.4",
|
||||
"@freesewing/plugin-validate": "0.4.1",
|
||||
"eslint": "5.13.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": "0.65.0",
|
||||
"rollup-plugin-babel": "4.3.2",
|
||||
"rollup-plugin-babel-minify": "7.0.0",
|
||||
"rollup-plugin-filesize": "^4.0.1",
|
||||
"rollup-plugin-json": "^3.0.0",
|
||||
"rollup-plugin-node-resolve": "^3.3.0"
|
||||
},
|
||||
"files": [
|
||||
"dist/*",
|
||||
"README.md",
|
||||
"package-lock.json",
|
||||
"package.json"
|
||||
]
|
||||
}
|
27
packages/wahid/rollup.js
Normal file
27
packages/wahid/rollup.js
Normal file
|
@ -0,0 +1,27 @@
|
|||
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 path from "path";
|
||||
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"
|
||||
}
|
||||
}
|
||||
};
|
518
packages/wahid/src/front.js
Normal file
518
packages/wahid/src/front.js
Normal file
|
@ -0,0 +1,518 @@
|
|||
import { constructMainDart, shapeSideSeam } from "./shared";
|
||||
|
||||
export default part => {
|
||||
let {
|
||||
points,
|
||||
Point,
|
||||
paths,
|
||||
Path,
|
||||
measurements,
|
||||
options,
|
||||
utils,
|
||||
macro,
|
||||
snippets,
|
||||
Snippet,
|
||||
complete,
|
||||
sa,
|
||||
paperless
|
||||
} = part.shorthand();
|
||||
|
||||
// Cleanup from Brian
|
||||
for (let i of Object.keys(paths)) delete paths[i];
|
||||
delete snippets.armholePitchNotch;
|
||||
|
||||
// Neck cutout
|
||||
points.closureTop = new Point(
|
||||
measurements.chestCircumference * options.frontOverlap * -1,
|
||||
points.armhole.y * options.necklineDrop
|
||||
);
|
||||
if (options.frontStyle === "classic")
|
||||
points.closureTopCp1 = new Point(
|
||||
points.neck.x,
|
||||
(points.armhole.y * options.necklineDrop) / 2
|
||||
);
|
||||
else points.closureTopCp1 = new Point(points.neck.x, points.p300.y);
|
||||
|
||||
// Front inset
|
||||
let shoulderLen = points.shoulder.dist(points.neck);
|
||||
let frontInset = shoulderLen * options.frontInset;
|
||||
points.armholePitch = points.armholePitch.shift(180, frontInset);
|
||||
points.armholePitchCp1 = points.armholePitchCp1.shift(180, frontInset);
|
||||
points.armholePitchCp2 = points.armholePitchCp2.shift(180, frontInset);
|
||||
points.armholeHollow = points.armholeHollow.shift(180, frontInset / 2);
|
||||
points.armholeHollowCp2 = points.armholeHollowCp2.shift(180, frontInset / 2);
|
||||
points.armholeHollowCp1 = points.armholeHollowCp1.shift(180, frontInset / 2);
|
||||
|
||||
// Shoulder inset
|
||||
points.shoulder = points.shoulder.shiftTowards(
|
||||
points.neck,
|
||||
shoulderLen * options.shoulderInset
|
||||
);
|
||||
points.shoulderCp1 = points.shoulderCp1.shift(
|
||||
points.shoulder.angle(points.neck),
|
||||
shoulderLen * options.shoulderInset
|
||||
);
|
||||
|
||||
// Neck inset
|
||||
points.neck = points.neck.shiftTowards(
|
||||
points.shoulder,
|
||||
shoulderLen * options.neckInset
|
||||
);
|
||||
points.neckCp2 = points.neck.shift(
|
||||
points.shoulder.angle(points.neck) + 90,
|
||||
shoulderLen * 0.2
|
||||
);
|
||||
|
||||
// Construct main dart
|
||||
constructMainDart(part);
|
||||
|
||||
// Shape side seam
|
||||
shapeSideSeam(part);
|
||||
|
||||
// Hem
|
||||
if (options.hemStyle === "classic") {
|
||||
// Construct cutaway
|
||||
let cutaway = points.closureTop.dx(points.hem) / 4;
|
||||
points.closureBottom = new Point(
|
||||
points.closureTop.x,
|
||||
points.hem.y - cutaway / 2
|
||||
);
|
||||
points.hemTip = new Point(
|
||||
points.closureBottom.x + cutaway,
|
||||
points.closureBottom.y + cutaway
|
||||
);
|
||||
// Shifting hem point to have a continious hem curve to work from
|
||||
let shift = points.dartHemLeft.dx(points.dartHemRight);
|
||||
points.splitHem = points.hem.shift(180, shift);
|
||||
// Split hem curve on left side of dart
|
||||
points.hemSplit = utils.curveIntersectsX(
|
||||
points.hemTip,
|
||||
points.hemTip,
|
||||
points.dartHemLeft,
|
||||
points.splitHem,
|
||||
points.dartHemLeft.x
|
||||
);
|
||||
// Split the hem curve
|
||||
let [c1, c2] = utils.splitCurve(
|
||||
points.hemTip,
|
||||
points.hemTip,
|
||||
points.dartHemLeft,
|
||||
points.splitHem,
|
||||
points.hemSplit
|
||||
);
|
||||
points.splitDartHemLeftCp1 = c1.cp2;
|
||||
points.splitDartHemRightCp2 = c2.cp1.shift(0, shift);
|
||||
points.splitHemCp1 = c2.cp2.shift(0, shift);
|
||||
points.splitDartHemLeft = utils.curveIntersectsX(
|
||||
points.hemTip,
|
||||
points.hemTip,
|
||||
points.dartHemLeft,
|
||||
points.splitHem,
|
||||
points.dartHemLeft.x
|
||||
);
|
||||
points.splitDartHemRight = points.splitDartHemLeft.shift(0, shift);
|
||||
points.lastButton = new Point(0, points.closureBottom.y);
|
||||
} else {
|
||||
points.closureBottom = new Point(points.closureTop.x, points.hem.y);
|
||||
// Draw rounded hem
|
||||
let radius = measurements.hipsCircumference * options.hemRadius;
|
||||
// Avoid radius extending beyond the dart
|
||||
if (radius > points.closureTop.dx(points.dartHemLeft))
|
||||
radius = points.closureTop.dx(points.dartHemLeft);
|
||||
macro("round", {
|
||||
from: points.closureTop,
|
||||
to: points.hem,
|
||||
via: points.closureBottom,
|
||||
radius,
|
||||
prefix: "round"
|
||||
});
|
||||
points.lastButton = new Point(0, points.roundStart.y);
|
||||
}
|
||||
|
||||
// Pockets
|
||||
let pw = measurements.hipsCircumference * options.pocketWidth; // Pocket width
|
||||
let pwh = pw * options.weltHeight; // Pocket welt height
|
||||
let pwvh = pwh / Math.cos(utils.deg2rad(options.pocketAngle)); // Pocket welt vertical height
|
||||
let pbh = pw * 1.3; // Pocket bag height
|
||||
|
||||
points.pocketTopMid = points.dartWaistCenter.shiftFractionTowards(
|
||||
points.dartHipCenter,
|
||||
options.pocketLocation
|
||||
);
|
||||
points.pocketTopMidLeft = utils.curveIntersectsY(
|
||||
points.dartWaistLeft,
|
||||
points.dartWaistLeftCpBottom,
|
||||
points.dartHipLeftCpTop,
|
||||
points.dartHipLeft,
|
||||
points.pocketTopMid.y
|
||||
);
|
||||
points.pocketBottomMidLeft = utils.curveIntersectsY(
|
||||
points.dartWaistLeft,
|
||||
points.dartWaistLeftCpBottom,
|
||||
points.dartHipLeftCpTop,
|
||||
points.dartHipLeft,
|
||||
points.pocketTopMid.y + pwvh
|
||||
);
|
||||
points.pocketTopLeft = points.pocketTopMidLeft.shift(
|
||||
180 + options.pocketAngle,
|
||||
pw / 2
|
||||
);
|
||||
points.pocketBottomLeft = points.pocketTopLeft.shift(
|
||||
options.pocketAngle - 90,
|
||||
pwh
|
||||
);
|
||||
points.pocketTopMidRight = points.pocketTopMidLeft.flipX(points.pocketTopMid);
|
||||
points.pocketBottomMidRight = points.pocketBottomMidLeft.flipX(
|
||||
points.pocketTopMid
|
||||
);
|
||||
points.pocketTopRight = points.pocketTopMidRight.shift(
|
||||
options.pocketAngle,
|
||||
pw / 2
|
||||
);
|
||||
points.pocketBottomRight = points.pocketTopRight.shift(
|
||||
options.pocketAngle - 90,
|
||||
pwh
|
||||
);
|
||||
|
||||
// Front scye dart
|
||||
points._dartWidth = points.dartTop.shiftFractionTowards(
|
||||
points.armholeHollow.rotate(options.frontScyeDart, points.dartTop),
|
||||
1.5
|
||||
);
|
||||
points.armholeHollowTop = new Path()
|
||||
.move(points.armholeHollow)
|
||||
.curve(points.armholeHollowCp2, points.armholePitchCp1, points.armholePitch)
|
||||
.intersects(new Path().move(points.dartTop).line(points._dartWidth))
|
||||
.pop();
|
||||
// Adjust control point
|
||||
points.armholeHollowCp2 = points.armholeHollowCp2.shift(
|
||||
points.armholeHollow.angle(points.armholeHollowTop),
|
||||
points.armholeHollow.dist(points.armholeHollowTop)
|
||||
);
|
||||
// Rotate front scye dart into front dart
|
||||
let toRotate = [
|
||||
"dartWaistRightCpTop",
|
||||
"dartWaistRight",
|
||||
"dartWaistRightCpBottom",
|
||||
"dartHipRightCpTop",
|
||||
"dartHipRight",
|
||||
"dartHemRight",
|
||||
"splitDartHemRight",
|
||||
"splitDartHemRightCp2",
|
||||
"splitHemCp1",
|
||||
"hem",
|
||||
"hips",
|
||||
"hipsCp2",
|
||||
"waistCp1",
|
||||
"waist",
|
||||
"waistCp2",
|
||||
"armhole",
|
||||
"armholeCp2",
|
||||
"armholeHollow",
|
||||
"pocketTopMidRight",
|
||||
"pocketBottomMidRight",
|
||||
"pocketTopRight",
|
||||
"pocketBottomRight"
|
||||
];
|
||||
for (let p of toRotate) {
|
||||
if (typeof points[p] !== "undefined")
|
||||
points[p] = points[p].rotate(options.frontScyeDart, points.dartTop);
|
||||
}
|
||||
points.armholeHollowCp1 = points.armholeHollowCp2.rotate(
|
||||
180,
|
||||
points.armholeHollow
|
||||
);
|
||||
|
||||
// Seam line
|
||||
delete paths.cutonfold;
|
||||
delete paths.saBase;
|
||||
delete paths.sa;
|
||||
if (options.hemStyle === "classic") {
|
||||
paths.saBase = new Path()
|
||||
.move(points.splitDartHemRight)
|
||||
.curve(points.splitDartHemRightCp2, points.splitHemCp1, points.hem);
|
||||
} else {
|
||||
paths.saBase = new Path().move(points.dartHemRight).line(points.hem);
|
||||
}
|
||||
paths.saBase
|
||||
.line(points.hips)
|
||||
.curve(points.hipsCp2, points.waistCp1, points.waist)
|
||||
.curve_(points.waistCp2, 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.closureTopCp1, points.closureTop);
|
||||
if (options.hemStyle === "classic") {
|
||||
paths.saBase
|
||||
.line(points.closureBottom)
|
||||
.line(points.hemTip)
|
||||
._curve(points.splitDartHemLeftCp1, points.splitDartHemLeft);
|
||||
} else {
|
||||
paths.saBase
|
||||
.line(points.roundStart)
|
||||
.curve(points.roundCp1, points.roundCp2, points.roundEnd)
|
||||
.line(points.dartHemLeft);
|
||||
}
|
||||
paths.dart = new Path()
|
||||
.move(paths.saBase.end())
|
||||
.line(points.dartHipLeft)
|
||||
.curve(
|
||||
points.dartHipLeftCpTop,
|
||||
points.dartWaistLeftCpBottom,
|
||||
points.dartWaistLeft
|
||||
)
|
||||
.curve_(points.dartWaistLeftCpTop, points.dartTop)
|
||||
._curve(points.dartWaistRightCpTop, points.dartWaistRight)
|
||||
.curve(
|
||||
points.dartWaistRightCpBottom,
|
||||
points.dartHipRightCpTop,
|
||||
points.dartHipRight
|
||||
)
|
||||
.line(paths.saBase.start());
|
||||
paths.seam = paths.saBase.join(paths.dart).attr("class", "fabric");
|
||||
paths.saBase.render = false;
|
||||
paths.dart.render = false;
|
||||
if (complete) {
|
||||
// Buttons
|
||||
points.button1 = new Point(0, points.closureTop.y);
|
||||
let delta = points.button1.dist(points.lastButton) / (options.buttons - 1);
|
||||
for (let i = 1; i <= options.buttons; i++) {
|
||||
points["button" + i] = points.button1.shift(-90, delta * (i - 1));
|
||||
if (complete) {
|
||||
snippets["button" + i] = new Snippet("button", points["button" + i]);
|
||||
snippets["buttonhole" + i] = new Snippet(
|
||||
"buttonhole",
|
||||
points["button" + i]
|
||||
).attr("data-rotate", 90);
|
||||
}
|
||||
}
|
||||
|
||||
// Facing/Lining boundary (flb)
|
||||
points.flbTop = points.neck.shiftFractionTowards(points.shoulder, 0.5);
|
||||
points.flbCp = points.dartTop.shift(
|
||||
90,
|
||||
points.dartTop.dist(points.flbTop) / 2
|
||||
);
|
||||
paths.flbFacing = new Path()
|
||||
.move(points.dartTop)
|
||||
.curve_(points.flbCp, points.flbTop)
|
||||
.attr("class", "fabric");
|
||||
paths.flbLining = paths.flbFacing.clone().attr("class", "lining dashed");
|
||||
|
||||
// Pocket path
|
||||
paths.pocket = new Path()
|
||||
.move(points.pocketTopMidLeft)
|
||||
.line(points.pocketTopLeft)
|
||||
.line(points.pocketBottomLeft)
|
||||
.line(points.pocketBottomMidLeft)
|
||||
.move(points.pocketBottomMidRight)
|
||||
.line(points.pocketBottomRight)
|
||||
.line(points.pocketTopRight)
|
||||
.line(points.pocketTopMidRight)
|
||||
.attr("class", "fabric dashed");
|
||||
|
||||
if (sa) paths.sa = paths.saBase.offset(sa).close();
|
||||
|
||||
if (paperless) {
|
||||
macro("hd", {
|
||||
from: points.closureTop,
|
||||
to: points.neck,
|
||||
y: points.neck.y - 15 - sa
|
||||
});
|
||||
macro("hd", {
|
||||
from: points.closureTop,
|
||||
to: points.shoulder,
|
||||
y: points.neck.y - 30 - sa
|
||||
});
|
||||
macro("hd", {
|
||||
from: points.closureTop,
|
||||
to: points.armhole,
|
||||
y: points.neck.y - 45 - sa
|
||||
});
|
||||
macro("ld", {
|
||||
from: points.neck,
|
||||
to: points.shoulder,
|
||||
d: 15 + sa
|
||||
});
|
||||
macro("ld", {
|
||||
from: points.neck,
|
||||
to: points.flbTop,
|
||||
d: -15
|
||||
});
|
||||
macro("vd", {
|
||||
from: points.armhole,
|
||||
to: points.shoulder,
|
||||
x: points.armhole.x + 15 + sa
|
||||
});
|
||||
macro("vd", {
|
||||
from: points.armhole,
|
||||
to: points.neck,
|
||||
x: points.armhole.x + 30 + sa
|
||||
});
|
||||
macro("vd", {
|
||||
from: points.hem,
|
||||
to: points.armhole,
|
||||
x:
|
||||
(points.armhole.x > points.hem.x ? points.armhole.x : points.hem.x) +
|
||||
15 +
|
||||
sa
|
||||
});
|
||||
macro("vd", {
|
||||
from:
|
||||
options.hemStyle === "classic"
|
||||
? points.splitDartHemRight
|
||||
: points.dartHemRight,
|
||||
to: points.armhole,
|
||||
x:
|
||||
(points.armhole.x > points.hem.x ? points.armhole.x : points.hem.x) +
|
||||
30 +
|
||||
sa
|
||||
});
|
||||
macro("vd", {
|
||||
from:
|
||||
options.hemStyle === "classic"
|
||||
? points.splitDartHemLeft
|
||||
: points.dartHemLeft,
|
||||
to: points.armhole,
|
||||
x:
|
||||
(points.armhole.x > points.hem.x ? points.armhole.x : points.hem.x) +
|
||||
45 +
|
||||
sa
|
||||
});
|
||||
macro("ld", {
|
||||
from: points.dartHemRight,
|
||||
to: points.hem,
|
||||
d: 15
|
||||
});
|
||||
if (options.hemStyle === "classic") {
|
||||
macro("hd", {
|
||||
from: points.closureBottom,
|
||||
to: points.hemTip,
|
||||
y: points.hemTip.y + 15 + sa
|
||||
});
|
||||
macro("hd", {
|
||||
from: points.closureBottom,
|
||||
to: points.splitDartHemLeft,
|
||||
y: points.hemTip.y + 30 + sa
|
||||
});
|
||||
macro("hd", {
|
||||
from: points.closureBottom,
|
||||
to: points.splitDartHemRight,
|
||||
y: points.hemTip.y + 45 + sa
|
||||
});
|
||||
macro("hd", {
|
||||
from: points.closureBottom,
|
||||
to: points.hem,
|
||||
y: points.hemTip.y + 60 + sa
|
||||
});
|
||||
macro("vd", {
|
||||
from: points.hemTip,
|
||||
to: points.closureBottom,
|
||||
x: points.closureBottom.x - 15 - sa
|
||||
});
|
||||
macro("vd", {
|
||||
from: points.hemTip,
|
||||
to: points.pocketTopMidLeft,
|
||||
x: points.closureBottom.x - 30 - sa
|
||||
});
|
||||
macro("vd", {
|
||||
from: points.hemTip,
|
||||
to: points.dartWaistLeft,
|
||||
x: points.closureBottom.x - 45 - sa
|
||||
});
|
||||
macro("vd", {
|
||||
from: points.hemTip,
|
||||
to: points.closureTop,
|
||||
x: points.closureBottom.x - 60 - sa
|
||||
});
|
||||
} else {
|
||||
macro("hd", {
|
||||
from: points.roundStart,
|
||||
to: points.roundEnd,
|
||||
y: points.roundEnd.y + 15 + sa
|
||||
});
|
||||
macro("hd", {
|
||||
from: points.roundStart,
|
||||
to: points.dartHemLeft,
|
||||
y: points.roundEnd.y + 30 + sa
|
||||
});
|
||||
macro("hd", {
|
||||
from: points.roundStart,
|
||||
to: points.dartHemRight,
|
||||
y: points.roundEnd.y + 45 + sa
|
||||
});
|
||||
macro("hd", {
|
||||
from: points.roundStart,
|
||||
to: points.hem,
|
||||
y: points.roundEnd.y + 60 + sa
|
||||
});
|
||||
macro("vd", {
|
||||
from: points.roundEnd,
|
||||
to: points.roundStart,
|
||||
x: points.roundStart.x - 15 - sa
|
||||
});
|
||||
macro("vd", {
|
||||
from: points.roundEnd,
|
||||
to: points.pocketTopMidLeft,
|
||||
x: points.roundStart.x - 30 - sa
|
||||
});
|
||||
macro("vd", {
|
||||
from: points.roundEnd,
|
||||
to: points.dartWaistLeft,
|
||||
x: points.roundStart.x - 45 - sa
|
||||
});
|
||||
macro("vd", {
|
||||
from: points.roundEnd,
|
||||
to: points.closureTop,
|
||||
x: points.roundStart.x - 60 - sa
|
||||
});
|
||||
}
|
||||
macro("vd", {
|
||||
from: points.closureTop,
|
||||
to: points.neck,
|
||||
x: points.closureTop.x - 15 - sa
|
||||
});
|
||||
macro("vd", {
|
||||
from: points.button2,
|
||||
to: points.button1,
|
||||
x: points.button1.x + 15
|
||||
});
|
||||
macro("hd", {
|
||||
from: points.closureTop,
|
||||
to: points.button2,
|
||||
y: points.button2.y + 15
|
||||
});
|
||||
macro("ld", {
|
||||
from: points.dartWaistLeft,
|
||||
to: points.dartWaistRight
|
||||
});
|
||||
macro("ld", {
|
||||
from: points.dartHipLeft,
|
||||
to: points.dartHipRight
|
||||
});
|
||||
macro("ld", {
|
||||
from: points.pocketTopLeft,
|
||||
to: points.pocketTopMidLeft,
|
||||
d: 15
|
||||
});
|
||||
macro("ld", {
|
||||
from: points.pocketTopMidRight,
|
||||
to: points.pocketTopRight,
|
||||
d: 15
|
||||
});
|
||||
macro("ld", {
|
||||
from: points.pocketBottomRight,
|
||||
to: points.pocketTopRight,
|
||||
d: -15
|
||||
});
|
||||
macro("vd", {
|
||||
from: points.pocketTopMidLeft,
|
||||
to: points.dartTop,
|
||||
x: points.closureTop.x - 30 - sa
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return part;
|
||||
};
|
27
packages/wahid/src/index.js
Normal file
27
packages/wahid/src/index.js
Normal file
|
@ -0,0 +1,27 @@
|
|||
import freesewing from "freesewing";
|
||||
import Brian from "@freesewing/brian";
|
||||
import plugins from "@freesewing/plugin-bundle";
|
||||
import round from "@freesewing/plugin-round";
|
||||
import buttons from "@freesewing/plugin-buttons";
|
||||
import config from "../config";
|
||||
// Parts
|
||||
import draftFront from "./front";
|
||||
|
||||
// Create pattern
|
||||
const Wahid = new freesewing.Design(config, [plugins, round, buttons]);
|
||||
|
||||
// Parts we're getting from Brian
|
||||
Wahid.prototype.draftBase = function(part) {
|
||||
return new Brian(this.settings).draftBase(part);
|
||||
};
|
||||
Wahid.prototype.draftBackBlock = function(part) {
|
||||
return new Brian(this.settings).draftBack(part);
|
||||
};
|
||||
Wahid.prototype.draftFrontBlock = function(part) {
|
||||
return new Brian(this.settings).draftFront(part);
|
||||
};
|
||||
|
||||
// Per-part draft methods
|
||||
Wahid.prototype.draftFront = part => draftFront(part);
|
||||
|
||||
export default Wahid;
|
68
packages/wahid/src/shared.js
Normal file
68
packages/wahid/src/shared.js
Normal file
|
@ -0,0 +1,68 @@
|
|||
export const constructMainDart = part => {
|
||||
let { measurements, options, points, Point, store } = part.shorthand();
|
||||
|
||||
let reduce = {};
|
||||
let chest = measurements.chestCircumference * (1 + options.chestEase);
|
||||
let waist = measurements.naturalWaist * (1 + options.waistEase);
|
||||
let hips = measurements.hipsCircumference * (1 + options.hipsEase);
|
||||
|
||||
reduce.waist = chest - waist;
|
||||
reduce.hips = chest - hips;
|
||||
if (reduce.hips < 0) reduce.hips = 0;
|
||||
if (reduce.waist < 0) reduce.waist = 0;
|
||||
|
||||
let wr12 = reduce.waist / 12;
|
||||
let hr12 = reduce.hips / 12;
|
||||
store.set("wr12", wr12);
|
||||
store.set("hr12", hr12);
|
||||
|
||||
points.dartWaistCenter = new Point(points.armhole.x / 2, points.waist.y);
|
||||
points.dartWaistRight = points.dartWaistCenter.shift(0, wr12);
|
||||
points.dartWaistLeft = points.dartWaistCenter.shift(180, wr12);
|
||||
points.dartTop = points.dartWaistCenter.shift(
|
||||
90,
|
||||
points.armhole.dy(points.waist) * 0.75
|
||||
);
|
||||
points.dartWaistRightCpTop = points.dartWaistRight.shift(
|
||||
90,
|
||||
points.armhole.dy(points.waist) * 0.35
|
||||
);
|
||||
points.dartWaistLeftCpTop = points.dartWaistLeft.shift(
|
||||
90,
|
||||
points.armhole.dy(points.waist) * 0.35
|
||||
);
|
||||
points.dartHipCenter = new Point(points.dartWaistCenter.x, points.hips.y);
|
||||
points.dartHipRight = points.dartHipCenter.shift(0, hr12);
|
||||
points.dartHipLeft = points.dartHipCenter.shift(180, hr12);
|
||||
points.dartHemRight = new Point(points.dartHipRight.x, points.hem.y);
|
||||
points.dartHemLeft = new Point(points.dartHipLeft.x, points.hem.y);
|
||||
points.dartHipRightCpTop = points.dartHipRight.shift(
|
||||
90,
|
||||
points.waist.dy(points.hips) * 0.25
|
||||
);
|
||||
points.dartHipLeftCpTop = points.dartHipLeft.shift(
|
||||
90,
|
||||
points.waist.dy(points.hips) * 0.25
|
||||
);
|
||||
points.dartWaistRightCpBottom = points.dartWaistRight.shift(
|
||||
-90,
|
||||
points.waist.dy(points.hips) * 0.25
|
||||
);
|
||||
points.dartWaistLeftCpBottom = points.dartWaistLeft.shift(
|
||||
-90,
|
||||
points.waist.dy(points.hips) * 0.25
|
||||
);
|
||||
};
|
||||
|
||||
export const shapeSideSeam = part => {
|
||||
let { measurements, options, points, Point, store } = part.shorthand();
|
||||
let wr12 = store.get("wr12");
|
||||
let hr12 = store.get("hr12");
|
||||
|
||||
points.waist = points.waist.shift(180, wr12);
|
||||
points.waistCp2 = new Point(points.waist.x, points.dartWaistRightCpTop.y);
|
||||
points.waistCp1 = new Point(points.waist.x, points.dartWaistRightCpBottom.y);
|
||||
points.hips = points.hips.shift(180, hr12);
|
||||
points.hipsCp2 = new Point(points.hips.x, points.dartHipRightCpTop.y);
|
||||
points.hem = points.hem.shift(180, hr12);
|
||||
};
|
14
packages/wahid/test.html
Normal file
14
packages/wahid/test.html
Normal file
|
@ -0,0 +1,14 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Brian</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="svg"></div>
|
||||
<script type="text/javascript" src="freesewing.js"></script>
|
||||
<script>
|
||||
console.log(freesewing);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue