1
0
Fork 0

🚧 Started work on Sandy port

This commit is contained in:
Joost De Cock 2019-07-11 16:49:28 +02:00
parent 54be0b691e
commit 4508d0d042
17 changed files with 11506 additions and 0 deletions

View file

@ -40,6 +40,7 @@ plugin-theme: "A FreeSewing plugin that provides a default theme"
plugin-title: "A FreeSewing plugin to add a title to your pattern parts"
plugin-validate: "A FreeSewing plugin that validates aspects of your code"
rendertest: "A FreeSewing pattern to test (y)our render engine our CSS"
sandy: "A FreeSewing pattern for a circle skirt"
shin: "A FreeSewing pattern for swim trunks"
simon: "A FreeSewing pattern for a button down shirt"
sven: "A FreeSewing pattern for a straightforward sweater"

107
packages/sandy/README.md Normal file
View file

@ -0,0 +1,107 @@
> **Note**: This is part of version 2 of FreeSewing.
> It is a work in progress, and not ready for prime-time yet
>
> For all questions, please come say hello in [our chatroom on Gitter](https://gitter.im/).
<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://www.npmjs.com/package/@freesewing/sandy"
title="@freesewing/sandy on NPM"
><img src="https://img.shields.io/npm/v/@freesewing/sandy.svg"
alt="@freesewing/sandy on NPM"/>
</a><a
href="https://opensource.org/licenses/MIT"
title="License: MIT"
><img src="https://img.shields.io/npm/l/@freesewing/sandy.svg?label=License"
alt="License: MIT"/>
</a><a
href="https://deepscan.io/dashboard#view=project&tid=2114&pid=2993&bid=23256"
title="Code quality on DeepScan"
><img src="https://deepscan.io/api/teams/2114/projects/2993/branches/23256/badge/grade.svg"
alt="Code quality on DeepScan"/>
</a><a
href="https://github.com/freesewing/freesewing/issues?q=is%3Aissue+is%3Aopen+label%3Apkg%3Asandy"
title="Open issues tagged pkg:sandy"
><img src="https://img.shields.io/github/issues/freesewing/freesewing/pkg:sandy.svg?label=Issues"
alt="Open issues tagged pkg:sandy"/>
</a></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>
# @freesewing/sandy
A FreeSewing pattern for a circle skirt
## 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).

View file

@ -0,0 +1,56 @@
import { version } from "../package.json";
export default {
name: "sandy",
version,
design: "Erica Alcusa Sáez",
code: ["Erica Alcusa Sáez", "Joost De Cock"],
department: "womenswear",
type: "pattern",
difficulty: 3,
tags: ["skirt", "top", "basics"],
optionGroups: {
fit: ["waistbandPosition"],
style: [
"lengthBonus",
"circleRatio",
"waistbandWidth",
"waistbandShape",
"waistbandOverlap",
"gathering",
"seamlessFullCircle",
"hemWidth"
]
},
measurements: [
"naturalWaist",
"naturalWaistToFloor",
"naturalWaistToHip",
"hipsCircumference"
],
dependencies: {},
inject: {},
hide: [],
parts: ["skirt"],
options: {
// Bool
seamlessFullCircle: { bool: false },
// Millimeter
waistbandWidth: { mm: 40, min: 5, max: 150 },
// Percentages
waistbandPosition: { pct: 50, min: 0, max: 100 },
lengthBonus: { pct: 50, min: 10, max: 100 },
circleRatio: { pct: 50, min: 20, max: 100 },
waistbandOverlap: { pct: 0, min: 20, max: 100 },
gathering: { pct: 0, min: 0, max: 200 },
hemWidth: { pct: 1, min: 0, max: 5 },
// Lists
waistbandShape: {
list: ["straight", "curved"],
dflt: "straight"
}
}
};

View file

@ -0,0 +1,10 @@
{
"plugins": [
["prismjs", {
"languages": ["javascript", "css", "markup"],
"plugins": ["line-numbers"],
"theme": "twilight",
"css": true
}]
]
}

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>
# sandy 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://sandy.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).

View file

@ -0,0 +1,48 @@
{
"name": "sandy-example",
"homepage": "https://freesewing.github.io/sandy",
"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": "link:..",
"prismjs": "1.16.0",
"react": "^16.8",
"react-dom": "^16.8",
"react-scripts": "^3.0.0",
"tlds": "^1.203.1",
"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>sandy</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": "sandy",
"name": "sandy",
"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,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,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();
});
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,90 @@
{
"name": "@freesewing/sandy",
"version": "2.0.0-beta.29",
"description": "A FreeSewing pattern for a circle skirt",
"author": "Joost De Cock <joost@decock.org> (https://github.com/joostdecock)",
"homepage": "https://freesewing.org/",
"repository": "github:freesewing/freesewing",
"license": "MIT",
"bugs": {
"url": "https://github.com/freesewing/freesewing/issues"
},
"keywords": [
"freesewing",
"design",
"diy",
"fashion",
"made to measure",
"parametric design",
"pattern",
"sewing",
"sewing pattern"
],
"main": "dist/index.js",
"module": "dist/index.mjs",
"scripts": {
"clean": "rimraf dist",
"build": "npm run clean && rollup -c",
"test": "echo \"sandy: No tests configured. Perhaps you'd like to do this?\" && exit 0",
"pubtest": "npm publish --registry http://localhost:6662",
"pubforce": "npm publish",
"symlink": "mkdir -p ./node_modules/@freesewing && cd ./node_modules/@freesewing && ln -s -f ../../../* . && cd -",
"start": "rollup -c -w",
"netlify": "echo \"Not configured yet\""
},
"peerDependencies": {
"@freesewing/core": "^2.0.0-beta.29",
"@freesewing/plugin-bundle": "^2.0.0-beta.29"
},
"dependencies": {},
"devDependencies": {
"react": "^16.8",
"react-dom": "^16.8",
"@babel/plugin-proposal-class-properties": "^7.0.0",
"babel-eslint": "10.0.1",
"eslint": "^5.16.0",
"babel-jest": "24.7.1",
"jest": "24.7.1",
"@freesewing/components": "^2.0.0-beta.29",
"@freesewing/css-theme": "^2.0.0-beta.29",
"@freesewing/i18n": "^2.0.0-beta.29",
"@freesewing/mui-theme": "^2.0.0-beta.29",
"@freesewing/patterns": "^2.0.0-beta.29",
"@freesewing/plugin-bust": "^2.0.0-beta.29",
"@freesewing/plugin-buttons": "^2.0.0-beta.29",
"@freesewing/plugin-flip": "^2.0.0-beta.29",
"@freesewing/utils": "^2.0.0-beta.29",
"@svgr/rollup": "^2.4.1",
"cross-env": "^5.1.4",
"gh-pages": "^1.2.0",
"react-scripts": "^3.0.0",
"webpack": "4.29.6",
"rollup": "^0.64.1",
"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",
"@material-ui/core": "4.0.1",
"@material-ui/icons": "4.0.1",
"@material-ui/lab": "^v4.0.0-alpha.14",
"react-intl": "2.8.0",
"prop-types": "15.7.2"
},
"files": [
"dist/*",
"README.md",
"package.json"
],
"publishConfig": {
"access": "public",
"tag": "beta"
},
"engines": {
"node": ">=8.0.0",
"npm": ">=5"
}
}

