1
0
Fork 0

Adding Penelope

This commit is contained in:
woutervdub 2019-08-21 11:11:05 -07:00
parent d4281f2ab6
commit bc6eb704e9
22 changed files with 14833 additions and 0 deletions

View file

@ -0,0 +1,31 @@
# penelope
> Pencil Skirt
[![NPM](https://img.shields.io/npm/v/penelope.svg)](https://www.npmjs.com/package/penelope) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
## Install
```bash
npm install --save penelope
```
## Usage
```jsx
import React, { Component } from 'react'
import MyComponent from 'penelope'
class Example extends Component {
render () {
return (
<MyComponent />
)
}
}
```
## License
© [woutervdub](https://github.com/woutervdub)

View file

@ -0,0 +1,88 @@
import { version } from "../package.json";
// ?? 🤔 ?? --> https://en.freesewing.dev/packages/core/config
export default {
name: "penelope",
version,
design: "woutervdub",
code: "woutervdub",
department: "womenswear",
type: "pattern",
difficulty: 3,
tags: [
"freesewing",
"design",
"diy",
"fashion",
"made to measure",
"parametric design",
"pattern",
"sewing",
"sewing pattern"
],
optionGroups: {
fit: [
"lengthBonus",
"hem",
"backVent",
"backVentLength",
"waistBand",
"waistBandWidth",
"zipperLocation",
"seatEase",
"waistEase",
"nrOfDarts",
"waistSideSeamRaise",
"backDartDepthFactor",
"frontDartDepthFactor",
"dartToSideSeamFactor"
]
},
measurements: [
"naturalWaist",
"hipsCircumference",
"seatCircumference",
"naturalWaistToHip",
"naturalWaistToSeat",
"naturalWaistToKnee"
],
dependencies: {},
inject: {},
hide: [],
parts: ["front", "back", "waistband"],
options: {
dartMaximumDifference: 300,
dartMinimumDifference: 180,
dartMinimumWidth: 6,
dartSideMinimum: 10,
dartBackControl1: 100,
dartBackControl2: 5,
dartBackControl3: 4,
curvePlacement: 2.4,
dart2offset: 32,
dart2factor: 0.80,
hipCurveDividerDown: 40,
hipCurveDividerUp: 3,
sideSeamShiftPercentage: 0.006,
backVentWidth: 50,
paperlessOffset: 15,
waistBandOverlap: 25,
lengthBonus: { pct: 0, min: -50, max: 50 },
hemBonus: { pct: 0, min: -35, max: 0 },
hem: { mm: 25, min: 0, max: 75 },
backVent: { bool: true },
backVentLength: { pct: 40, min: 5, max: 70 },
waistBand: { bool: true },
waistBandWidth: { mm: 50, min: 10, max: 200 },
zipperLocation: { dflt: "backSeam", list: ["backSeam", "sideSeam"] },
nrOfDarts: { count: 2, min: 1, max: 2 },
seatEase: { mm: 5, min: 0, max: 15 },
waistEase: { mm: 5, min: 0, max: 15 },
waistSideSeamRaise: { pct: 0, min: 0, max: 10 },
backDartDepthFactor: { pct: 50, min: 35, max: 70 },
frontDartDepthFactor: { pct: 45, min: 30, max: 65 },
dartToSideSeamFactor: { pct: 50, min: 30, max: 70 }
}
};

View file

@ -0,0 +1,96 @@
<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>
<br>
<a href="https://freesewing.org/">FreeSewing v2</a>
</p>
<p align="center">A JavaScript library for made-to-measure sewing patterns</p>
<p align='center'><a
href="https://twitter.com/freesewing_org"
title="Follow @freesewing_org on Twitter"
><img src="https://img.shields.io/badge/%F3%A0%80%A0-Follow%20us-blue.svg?logo=twitter&logoColor=white&logoWidth=15"
alt="Follow @freesewing_org on Twitter"/>
</a><a
href="https://gitter.im/freesewing/freesewing"
title="Chat with us on Gitter"
><img src="https://img.shields.io/badge/%F3%A0%80%A0-Chat%20with%20us-CA0547.svg?logo=gitter&logoColor=white&logoWidth=15"
alt="Chat with us on Gitter"/>
</a><a
href="https://freesewing.org/patrons/join"
title="Become a FreeSewing Patron"
><img src="https://img.shields.io/badge/%F3%A0%80%A0-Support%20us-blueviolet.svg?logo=cash-app&logoColor=white&logoWidth=15"
alt="Become a FreeSewing Patron"/>
</a><a
href="https://instagram.com/freesewing_org"
title="Follow @freesewing_org on Twitter"
><img src="https://img.shields.io/badge/%F3%A0%80%A0-Follow%20us-E4405F.svg?logo=instagram&logoColor=white&logoWidth=15"
alt="Follow @freesewing_org on Twitter"/>
</a>
</p>
# penelope example
This project was bootstrapped with [Create Freesewing Pattern](https://en.freesewing.dev/create-freesewing-pattern):
```js
npm init freesewing-pattern
```
This example folder is part of the local development environment.
It is **not** part of the pattern's source code.
To run this example, follow these steps:
- In the folder above this one, run: `yarn start` (or `npm start`)
- Then, in new terminal, run the same command in this folder: `yarn start` (or `npm start`)
This will spin up the development environment, similar to [our online demo](https://penelope.freesewing.dev/).
## About FreeSewing 🤔
Where the world of makers and developers collide, that's where you'll find FreeSewing.
Our [core library](https://freesewing.dev/en/freesewing) is a *batteries-included* toolbox
for parametric design of sewing patterns. It's a modular system (check our list
of [plugins](https://freesewing.dev/en/plugins) and getting started is as simple as:
```bash
npm init freesewing-pattern
```
The [getting started] section on [freesewing.dev](https://freesewing.dev/) is a good
entrypoint to our documentation, but you'll find a lot more there, including
our [API documentation](https://freesewing.dev/en/freesewing/api),
as well as [examples](https://freesewing.dev/en/freesewing/examples),
and [best practices](https://freesewing.dev/en/do).
If you're a maker, checkout [freesewing.org](https://freesewing/) where you can generate
our sewing patterns adapted to your measurements.
## Support FreeSewing: Become a patron 🥰
FreeSewing is an open source project run by a community,
and financially supported by our patrons.
If you feel what we do is worthwhile, you too
should [become a patron](https://freesewing.org/patrons/join).
## Links 👩‍💻
- 💻 Makers website: [freesewing.org](https://freesewing.org)
- 💻 Developers website: [freesewing.dev](https://freesewing.org)
- 💬 Chat: [gitter.im/freesewing](https://gitter.im/freesewing/freesewing)
- 🐦 Twitter: [@freesewing_org](https://twitter.com/freesewing_org)
- 📷 Instagram: [@freesewing_org](https://instagram.com/freesewing_org)
## License: MIT 🤓
© [Joost De Cock](https://github.com/joostdecock).
See [the license file](https://github.com/freesewing/freesewing/blob/develop/LICENSE) for details.
## Where to get help 🤯
Our [chatroom on Gitter](https://gitter.im) is the best place to ask questions,
share your feedback, or just hang out.
If you want to report a problem, please [create an issue](https://github.com/freesewing/freesewing/issues/new).

13278
packages/penelope/example/package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,47 @@
{
"name": "penelope-example",
"homepage": "https://woutervdub.github.io/penelope",
"version": "0.0.0",
"private": true,
"dependencies": {
"@freesewing/components": "beta",
"@freesewing/core": "beta",
"@freesewing/css-theme": "beta",
"@freesewing/i18n": "beta",
"@freesewing/models": "beta",
"@freesewing/mui-theme": "beta",
"@freesewing/pattern-info": "beta",
"@freesewing/plugin-bundle": "beta",
"@freesewing/plugin-i18n": "beta",
"@freesewing/plugin-svgattr": "beta",
"@freesewing/utils": "beta",
"@material-ui/core": "^4.0.1",
"@material-ui/icons": "^4.0.1",
"@material-ui/lab": "^v4.0.0-alpha.14",
"axios": "^0.19.0",
"pattern": "file:..",
"prismjs": "1.16.0",
"react": "^16.8",
"react-dom": "^16.8",
"react-scripts": "^3.0.0",
"typeface-roboto-condensed": "latest"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
],
"devDependencies": {
"babel-plugin-prismjs": "1.0.2"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View file

@ -0,0 +1,40 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="theme-color" content="#000000">
<!--
manifest.json provides metadata used when your web app is added to the
homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>penelope</title>
</head>
<body>
<noscript>
You need to enable JavaScript to run this app.
</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>

View file

@ -0,0 +1,15 @@
{
"short_name": "penelope",
"name": "penelope",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}

View file

@ -0,0 +1,32 @@
.App {
text-align: center;
}
.App-logo {
animation: App-logo-spin infinite 20s linear;
height: 40vmin;
}
.App-header {
background-color: #282c34;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: calc(10px + 2vmin);
color: white;
}
.App-link {
color: #61dafb;
}
@keyframes App-logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}

View file

@ -0,0 +1,22 @@
import React from "react";
import freesewing from "@freesewing/core";
import Workbench from "@freesewing/components/Workbench";
import "typeface-roboto-condensed";
import "@freesewing/css-theme";
import Pattern from "pattern";
const App = props => {
let instance = new Pattern();
let config = instance.config;
return (
<Workbench
freesewing={freesewing}
Pattern={Pattern}
config={config}
userLanguage="en"
/>
);
};
export default App;

View file

@ -0,0 +1,9 @@
import React from "react";
import ReactDOM from "react-dom";
import App from "./App";
it("renders without crashing", () => {
const div = document.createElement("div");
ReactDOM.render(<App />, div);
ReactDOM.unmountComponentAtNode(div);
});

View file

@ -0,0 +1,14 @@
body {
margin: 0;
padding: 0;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen",
"Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue",
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
code {
font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New",
monospace;
}

View file

@ -0,0 +1,11 @@
import React from "react";
import ReactDOM from "react-dom";
import App from "./App";
import * as serviceWorker from "./serviceWorker";
ReactDOM.render(<App />, document.getElementById("root"));
// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: http://bit.ly/CRA-PWA
serviceWorker.unregister();

View file

@ -0,0 +1,127 @@
// In production, we register a service worker to serve assets from local cache.
// This lets the app load faster on subsequent visits in production, and gives
// it offline capabilities. However, it also means that developers (and users)
// will only see deployed updates on the "N+1" visit to a page, since previously
// cached resources are updated in the background.
// To learn more about the benefits of this model, read https://goo.gl/KwvDNy.
// This link also includes instructions on opting out of this behavior.
const isLocalhost = Boolean(
window.location.hostname === "localhost" ||
// [::1] is the IPv6 localhost address.
window.location.hostname === "[::1]" ||
// 127.0.0.1/8 is considered localhost for IPv4.
window.location.hostname.match(
/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
)
);
export function register(config) {
if (process.env.NODE_ENV === "production" && "serviceWorker" in navigator) {
// The URL constructor is available in all browsers that support SW.
const publicUrl = new URL(process.env.PUBLIC_URL, window.location);
if (publicUrl.origin !== window.location.origin) {
// Our service worker won't work if PUBLIC_URL is on a different origin
// from what our page is served on. This might happen if a CDN is used to
// serve assets; see https://github.com/facebook/create-react-app/issues/2374
return;
}
window.addEventListener("load", () => {
const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;
if (isLocalhost) {
// This is running on localhost. Let's check if a service worker still exists or not.
checkValidServiceWorker(swUrl, config);
// Add some additional logging to localhost, pointing developers to the
// service worker/PWA documentation.
navigator.serviceWorker.ready.then(() => {
console.log(
"This web app is being served cache-first by a service " +
"worker. To learn more, visit https://goo.gl/SC7cgQ"
);
});
} else {
// Is not local host. Just register service worker
registerValidSW(swUrl, config);
}
});
}
}
function registerValidSW(swUrl, config) {
navigator.serviceWorker
.register(swUrl)
.then(registration => {
registration.onupdatefound = () => {
const installingWorker = registration.installing;
installingWorker.onstatechange = () => {
if (installingWorker.state === "installed") {
if (navigator.serviceWorker.controller) {
// At this point, the old content will have been purged and
// the fresh content will have been added to the cache.
// It's the perfect time to display a "New content is
// available; please refresh." message in your web app.
console.log("New content is available; please refresh.");
// Execute callback
if (config.onUpdate) {
config.onUpdate(registration);
}
} else {
// At this point, everything has been precached.
// It's the perfect time to display a
// "Content is cached for offline use." message.
console.log("Content is cached for offline use.");
// Execute callback
if (config.onSuccess) {
config.onSuccess(registration);
}
}
}
};
};
})
.catch(error => {
console.error("Error during service worker registration:", error);
});
}
function checkValidServiceWorker(swUrl, config) {
// Check if the service worker can be found. If it can't reload the page.
fetch(swUrl)
.then(response => {
// Ensure service worker exists, and that we really are getting a JS file.
if (
response.status === 404 ||
response.headers.get("content-type").indexOf("javascript") === -1
) {
// No service worker found. Probably a different app. Reload the page.
navigator.serviceWorker.ready.then(registration => {
registration.unregister().then(() => {
window.location.reload();
});
});
} else {
// Service worker found. Proceed as normal.
registerValidSW(swUrl, config);
}
})
.catch(() => {
console.log(
"No internet connection found. App is running in offline mode."
);
});
}
export function unregister() {
if ("serviceWorker" in navigator) {
navigator.serviceWorker.ready.then(registration => {
registration.unregister();
});
}
}

74
packages/penelope/package.json Executable file
View file

@ -0,0 +1,74 @@
{
"name": "penelope",
"version": "0.0.1",
"description": "Pencil Skirt",
"author": "woutervdub",
"license": "MIT",
"repository": "woutervdub/penelope",
"main": "dist/index.js",
"module": "dist/index.es.js",
"jsnext:main": "dist/index.es.js",
"engines": {
"node": ">=8",
"npm": ">=5"
},
"scripts": {
"test": "cross-env CI=1 react-scripts test --env=jsdom",
"test:watch": "react-scripts test --env=jsdom",
"build": "rollup -c",
"start": "rollup -c -w",
"prepare": "npm run build",
"predeploy": "cd example && npm install && npm run build",
"deploy": "gh-pages -d example/build"
},
"devDependencies": {
"@babel/plugin-proposal-class-properties": "^7.0.0",
"@freesewing/components": "^2.0.0-beta.9-2",
"@freesewing/core": "^2.0.0-beta.32",
"@freesewing/css-theme": "beta",
"@freesewing/i18n": "beta",
"@freesewing/mui-theme": "beta",
"@freesewing/patterns": "beta",
"@freesewing/plugin-bundle": "^2.0.0-beta.32",
"@freesewing/plugin-bust": "beta",
"@freesewing/plugin-buttons": "beta",
"@freesewing/plugin-debug": "beta",
"@freesewing/plugin-designer": "beta",
"@freesewing/plugin-flip": "beta",
"@freesewing/utils": "beta",
"@material-ui/core": "^3.9.3",
"@material-ui/icons": "^3.0.2",
"@material-ui/lab": "^3.0.0-alpha.30",
"@svgr/rollup": "^2.4.1",
"babel-eslint": "10.0.1",
"babel-jest": "24.7.1",
"cross-env": "^5.1.4",
"eslint": "^5.16.0",
"gh-pages": "^1.2.0",
"jest": "24.7.1",
"prop-types": "15.7.2",
"react": "^16.8",
"react-dom": "^16.8",
"react-intl": "2.8.0",
"react-scripts": "^3.0.0",
"rollup": "^0.68.2",
"rollup-plugin-babel": "^4.0.1",
"rollup-plugin-babel-minify": "^7.0.0",
"rollup-plugin-commonjs": "^9.1.3",
"rollup-plugin-json": "^3.1.0",
"rollup-plugin-node-resolve": "^3.3.0",
"rollup-plugin-peer-deps-external": "^2.2.0",
"rollup-plugin-postcss": "^1.6.2",
"rollup-plugin-url": "^1.4.0",
"webpack": "4.29.6"
},
"dependencies": {
"@freesewing/examples": "^2.0.0-beta.32",
"@freesewing/pattern-info": "^2.0.0-beta.32",
"@freesewing/rendertest": "^2.0.0-beta.32",
"@freesewing/tutorial": "^2.0.0-beta.32",
"axios": "^0.19.0",
"prismjs": "^1.16.0",
"typescript": "^3.5.3"
}
}

View file

@ -0,0 +1,5 @@
{
"env": {
"jest": true
}
}

150
packages/penelope/src/back.js Executable file
View file

@ -0,0 +1,150 @@
import { BuildMainShape } from "./shape";
export default function(part) {
let {
options,
measurements,
/*Point,*/
Path,
points,
paths,
Snippet,
snippets,
store,
complete,
sa,
paperless,
macro
} = part.shorthand();
BuildMainShape(part, false);
if (options.backVent == true) {
// I don't care what you're trying to create, the vent will not go higher than your hips.
let backVentLength = Math.min(
store.get("skirtLength") - measurements.naturalWaistToHip,
options.backVentLength * store.get("skirtLength")
);
console.log({
backVentLength: backVentLength,
skirtLength: store.get("skirtLength"),
OptionsBackVentLength: options.backVentLength
});
points.vLeg = points.lLeg.shift(180, options.backVentWidth);
points.vHem = points.lHem.shift(180, options.backVentWidth);
points.vTop = points.vLeg.shift(90, backVentLength);
points.lVent = points.vTop
.shift(0, options.backVentWidth)
.shift(90, options.backVentWidth);
paths.vent = new Path()
.move(points.lVent)
.line(points.vTop)
.line(points.vLeg)
.line(points.vHem)
.setRender(false);
paths.leftSide = new Path()
.move(points.lWaist)
.line(points.lVent)
.join(paths.vent)
.setRender(false);
paths.hem = paths.hem.line(points.vLeg);
}
paths.seam = paths.leftSide
.clone()
.join(paths.bottom)
.join(paths.sideSeam)
.join(paths.waist)
.attr("class", "fabric");
// Complete?
if (complete) {
macro("grainline", {
from: points.grainlineTop,
to: points.grainlineBottom
});
snippets.logo = new Snippet("logo", points.logoAnchor);
if (options.backVent == false && options.zipperLocation != "backSeam") {
macro("cutonfold", {
from: points.lWaist,
to: points.lLeg,
margin: 5,
offset: 10
});
macro("title", {
at: points.titleAnchor,
title: "1x " + "cutOnFold" + " " + "fromFabric"
});
} else {
macro("title", {
at: points.titleAnchor,
title: "2x " + "fromFabric"
});
}
if (sa) {
if (options.backVent || options.zipperLocation == "backSeam") {
paths.sa = paths.leftSide
.clone()
.join(paths.bottom)
.join(paths.sideSeam)
.join(paths.waistSA)
.line(points.lWaist)
.close()
.offset(sa)
.attr("class", "fabric sa");
} else {
paths.sa = new Path()
.move(points.lHem)
.join(
paths.bottom
.join(paths.sideSeam)
.join(paths.waistSA)
.offset(sa)
)
.line(points.lWaist)
.attr("class", "fabric sa");
}
}
}
if (paperless) {
if (options.backVent) {
macro("hd", {
from: points.vHem,
to: points.rHem,
y: points.rHem.y - options.paperlessOffset
});
macro("hd", {
from: points.vTop,
to: points.lVent,
y: points.vTop.y
});
macro("vd", {
from: points.lSeat,
to: points.lVent,
x: points.lWaist.x - options.paperlessOffset
});
macro("vd", {
from: points.lVent,
to: points.vTop,
x: points.lVent.x
});
} else {
macro("hd", {
from: points.lHem,
to: points.rHem,
y: points.rHem.y - options.paperlessOffset
});
}
}
return part;
}

116
packages/penelope/src/front.js Executable file
View file

@ -0,0 +1,116 @@
import { BuildMainShape } from "./shape";
export default function(part) {
let frontPart = true;
let {
options,
measurements,
Point,
Path,
points,
paths,
Snippet,
snippets,
store,
complete,
sa,
paperless,
macro
} = part.shorthand();
BuildMainShape(part, true);
paths.seam = paths.leftSide
.clone()
.join(paths.bottom)
.join(paths.sideSeam)
.join(paths.waist)
.attr("class", "fabric");
// Complete?
if (complete) {
macro("cutonfold", {
from: points.lWaist,
to: points.lLeg,
margin: 5,
offset: 10
});
macro("title", {
at: points.titleAnchor,
title: "1x " + "cutOnFold" + " " + "fromFabric"
});
/*
let so = {
from: points.lWaist,
to: points.lLeg,
margin: 5,
offset: -10,
prefix: ''
};
points["cutonfoldFrom" + so.prefix] = so.from.shiftFractionTowards(
so.to,
so.margin / 100
);
points["cutonfoldTo" + so.prefix] = so.to.shiftFractionTowards(
so.from,
so.margin / 100
);
points["cutonfoldVia1" + so.prefix] = points["cutonfoldFrom" + so.prefix]
.shiftTowards(so.from, so.offset)
.rotate(-90, points["cutonfoldFrom" + so.prefix]);
points["cutonfoldVia2" + so.prefix] = points["cutonfoldTo" + so.prefix]
.shiftTowards(so.to, so.offset)
.rotate(90, points["cutonfoldTo" + so.prefix]);
let text = so.grainline ? "cutOnFoldAndGrainline" : "cutOnFold";
paths["cutonfold" + so.prefix] = new this.Path()
.move(points["cutonfoldFrom" + so.prefix])
.line(points["cutonfoldVia1" + so.prefix])
.line(points["cutonfoldVia2" + so.prefix])
.line(points["cutonfoldTo" + so.prefix])
.attr("class", "note")
.attr("marker-start", "url(#cutonfoldFrom)")
.attr("marker-end", "url(#cutonfoldTo)")
.attr("data-text", text)
.attr("data-text-class", "center fill-note");
*/
macro("title", {
at: points.titleAnchor,
title: "1x " + "cutOnFold" + " " + "fromFabric"
});
macro("grainline", {
from: points.grainlineTop,
to: points.grainlineBottom
});
points.scaleBox = points.logoAnchor.shift(270, 100);
macro("scalebox", { at: points.scaleBox });
snippets.logo = new Snippet("logo", points.logoAnchor);
if (sa) {
paths.sa = new Path()
.move(points.lHem)
.join(
paths.bottom
.join(paths.sideSeam)
.join(paths.waistSA)
.offset(sa)
)
.line(points.lWaist)
.attr("class", "fabric sa");
}
if (paperless) {
macro("hd", {
from: points.lHem,
to: points.rHem,
y: points.rHem.y - options.paperlessOffset
});
}
}
return part;
}

16
packages/penelope/src/index.js Executable file
View file

@ -0,0 +1,16 @@
import freesewing from "@freesewing/core";
import plugins from "@freesewing/plugin-bundle";
import config from "../config";
import draftFront from "./front";
import draftBack from "./back";
import draftWaistband from "./waistband";
// Create new design
const Pattern = new freesewing.Design(config, plugins);
// Attach the draft methods to the prototype
Pattern.prototype.draftFront = draftFront;
Pattern.prototype.draftBack = draftBack;
Pattern.prototype.draftWaistband = draftWaistband;
export default Pattern;

406
packages/penelope/src/shape.js Executable file
View file

@ -0,0 +1,406 @@
import { addDartToCurve, dartCalc } from "./utils";
function BuildMainShape(part, frontPart) {
let {
options,
measurements,
Point,
Path,
points,
paths,
/*Snippet,*/
/*snippets,*/
store,
/*complete,*/
/*sa,*/
paperless,
macro
} = part.shorthand();
let skirtLength =
measurements.naturalWaistToKnee + options.lengthBonus + options.hem;
store.set("skirtLength", skirtLength);
let waistEase = options.waistEase;
let seatEase = options.seatEase;
let dartDepthFactor = frontPart
? options.frontDartDepthFactor
: options.backDartDepthFactor;
let waist = measurements.naturalWaist;
let seat =
measurements.seatCircumference > waist
? measurements.seatCircumference
: waist;
let hip =
measurements.hipsCircumference > waist
? measurements.hipsCircumference
: waist;
dartCalc(options, seat, seatEase, waist, waistEase);
/*
console.log(
"seat: " +
seat +
" seatEase: " +
seatEase +
" waist: " +
waist +
" waistEase: " +
waistEase
);
*/
let nrOfDarts = options.nrOfDarts;
let dartSize = options.frontDartSize;
if (frontPart == false) {
dartSize = options.backDartSize;
}
//console.log("dartSize: " + dartSize + " nrOfDarts: " + nrOfDarts);
if (dartSize <= 0) {
nrOfDarts = 0;
}
store.set("nrOfDarts", nrOfDarts);
store.set("dartSize", dartSize);
let sideSeamShift =
(frontPart ? -1 : 1) * options.sideSeamShiftPercentage * seat;
seat += seatEase;
waist += waistEase;
let sideSeam = seat / 4 + sideSeamShift;
let hipSeam = hip / 4 + sideSeamShift;
points.lWaist = new Point(0, 0);
points.lLeg = new Point(0, skirtLength);
points.rWaistOriginal = new Point(sideSeam, 0);
points.rLeg = new Point(
sideSeam + (options.hemBonus * seat) / 10,
skirtLength
);
points.lSeat = new Point(0, measurements.naturalWaistToSeat);
points.rSeat = new Point(sideSeam, measurements.naturalWaistToSeat);
points.rWaistCPdown = new Point(
sideSeam,
measurements.naturalWaistToSeat / 3
);
points.rSeatCPup = new Point(
sideSeam,
(measurements.naturalWaistToSeat / 3) * 2
);
points.rSeatCPdown = points.rSeat.shift(
270,
((measurements.naturalWaistToSeat - measurements.naturalWaistToHip) *
Math.abs((options.hemBonus * seat) / 10)) /
options.hipCurveDividerDown
);
//$p->newPoint('pH', $sideSeam, $model->m('naturalWaistToHip') -$this->o('waistSideSeamRise'));
let waistFactor = 0.99;
let sideFactor = 0.97;
let wdelta = 1;
let sdelta = 1;
let iteration = 0;
let waistCurve = null;
let waistPath = null;
let waistPathSA = null;
let waistLength = 0;
let sideSeamPath = null;
let sideSeamLength = 0;
let curve1 = null;
let curve2 = null;
do {
if (wdelta < -1) {
waistFactor *= 0.9995;
} else if (wdelta > 1) {
waistFactor *= 1.01;
}
if (sdelta < -1) {
sideFactor *= 0.995;
} else if (sdelta > 1) {
sideFactor *= 1.01;
}
points.rWaistTemp1 = points.lWaist.shift(0, (waist / 4) * waistFactor);
points.rWaistTemp2 = points.rWaistTemp1.shift(0, dartSize * nrOfDarts);
points.rWaist = points.rWaistTemp2.shift(90, 16 * sideFactor);
points.lWaistCP = points.lWaist.shift(0, seat / 12);
points.rWaistCPleft = points.rWaist.shift(
points.rWaist.angle(points.rWaistCPdown) - 90,
waist / 16
);
/*
console.log(
"rWaist: (" +
points.rWaist.x.toString() +
"," +
points.rWaist.y.toString() +
") [" +
iteration.toString() +
"]"
);
*/
waistCurve = new Path()
.move(points.lWaist)
.curve(points.lWaistCP, points.rWaistCPleft, points.rWaist)
.setRender(false);
if (nrOfDarts > 0) {
curve1 = addDartToCurve(
part,
waistCurve,
seat / 4 / options.curvePlacement,
dartSize,
measurements.naturalWaistToSeat * dartDepthFactor
);
waistLength = curve1.left.length();
points.dart1Start = curve1.dart.start();
points.dart1Middle = curve1.dart.ops[1].to;
points.dart1End = curve1.dart.end();
if (nrOfDarts > 1) {
curve2 = addDartToCurve(
part,
curve1.right,
options.dart2offset,
dartSize,
measurements.naturalWaistToSeat *
dartDepthFactor *
options.dart2factor
);
waistLength += curve2.left.length();
waistLength += curve2.right.length();
waistPath = curve1.left.join(
curve1.dart.join(curve2.left.join(curve2.dart.join(curve2.right)))
);
waistPathSA = curve1.left.join(curve2.left.join(curve2.right));
points.dart2Start = curve2.dart.start();
points.dart2Middle = curve2.dart.ops[1].to;
points.dart2End = curve2.dart.end();
} else {
waistLength += curve1.right.length();
waistPath = curve1.left.join(curve1.dart.join(curve1.right));
waistPathSA = curve1.left.join(curve1.right);
}
} else {
waistLength = waistCurve.length();
waistPath = waistCurve;
waistPathSA = waistCurve.clone();
}
sideSeamPath = new Path()
.move(points.rLeg)
//.line(points.rSeat)
.curve(points.rLeg, points.rSeatCPdown, points.rSeat)
.curve(points.rSeatCPup, points.rWaistCPdown, points.rWaist);
//console.log(sideSeamPath);
wdelta = waist / 4 - waistLength;
if (frontPart) {
sdelta = 0;
} else {
sideSeamLength = sideSeamPath.length();
sdelta = store.get("sideSeamLength") - sideSeamLength;
}
/*
console.log({
iteration: iteration,
wdelta: wdelta,
waistFactor: waistFactor,
sdelta: sdelta,
sideFactor: sideFactor
});
*/
} while ((Math.abs(wdelta) > 1 || Math.abs(sdelta) > 1) && iteration++ < 100);
//paths.waist0 = waistCurveHelper.translate( 0, -10 ).attr('class', 'lining dashed');
paths.waist1 = waistCurve.translate(0, 10).attr("class", "lining dashed");
if (iteration >= 100) {
throw "Too many iterations trying to make it fit!";
}
if (frontPart) {
sideSeamLength = sideSeamPath.length();
store.set("sideSeamLength", sideSeamLength);
//console.log("Front sideseam length: " + sideSeamLength);
} else {
//console.log("back sideseam length: " + sideSeamLength);
}
points.lHem = points.lLeg;
points.rHem = points.rLeg;
paths.hem = new Path()
.move(points.lLeg)
.line(points.rLeg)
.attr("class", "fabric stroke-sm")
.setRender(false);
if (options.hem > 0) {
// Create the inverse of the curve from the leg to the waist
// Then split it at the hem level
points.lHem = points.lLeg.shift(270, options.hem);
let rInverseSeat = points.rSeat.shift(
270,
(points.rLeg.y - points.rSeat.y) * 2
);
let rInverseSeatCP = rInverseSeat.shift(
90,
points.rSeatCPdown.y - points.rSeat.y
);
let rInversePath = new Path()
.move(rInverseSeat)
.curve(rInverseSeatCP, points.rLeg, points.rLeg);
points.rHem = rInversePath.intersectsY(points.lHem.y)[0];
let sideSeamHemPath = rInversePath.split(points.rHem)[1];
sideSeamPath = sideSeamHemPath.join(sideSeamPath);
paths.hem.setRender(true);
}
paths.leftSide = new Path()
.move(points.lWaist)
.line(points.lHem)
.setRender(false);
paths.bottom = new Path()
.move(points.lHem)
.line(points.rHem)
.setRender(false);
paths.sideSeam = sideSeamPath.setRender(false);
// Turn the path in the other direction, to comply with the counter-clockwise guideline
paths.waist = waistPath.reverse().setRender(false);
paths.waistSA = waistPathSA.reverse().setRender(false);
points.titleAnchor = new Point(
measurements.naturalWaist / 6,
measurements.naturalWaistToSeat
);
points.logoAnchor = points.titleAnchor.shift(270, 75);
points.grainlineTop = points.lWaist.shift(0, 50).shift(270, 50);
points.grainlineBottom = points.lLeg.shift(0, 50).shift(90, 50);
if (paperless) {
macro("hd", {
from: points.lSeat,
to: points.rSeat,
y: points.rSeat.y
});
macro("vd", {
from: points.lWaist,
to: points.rWaist,
x: points.rWaist.x + options.paperlessOffset
});
macro("vd", {
from: points.lWaist,
to: points.lLeg,
x: points.lLeg.x + options.paperlessOffset
});
if (options.hem > 0) {
macro("vd", {
from: points.lLeg,
to: points.lHem,
x: points.lLeg.x + options.paperlessOffset
});
}
if (store.get("nrOfDarts") > 0) {
macro("hd", {
from: points.lWaist,
to: points.dart1Middle,
y: points.dart1Middle.y
});
macro("hd", {
from: points.lWaist,
to: points.dart1Start,
y: points.dart1Start.y - options.paperlessOffset
});
macro("hd", {
from: points.dart1Start,
to: points.dart1End,
y: points.dart1End.y - options.paperlessOffset
});
if (store.get("nrOfDarts") > 1) {
macro("hd", {
from: points.lWaist,
to: points.dart2Middle,
y: points.dart2Middle.y
});
macro("hd", {
from: points.dart1End,
to: points.dart2Start,
y: points.dart2Start.y - options.paperlessOffset
});
macro("hd", {
from: points.dart2Start,
to: points.dart2End,
y: points.dart2End.y - options.paperlessOffset
});
macro("hd", {
from: points.dart2End,
to: points.rWaist,
y: points.rWaist.y - options.paperlessOffset
});
macro("vd", {
from: points.lWaist,
to: points.dart2Middle,
x: points.lWaist.x - options.paperlessOffset
});
macro("vd", {
from: points.dart2Middle,
to: points.dart1Middle,
x: points.lWaist.x - options.paperlessOffset
});
macro("vd", {
from: points.dart1Middle,
to: points.lSeat,
x: points.lWaist.x - options.paperlessOffset
});
} else {
macro("vd", {
from: points.lWaist,
to: points.dart1Middle,
x: points.lWaist.x - options.paperlessOffset
});
macro("hd", {
from: points.dart1End,
to: points.rWaist,
y: points.rWaist.y - options.paperlessOffset
});
macro("vd", {
from: points.dart1Middle,
to: points.lSeat,
x: points.lWaist.x - options.paperlessOffset
});
}
} else {
macro("hd", {
from: points.lWaist,
to: points.rWaist,
y: points.rWaist.y - options.paperlessOffset
});
macro("vd", {
from: points.lWaist,
to: points.lSeat,
x: points.lWaist.x - options.paperlessOffset
});
}
}
}
export { BuildMainShape };

168
packages/penelope/src/utils.js Executable file
View file

@ -0,0 +1,168 @@
function dartCalcFront(options, seatWaistDiff, nrOfDarts) {
/*
console.log(
"F: seatWaistDiff: " + seatWaistDiff + " nrOfDarts: " + nrOfDarts
);
*/
return (
((options.dartMinimumWidth +
(Math.max(
Math.min(seatWaistDiff, options.dartMaximumDifference),
options.dartMinimumDifference
) -
options.dartMinimumDifference) /
4) /
nrOfDarts) *
(0.5 + options.dartToSideSeamFactor)
);
}
function dartCalcBack(options, seatWaistDiff, nrOfDarts) {
/*
console.log(
"B: seatWaistDiff: " + seatWaistDiff + " nrOfDarts: " + nrOfDarts
);
*/
return (
((options.dartMinimumWidth +
(seatWaistDiff -
options.dartBackControl1 -
(seatWaistDiff - options.dartBackControl1) / options.dartBackControl2) /
options.dartBackControl3) /
nrOfDarts) *
(0.5 + options.dartToSideSeamFactor)
);
}
function dartCalc(options, seat, seatEase, waist, waistEase) {
seat += seatEase;
waist += waistEase;
let seatWaistDiff = Math.max(seat - waist, 0);
options.seatWaistDiff = seatWaistDiff;
let nrOfDarts = options.nrOfDarts;
let frontDartSize = dartCalcFront(options, seatWaistDiff, nrOfDarts);
/*
console.log({
frontDartSize: frontDartSize,
dartMinimumWidth: options.dartMinimumWidth,
nrOfDarts: nrOfDarts
});
*/
// If the front darts are too small and we have more than one, remove one.
if (frontDartSize <= options.dartMinimumWidth * nrOfDarts && nrOfDarts > 1) {
nrOfDarts--;
frontDartSize = dartCalcFront(options, seatWaistDiff, nrOfDarts);
}
// See if the dart created by the side seam becomes too small:
if (seatWaistDiff / 4 - frontDartSize < options.dartSideMinimum) {
frontDartSize = 0;
}
// if( seatWaistDiff/4 -frontDartSize < options.dartSideMinimum || frontDartSize < options.dartMinimumWidth *nrOfDarts ) {
// nrOfDarts = 1;
// }
/*
console.log({
frontDartSize: frontDartSize,
dartMinimumWidth: options.dartMinimumWidth,
nrOfDarts: nrOfDarts
});
*/
let backDartSize = dartCalcBack(options, seatWaistDiff, nrOfDarts);
// If the back darts are too small and we have more than one, remove one.
if (backDartSize < options.dartMinimumWidth * nrOfDarts && nrOfDarts > 1) {
nrOfDarts = 1;
frontDartSize = dartCalcFront(options, seatWaistDiff, nrOfDarts);
backDartSize = dartCalcBack(options, seatWaistDiff, nrOfDarts);
}
/*
console.log({
backDartSize: backDartSize,
dartMinimumWidth: options.dartMinimumWidth,
nrOfDarts: nrOfDarts
});
*/
options.frontDartSize = frontDartSize;
options.backDartSize = backDartSize;
options.nrOfDarts = nrOfDarts;
}
/**
* Method to add a dart onto a curve
* The dart is added at an 90 degree angle with the curve for a certain depth and Width
* @param part The part that will provide that Paths
* @param curvePath The curve the dart needs to divide
* @param distance Distance from $p1 where the middle of the dart will be
* @param dartSize The width of the dart opening at the curve
* @param dartDepth The depth of the dart
*
* @return Object with three path attributes; left, dart, right
*/
function addDartToCurve(part, curvePath, distance, dartSize, dartDepth) {
let dartMiddle = curvePath.shiftAlong(distance);
let curvePaths = curvePath.split(dartMiddle);
let dartLeft = curvePaths[0].reverse().shiftAlong(dartSize / 2);
let dartRight = curvePaths[1].shiftAlong(dartSize / 2);
let distanceFactor = 0.15;
let leftCPdistance = Math.min(
curvePaths[0].length() * distanceFactor,
curvePaths[0].ops[1].to.dist(curvePaths[0].ops[1].cp2)
);
let rightCPdistance = Math.min(
curvePaths[1].length() * distanceFactor,
curvePaths[1].ops[0].to.dist(curvePaths[1].ops[1].cp1)
);
let dartBottom = dartMiddle.shift(dartLeft.angle(dartRight) - 90, dartDepth);
let leftDartCP = dartLeft.shift(
dartLeft.angle(dartBottom) - 90,
leftCPdistance
);
let rightDartCP = dartRight.shift(
dartRight.angle(dartBottom) + 90,
rightCPdistance
);
let curveLeftOfDart = new part.Path()
.move(curvePaths[0].ops[0].to)
.curve(curvePaths[0].ops[1].cp1, leftDartCP, dartLeft)
.setRender(false);
let curveRightOfDart = new part.Path()
.move(dartRight)
.curve(rightDartCP, curvePaths[1].ops[1].cp2, curvePaths[1].ops[1].to)
.setRender(false);
let dart = new part.Path()
.move(dartLeft)
.line(dartBottom)
.line(dartRight)
.setRender(false);
let curveWithDart = {
left: curveLeftOfDart,
dart: dart,
right: curveRightOfDart
};
/*
part.points.dartMiddle = dartMiddle ;
part.points.dartLeft = dartLeft ;
part.points.dartRight = dartRight ;
part.points.dartBottom = dartBottom ;
*/
return curveWithDart;
}
export { addDartToCurve, dartCalc };

View file

@ -0,0 +1,88 @@
export default function(part) {
let {
options,
measurements,
Point,
Path,
points,
paths,
Snippet,
snippets,
complete,
sa,
paperless,
macro
} = part.shorthand();
let waistEase = options.waistEase;
let waist = measurements.naturalWaist;
waist += waistEase;
points.TL = new Point(0, 0);
points.BL = new Point(0, waist / 2 + options.waistBandOverlap);
points.TR = new Point(options.waistBandWidth, 0);
points.BR = new Point(
options.waistBandWidth,
waist / 2 + options.waistBandOverlap
);
points.titleAnchor = new Point(options.waistBandWidth / 2, waist / 6);
points.logoAnchor = new Point(options.waistBandWidth / 2, waist / 3);
paths.outline = new Path()
.move(points.TL)
.line(points.BL)
.line(points.BR)
.line(points.TR)
.line(points.TL)
.close()
.attr("class", "fabric");
// Complete?
if (complete) {
macro("cutonfold", {
from: points.TR,
to: points.TL,
margin: 15,
offset: 15,
grainline: true
});
snippets.logo = new Snippet("logo", points.logoAnchor);
macro("title", {
at: points.titleAnchor,
title: "1x " + "fromFabric"
});
if (sa) {
paths.sa = new Path()
.move(points.TL)
.join(
new Path()
.move(points.TL)
.line(points.BL)
.line(points.BR)
.line(points.TR)
.offset(sa)
)
.line(points.TR)
.attr("class", "fabric sa");
}
}
if (paperless) {
macro("vd", {
from: points.TL,
to: points.BL,
x: points.TL.x + options.paperlessOffset
});
macro("hd", {
from: points.BL,
to: points.BR,
y: points.BR.y - options.paperlessOffset
});
}
return part;
}