View file

@ -0,0 +1,59 @@
import babel from "rollup-plugin-babel";
import resolve from "rollup-plugin-node-resolve";
import commonjs from "rollup-plugin-commonjs";
import json from "rollup-plugin-json";
import minify from "rollup-plugin-babel-minify";
import yaml from "rollup-plugin-yaml";
import url from "rollup-plugin-url";
import postcss from "rollup-plugin-postcss";
import svgr from "@svgr/rollup";
import peerDepsExternal from "rollup-plugin-peer-deps-external";
import {
name,
version,
description,
author,
license,
main,
module
} from "./package.json";
const output = [
{
file: main,
format: "cjs",
sourcemap: true
}
];
if (typeof module !== "undefined")
output.push({
file: module,
format: "es",
sourcemap: true
});
export default {
input: "src/index.js",
output,
plugins: [
peerDepsExternal(),
resolve({ modulesOnly: true }),
url(),
commonjs(),
json(),
yaml(),
svgr(),
postcss({
modules: true
}),
babel({
exclude: "node_modules/**",
plugins: ["@babel/plugin-proposal-object-rest-spread"]
}),
minify({
comments: false,
sourceMap: true,
banner: `/**\n * ${name} | v${version}\n * ${description}\n * (c) ${new Date().getFullYear()} ${author}\n * @license ${license}\n */`
})
]
};

View file

@ -0,0 +1,13 @@
import freesewing from "@freesewing/core";
import plugins from "@freesewing/plugin-bundle";
import config from "../config";
// Parts
import draftSkirt from "./skirt";
// Create design
const Pattern = new freesewing.Design(config, plugins);
// Attach draft methods to prototype
Pattern.prototype.draftSkirt = part => draftSkirt(part);
export default Pattern;

214
packages/sandy/src/skirt.js Normal file
View file

@ -0,0 +1,214 @@
export default function(part) {
let {
utils,
store,
sa,
Point,
points,
Path,
paths,
Snippet,
snippets,
options,
measurements,
complete,
paperless,
macro
} = part.shorthand();
const roundExtended = (radius, angle = 90) => {
let arg = utils.deg2rad(angle / 2);
return (radius * 4 * (1 - Math.cos(arg))) / Math.sin(arg) / 3;
};
const draftRingSector = (rot, an, radIn, radEx) => {
/**
* Calculates the distance of the control point for the internal
* and external arcs using bezierCircleExtended
*/
let distIn = roundExtended(radIn, an / 2);
let distEx = roundExtended(radEx, an / 2);
// The centre of the circles
points.center = new Point(0, 0);
/**
* This function is expected to draft ring sectors for
* angles up to 180%. Since roundExtended works
* best for angles until 90º, we generate the ring
* sector using the half angle and then duplicate it
*/
/**
* The first point of the internal arc, situated at
* a radIn distance below the centre
*/
points.in1 = points.center.shift(-90, radIn);
/**
* The control point for 'in1'. It's situated at a
* distance $distIn calculated with bezierCircleExtended
* and the line between it and 'in1' is perpendicular to
* the line between 'in1' and the centre, so it's
* shifted in the direction 0º
*/
points.in1C = points.in1.shift(0, distIn);
/**
* The second point of the internal arc, situated at
* a $radIn distance of the centre in the direction
* $an/2 - 90º
*/
points.in2 = points.center.shift(an / 2 - 90, radIn);
/**
* The control point for 'in2'. It's situated at a
* distance $distIn calculated with bezierCircleExtended
* and the line between it and 'in2' is perpendicular to
* the line between 'in2' and the centre, so it's
* shifted in the direction $an/2 + 180º
*/
points.in2C = points.in2.shift(an / 2 + 180, distIn);
/**
* The points for the external arc are generated in the
* same way, using $radEx and $distEx instead
*/
points.ex1 = points.center.shift(-90, radEx);
points.ex1C = points.ex1.shift(0, distEx);
points.ex2 = points.center.shift(an / 2 - 90, radEx);
points.ex2C = points.ex2.shift(an / 2 + 180, distEx);
// Flip all the points to generate the full ring sector
for (let id of ["in2", "in2C", "in1C", "ex1C", "ex2C", "ex2"])
points[id + "Flipped"] = points[id].flipX();
// Rotate all the points an angle rot
for (let id of [
"in1",
"in1C",
"in2",
"in2C",
"ex1",
"ex1C",
"ex2",
"ex2C",
"in2Flipped",
"in2CFlipped",
"in1CFlipped",
"ex1CFlipped",
"ex2CFlipped",
"ex2Flipped"
])
points[id + "Rotated"] = points[id].rotate(rot, points.center);
// Return the path of the full ring sector
return new Path()
.move(points.in2Flipped)
.curve(points.in2CFlipped, points.in1CFlipped, points.in1)
.curve(points.in1C, points.in2C, points.in2)
.line(points.ex2)
.curve(points.ex2C, points.ex1C, points.ex1)
.curve(points.ex1CFlipped, points.ex2CFlipped, points.ex2Flipped)
.close();
};
// Circumference of the top of the waistband, calculated from the waistbandPosition option
store.set(
"topCircumference",
options.waistbandPosition * measurements.hipsCircumference +
(1 - options.waistbandPosition) * measurements.naturalWaist
);
// Circumference of the bottom of the waistband
if (options.waistbandShape === "curved") {
// If the waistband is curved, the bottom circumference is calculated from the measurements
store.set(
"bottomCircumference",
store.get("topCircumference") +
(options.waistbandWidth *
(measurements.hipsCircumference - measurements.naturalWaist)) /
measurements.naturalWaistToHip
);
} else {
// If the waistband is straight, the bottom circumference is the same as the top circumference
store.set("bottomCircumference", store.get("topCircumference"));
}
// The top circumference of the skirt corresponds to the bottom circumference of the waistband, plus the extraWaist option for gathering/pleating
store.set(
"skirtCircumference",
store.get("bottomCircumference") * (1 + options.gathering)
);
// The length from the top of the skirt to the floor (max length available)
store.set(
"fullLength",
measurements.naturalWaistToFloor -
measurements.naturalWaistToHip * options.waistbandPosition
);
console.log("STORE", store.data);
let radiusWaist, an;
if (options.seamlessFullCircle) {
/**
* If the seamless full circle option is selected, the angle
* is 90º, and the radius of the waist arc is half than if
* it's not selected, because in this case the fabric is cut
* in a double fold
*/
an = 90;
radiusWaist = store.get("skirtCircumference") / utils.deg2rad(an) / 4;
} else {
/**
* If the seamless full circle option is not selected, the
* angle is calculated using the circlePercent option
*/
an = 180 * options.circleRatio;
radiusWaist = store.get("skirtCircumference") / utils.deg2rad(an) / 2;
/**
* If the angle is too large, the seam allowance can fall out
* of the fold of the fabric, so we limit the angle to a
* maximum angle calculated so the seam allowance fits in the
* fabric
*/
if (an > 90 && sa) {
let maxAn = utils.rad2deg(Math.atan(radiusWaist / sa));
if (an > 90 + maxAn) an = 90 + maxAn;
}
}
/**
* The radius of the hem arc is the radius of the waist
* arc with the length of the skirt added
*/
let radiusHem =
radiusWaist +
store.get("fullLength") * options.lengthBonus -
options.waistbandWidth;
/**
* The ring sector will be rotated an angle an/2 so we
* display the part with one edge of the skirt vertical
*/
let rot = an / 2;
// Call draftRingSector to draft the part
paths.seam = draftRingSector(rot, an, radiusWaist, radiusHem).attr(
"class",
"fabric"
);
// Anchor samples to the centre of the waist
points.gridAnchor = points.in2Flipped.clone();
// Complete pattern?
if (complete) {
if (sa) {
}
}
// Paperless?
if (paperless) {
}
return part;
}