diff --git a/.gitignore b/.gitignore index 546d8244ba7..a0c924af46d 100644 --- a/.gitignore +++ b/.gitignore @@ -67,3 +67,9 @@ yarn-debug.log* yarn-error.log* lerna-debug.log* packages/core/.nyc_output +packages/i18n/sort.sh +packages/create-freesewing-pattern/index.js +packages/create-freesewing-pattern/lib/cli.js +.gitignore +scripts/taskrunner.sh +scripts/verdaccio.sh diff --git a/packages/create-freesewing-pattern/index.js b/packages/create-freesewing-pattern/index.js old mode 100755 new mode 100644 diff --git a/packages/create-freesewing-pattern/lib/cli.js b/packages/create-freesewing-pattern/lib/cli.js old mode 100755 new mode 100644 diff --git a/packages/i18n/sort.sh b/packages/i18n/sort.sh old mode 100755 new mode 100644 diff --git a/packages/waralee/README.md b/packages/waralee/README.md new file mode 100644 index 00000000000..d3d7540e22c --- /dev/null +++ b/packages/waralee/README.md @@ -0,0 +1,31 @@ +# waralee + +> wrap pants + +[![NPM](https://img.shields.io/npm/v/waralee.svg)](https://www.npmjs.com/package/waralee) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com) + +## Install + +```bash +npm install --save waralee +``` + +## Usage + +```jsx +import React, { Component } from 'react' + +import MyComponent from 'waralee' + +class Example extends Component { + render () { + return ( + + ) + } +} +``` + +## License + + © [woutervdub](https://github.com/woutervdub) diff --git a/packages/waralee/config/index.js b/packages/waralee/config/index.js new file mode 100644 index 00000000000..63a70ea6e47 --- /dev/null +++ b/packages/waralee/config/index.js @@ -0,0 +1,72 @@ +//import { version } from "../package.json"; + +// ?? 🤔 ?? --> https://en.freesewing.dev/packages/core/config + +export default { + name: "waralee", + version: "0.0.1", + design: "woutervdub", + code: "woutervdub", + department: "menswear", + type: "pattern", + difficulty: 3, + tags: [ + "freesewing", + "design", + "diy", + "fashion", + "made to measure", + "parametric design", + "pattern", + "sewing", + "sewing pattern" + ], + optionGroups: { + fit: [ + "waistRaise", + "legShortening", + "waistOverlap", + "crotchFront", + "crotchBack", + "crotchFactorBackHor", + "crotchFactorBackVer", + "crotchFactorFrontHor", + "crotchFactorFrontVer", + "backRaise" + ] + }, + measurements: [ + "hipsCircumference", + "seatCircumference", + "inseam", + "seatDepth" + ], + dependencies: {}, + inject: {pants:"pantsproto"/*,mini:"pantsproto"*/}, + hide: [], + parts: ["cutout", "pocket", "facings"], + options: { + minimizer: 5, + frontPocketVerticalOffset: 0.07, + frontPocketHorizontalOffset: 0.18, + frontPocketSize: 0.65, + frontPocket: { bool: true }, + frontPocketDepthFactor: 1.6, + backPocketVerticalOffset: 0.15, + backPocketHorizontalOffset: 0.045, + backPocketSize: 0.65, + backPocket: { bool: true }, + hem: {mm: 15, min: 0, max: 100}, + waistBand: {mm: 25, min: 0, max: 100}, + waistRaise: { pct: 20, min: 0, max: 40 }, + crotchBack: { pct: 45, min: 10, max: 70 }, + crotchFront: { pct: 30, min: 10, max: 70 }, + crotchFactorFrontHor: { pct: 85, min: 10, max: 100 }, + crotchFactorFrontVer: { pct: 25, min: 10, max: 70 }, + crotchFactorBackHor: { pct: 90, min: 10, max: 100 }, + crotchFactorBackVer: { pct: 60, min: 20, max: 90 }, + waistOverlap: { pct: 50, min: 10, max: 100 }, + legShortening: { pct: 25, min: 0, max: 50 }, + backRaise: { pct: 10, min: 0, max: 25 } + } +}; diff --git a/packages/waralee/example/.babelrc b/packages/waralee/example/.babelrc new file mode 100644 index 00000000000..6e3090a4956 --- /dev/null +++ b/packages/waralee/example/.babelrc @@ -0,0 +1,10 @@ +{ + "plugins": [ + ["prismjs", { + "languages": ["javascript", "css", "markup"], + "plugins": ["line-numbers"], + "theme": "twilight", + "css": true + }] + ] +} diff --git a/packages/waralee/example/README.md b/packages/waralee/example/README.md new file mode 100644 index 00000000000..9dcb1665c16 --- /dev/null +++ b/packages/waralee/example/README.md @@ -0,0 +1,96 @@ +

+Freesewing logo +
+FreeSewing v2 +

+

A JavaScript library for made-to-measure sewing patterns

+

Follow @freesewing_org on Twitter + Chat with us on Gitter + Become a FreeSewing Patron + Follow @freesewing_org on Twitter + +

+ +# waralee 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://test34.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). + diff --git a/packages/waralee/example/package.json b/packages/waralee/example/package.json new file mode 100644 index 00000000000..e93096a0896 --- /dev/null +++ b/packages/waralee/example/package.json @@ -0,0 +1,47 @@ +{ + "name": "waralee-example", + "homepage": "https://woutervdub.github.io/waralee", + "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-theme": "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", + "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" + } +} diff --git a/packages/waralee/example/public/favicon.ico b/packages/waralee/example/public/favicon.ico new file mode 100644 index 00000000000..95061a260f1 Binary files /dev/null and b/packages/waralee/example/public/favicon.ico differ diff --git a/packages/waralee/example/public/index.html b/packages/waralee/example/public/index.html new file mode 100644 index 00000000000..203d45f5303 --- /dev/null +++ b/packages/waralee/example/public/index.html @@ -0,0 +1,40 @@ + + + + + + + + + + + waralee + + + +
+ + + diff --git a/packages/waralee/example/public/manifest.json b/packages/waralee/example/public/manifest.json new file mode 100644 index 00000000000..c5fcfde17bb --- /dev/null +++ b/packages/waralee/example/public/manifest.json @@ -0,0 +1,15 @@ +{ + "short_name": "waralee", + "name": "waralee", + "icons": [ + { + "src": "favicon.ico", + "sizes": "64x64 32x32 24x24 16x16", + "type": "image/x-icon" + } + ], + "start_url": ".", + "display": "standalone", + "theme_color": "#000000", + "background_color": "#ffffff" +} diff --git a/packages/waralee/example/src/App.js b/packages/waralee/example/src/App.js new file mode 100644 index 00000000000..e7936330e5d --- /dev/null +++ b/packages/waralee/example/src/App.js @@ -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 ( + + ); +}; + +export default App; diff --git a/packages/waralee/example/src/App.test.js b/packages/waralee/example/src/App.test.js new file mode 100644 index 00000000000..23c181f0276 --- /dev/null +++ b/packages/waralee/example/src/App.test.js @@ -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(, div); + ReactDOM.unmountComponentAtNode(div); +}); diff --git a/packages/waralee/example/src/index.js b/packages/waralee/example/src/index.js new file mode 100644 index 00000000000..7900787a4d2 --- /dev/null +++ b/packages/waralee/example/src/index.js @@ -0,0 +1,11 @@ +import React from "react"; +import ReactDOM from "react-dom"; +import App from "./App"; +import * as serviceWorker from "./serviceWorker"; + +ReactDOM.render(, 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(); diff --git a/packages/waralee/example/src/serviceWorker.js b/packages/waralee/example/src/serviceWorker.js new file mode 100644 index 00000000000..68fda5a0eb6 --- /dev/null +++ b/packages/waralee/example/src/serviceWorker.js @@ -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(); + }); + } +} diff --git a/packages/waralee/package.json b/packages/waralee/package.json new file mode 100644 index 00000000000..f23caee7b79 --- /dev/null +++ b/packages/waralee/package.json @@ -0,0 +1,66 @@ +{ + "name": "waralee", + "version": "0.0.1", + "description": "", + "author": "woutervdub", + "license": "MIT", + "repository": "woutervdub/waralee", + "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": { + "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/core": "beta", + "@freesewing/plugin-bundle": "beta", + "@freesewing/components": "beta", + "@freesewing/css-theme": "beta", + "@freesewing/i18n": "beta", + "@freesewing/mui-theme": "beta", + "@freesewing/patterns": "beta", + "@freesewing/plugin-bust": "beta", + "@freesewing/plugin-buttons": "beta", + "@freesewing/plugin-debug": "beta", + "@freesewing/plugin-designer": "beta", + "@freesewing/plugin-flip": "beta", + "@freesewing/utils": "beta", + "@svgr/rollup": "^2.4.1", + "cross-env": "^5.1.4", + "gh-pages": "^1.2.0", + "react-scripts": "^3.0.1", + "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", + "file-saver": "^2.0.2" + } +} diff --git a/packages/waralee/rollup.config.js b/packages/waralee/rollup.config.js new file mode 100644 index 00000000000..70c428bd463 --- /dev/null +++ b/packages/waralee/rollup.config.js @@ -0,0 +1,47 @@ +import babel from "rollup-plugin-babel"; +import commonjs from "rollup-plugin-commonjs"; +import external from "rollup-plugin-peer-deps-external"; +import postcss from "rollup-plugin-postcss"; +import json from "rollup-plugin-json"; +import resolve from "rollup-plugin-node-resolve"; +import url from "rollup-plugin-url"; +import svgr from "@svgr/rollup"; +import minify from "rollup-plugin-babel-minify"; +import { name, version, description, author, license } from "./package.json"; + +import pkg from "./package.json"; + +export default { + input: "src/index.js", + output: [ + { + file: pkg.main, + format: "cjs", + sourcemap: true + }, + { + file: pkg.module, + format: "es", + sourcemap: true + } + ], + plugins: [ + external(), + postcss({ + modules: true + }), + url({ exclude: ["**/*.svg"] }), + svgr(), + babel({ + exclude: "node_modules/**" + }), + resolve({ browser: true }), + json(), + commonjs(), + minify({ + comments: false, + sourceMap: true, + banner: `/**\n * ${name} | v${version}\n * ${description}\n * (c) ${new Date().getFullYear()} ${author}\n * @license ${license}\n */` + }) + ] +}; diff --git a/packages/waralee/src/.eslintrc b/packages/waralee/src/.eslintrc new file mode 100644 index 00000000000..55f121d152d --- /dev/null +++ b/packages/waralee/src/.eslintrc @@ -0,0 +1,5 @@ +{ + "env": { + "jest": true + } +} diff --git a/packages/waralee/src/cutout.js b/packages/waralee/src/cutout.js new file mode 100644 index 00000000000..6a79c7a8d9d --- /dev/null +++ b/packages/waralee/src/cutout.js @@ -0,0 +1,84 @@ +import { CreateCrotchPoints } from "./util"; + +export default function(part) { + let { + options, + measurements, + Point, + Path, + points, + paths, + Snippet, + snippets, + complete, + sa, + paperless, + macro + } = part.shorthand(); + + let seatDepth = measurements.seatDepth + (measurements.seatDepth *options.waistRaise ); + + points.mWaist = new Point(0, 0); + points.mHip = points.mWaist.shift(270, seatDepth); + + CreateCrotchPoints(part); + + points.mWaist1 = new Point( points.mWaist.x, points.fWaistSide.y ); + points.mWaist2 = new Point( points.mWaist.x, points.bWaistSide.y ); + + paths.seam = new Path() + .move(points.mWaist1) + .line(points.fWaistSide) + .curve(points.fWaistCrotchCP, points.fHipCrotchCP, points.mHip) + .curve(points.bHipCrotchCP, points.bWaistCrotchCP, points.bWaistSide) + .line(points.mWaist2) + .line(points.mWaist1) + .close() + .attr("class", "fabric"); + + + // Complete? + if (complete) { + points.logo = points.mWaist.shift(270, 75); + snippets.logo = new Snippet("logo", points.logo); + points.text = points.logo + .shift(-90, 25) + .attr("data-text", "Waralee") + .attr("data-text-class", "center"); + + if (sa) { + paths.seamAlternate = new Path() + .move(points.bWaistSide) + .curve(points.bWaistCrotchCP, points.bHipCrotchCP, points.mHip) + .curve(points.fHipCrotchCP, points.fWaistCrotchCP, points.fWaistSide); + + paths.sa = paths.seamAlternate.offset(sa).attr("class", "fabric sa"); + } + } + + // Paperless? + if (paperless) { + macro("hd", { + from: points.fWaistSide, + to: points.mWaist, + y: points.mWaist.y + }); + macro("hd", { + from: points.mWaist, + to: points.bWaistSide, + y: points.mWaist.y + }); + macro("vd", { + from: points.mWaist1, + to: points.mHip, + x: points.mWaist.x + }); + macro("vd", { + from: points.mWaist2, + to: points.mWaist1, + x: points.mWaist.x +15 + }); + } + + return part; +} diff --git a/packages/waralee/src/facings.js b/packages/waralee/src/facings.js new file mode 100644 index 00000000000..19c58141d63 --- /dev/null +++ b/packages/waralee/src/facings.js @@ -0,0 +1,99 @@ +export default function(part) { + let { + options, + measurements, + Point, + Path, + points, + paths, + /*Snippet,*/ + snippets, + complete, + /*sa,*/ + paperless, + macro + } = part.shorthand(); + + let frontPocketSize = options.frontPocketSize * measurements.seatDepth; + let backPocketSize = options.backPocketSize * measurements.seatDepth; + + points.frontTL = new Point(0, 0); + points.frontTR = points.frontTL.shift(0, frontPocketSize + 24); + points.frontBL = points.frontTL.shift(270, frontPocketSize / 2); + points.frontBR = points.frontTR.shift(270, frontPocketSize / 2); + + points.backTL = points.frontBL.shift(270, 50); + points.backTR = points.backTL.shift(0, backPocketSize + 24); + points.backBL = points.backTL.shift(270, backPocketSize / 2); + points.backBR = points.backTR.shift(270, backPocketSize / 2); + + paths.frontSeam = new Path() + .move(points.frontTL) + .line(points.frontBL) + .line(points.frontBR) + .line(points.frontTR) + .line(points.frontTL) + .close() + .attr("class", "fabric"); + paths.backSeam = new Path() + .move(points.backTL) + .line(points.backBL) + .line(points.backBR) + .line(points.backTR) + .line(points.backTL) + .close() + .attr("class", "fabric"); + + // Complete? + if (complete) { + points.frontTitle = points.frontTL.shift(270, 15).shift(0, 50); + macro("title", { + at: points.frontTitle.shift(0,30), + title: "1x fromFabric" + }); + points.frontLogo = points.frontTitle.shift(270, 15); + snippets.frontLogo = new Snippet("logo", points.frontLogo).attr("data-scale", 0.4); + points.frontText = points.frontLogo + .shift(-90, 25) + .attr("data-text", "Waralee") + .attr("data-text-class", "center"); + + points.backTitle = points.backTL.shift(270, 15).shift(0, 50); + macro("title", { + at: points.backTitle.shift(0,30), + title: "1x fromFabric" + }); + points.backLogo = points.backTitle.shift(270, 15); + snippets.backLogo = new Snippet("logo", points.backLogo).attr("data-scale", 0.4); + points.backText = points.backLogo + .shift(-90, 25) + .attr("data-text", "Waralee") + .attr("data-text-class", "center"); + } + + // Paperless? + if (paperless) { + macro("hd", { + from: points.frontTL, + to: points.frontTR, + y: points.frontTL.y + 15 + }); + macro("hd", { + from: points.backTL, + to: points.backTR, + y: points.backTL.y + 15 + }); + macro("vd", { + from: points.frontTL, + to: points.frontBL, + x: points.frontTL.x + 15 + }); + macro("vd", { + from: points.backTL, + to: points.backBL, + x: points.backTL.x + 15 + }); + } + + return part; +} diff --git a/packages/waralee/src/index.js b/packages/waralee/src/index.js new file mode 100644 index 00000000000..a7719ebb6e2 --- /dev/null +++ b/packages/waralee/src/index.js @@ -0,0 +1,22 @@ +import freesewing from "@freesewing/core"; +import plugins from "@freesewing/plugin-bundle"; +import config from "../config"; +import draftPantsproto from "./pantsproto"; +import draftPants from "./pants"; +import draftCutout from "./cutout"; +import draftPocket from "./pocket"; +import draftFacings from "./facings"; +//import draftMini from "./mini"; + +// Create new design +const Pattern = new freesewing.Design(config, plugins); + +// Attach the draft methods to the prototype +Pattern.prototype.draftPantsproto = draftPantsproto; +Pattern.prototype.draftPants = draftPants; +Pattern.prototype.draftCutout = draftCutout; +Pattern.prototype.draftPocket = draftPocket; +Pattern.prototype.draftFacings = draftFacings; +//Pattern.prototype.draftMini = draftMini; + +export default Pattern; diff --git a/packages/waralee/src/mini.js b/packages/waralee/src/mini.js new file mode 100644 index 00000000000..49f8e48f3a6 --- /dev/null +++ b/packages/waralee/src/mini.js @@ -0,0 +1,158 @@ +// This is an idea to keep the printing to a minimum. The whole patterns is rather large. +// To keep you from printing it completely, you could print this part in paperless mode +// and only have a single sheet with all the dimensions on it. + +export default function(part) { + let { + options, + /*measurements, + Point, + Path,*/ + points, + paths, + Snippet, + snippets, + complete, + sa, + paperless, + macro + } = part.shorthand(); + + let mini = options.minimizer; + + for( var p in points ) { + points[p].x = points[p].x /mini; + points[p].y = points[p].y /mini; + } + + + paths.waistFoldBack = paths.waistBack + .offset(-1 * options.waistBand/mini) + .attr("class", "fabric stroke-sm"); + paths.waistFoldFront = paths.waistFront + .offset(-1 * options.waistBand/mini) + .attr("class", "fabric stroke-sm"); + + paths.frontFold = paths.front + .offset(-1 * options.hem/mini) + .attr("class", "fabric stroke-sm"); + paths.legFold = paths.leg + .offset(-1 * options.hem/mini) + .attr("class", "fabric stroke-sm"); + paths.backFold = paths.back + .offset(-1 * options.hem/mini) + .attr("class", "fabric stroke-sm"); + + + + // Complete? + if (complete) { + points.logo = points.fWaistFront.shift(270, 400); + snippets.logo = new Snippet("logo", points.logo); + points.text = points.logo + .shift(-90, 50) + .attr("data-text", "hello") + .attr("data-text-class", "center"); + + if (sa) { + paths.sa = paths.seam.offset(sa).attr("class", "fabric sa"); + } + } + + // Paperless? + if (paperless) { + macro("hd", { + from: points.fWaistSide, + to: points.mWaist, + y: points.fWaistSide.y, + text: part.units(points.fWaistSide.dist(points.mWaist)*mini) + }); + /* + macro("hd", { + from: points.fWaistFrontOverlap, + to: points.mWaist, + y: points.fWaistSide.y - sa - 15 + }); + macro("hd", { + from: points.mWaist, + to: points.bWaistSide, + y: points.bWaistSide.y + }); + macro("hd", { + from: points.mWaist, + to: points.bWaistBack, + y: points.bWaistSide.y - sa - 15 + }); + macro("hd", { + from: points.mWaist, + to: points.bWaistBackOverlap, + y: points.bWaistSide.y - sa - 30 + }); + macro("vd", { + from: points.mWaist, + to: points.mHip, + x: points.mWaist.x + }); + macro("vd", { + from: points.bWaistSide, + to: points.bWaistBack, + x: points.bWaistSide.x + 15 + }); + macro("vd", { + from: points.bWaistBackOverlap, + to: points.bLegBackOverlap, + x: points.bLegBackOverlap.x - 30 + }); + + if (options.frontPocket) { + macro("vd", { + from: points.fWaistSide, + to: points.frontPocketTop, + x: points.frontPocketTop.x + }); + macro("vd", { + from: points.fWaistSide, + to: points.frontPocketBottom, + x: points.frontPocketBottom.x + }); + macro("hd", { + from: points.frontPocketTop, + to: points.fWaistSide, + y: points.frontPocketTop.y + }); + macro("hd", { + from: points.frontPocketBottom, + to: points.fWaistSide, + y: points.frontPocketBottom.y + }); + } + if (options.backPocket) { + macro("vd", { + from: points.bWaistSide, + to: points.backPocketLeft, + x: points.backPocketLeft.x + }); + macro("vd", { + from: points.bWaistSide, + to: points.backPocketRight, + x: points.backPocketRight.x + }); + macro("hd", { + from: points.bWaistSide, + to: points.backPocketLeft, + y: points.backPocketLeft.y + }); + macro("hd", { + from: points.bWaistSide, + to: points.backPocketRight, + y: points.backPocketRight.y + }); + } + */ + } + + // keep this secret for now: + part.render = false; + + return part; +} diff --git a/packages/waralee/src/pants.js b/packages/waralee/src/pants.js new file mode 100644 index 00000000000..29d4ae104d1 --- /dev/null +++ b/packages/waralee/src/pants.js @@ -0,0 +1,141 @@ +export default function(part) { + let { + options, + /*measurements, + Point, + Path,*/ + points, + paths, + Snippet, + snippets, + complete, + sa, + paperless, + macro + } = part.shorthand(); + + + paths.waistFoldBack = paths.waistBack + .offset(-1 * options.waistBand) + .attr("class", "fabric stroke-sm"); + paths.waistFoldFront = paths.waistFront + .offset(-1 * options.waistBand) + .attr("class", "fabric stroke-sm"); + + paths.frontFold = paths.front + .offset(-1 * options.hem) + .attr("class", "fabric stroke-sm"); + paths.legFold = paths.leg + .offset(-1 * options.hem) + .attr("class", "fabric stroke-sm"); + paths.backFold = paths.back + .offset(-1 * options.hem) + .attr("class", "fabric stroke-sm"); + + + + // Complete? + if (complete) { + points.logo = points.fWaistFront.shift(270, 400); + snippets.logo = new Snippet("logo", points.logo); + points.text = points.logo + .shift(-90, 50) + .attr("data-text", "hello") + .attr("data-text-class", "center"); + + if (sa) { + paths.sa = paths.seam.offset(sa).attr("class", "fabric sa"); + } + } + + // Paperless? + if (paperless) { + macro("hd", { + from: points.fWaistSide, + to: points.mWaist, + y: points.fWaistSide.y + }); + macro("hd", { + from: points.fWaistFrontOverlap, + to: points.mWaist, + y: points.fWaistSide.y - sa - 15 + }); + macro("hd", { + from: points.mWaist, + to: points.bWaistSide, + y: points.bWaistSide.y + }); + macro("hd", { + from: points.mWaist, + to: points.bWaistBack, + y: points.bWaistSide.y - sa - 15 + }); + macro("hd", { + from: points.mWaist, + to: points.bWaistBackOverlap, + y: points.bWaistSide.y - sa - 30 + }); + macro("vd", { + from: points.mWaist, + to: points.mHip, + x: points.mWaist.x + }); + macro("vd", { + from: points.bWaistSide, + to: points.bWaistBack, + x: points.bWaistSide.x + 15 + }); + macro("vd", { + from: points.bWaistBackOverlap, + to: points.bLegBackOverlap, + x: points.bLegBackOverlap.x - 30 + }); + + if (options.frontPocket) { + macro("vd", { + from: points.fWaistSide, + to: points.frontPocketTop, + x: points.frontPocketTop.x + }); + macro("vd", { + from: points.fWaistSide, + to: points.frontPocketBottom, + x: points.frontPocketBottom.x + }); + macro("hd", { + from: points.frontPocketTop, + to: points.fWaistSide, + y: points.frontPocketTop.y + }); + macro("hd", { + from: points.frontPocketBottom, + to: points.fWaistSide, + y: points.frontPocketBottom.y + }); + } + if (options.backPocket) { + macro("vd", { + from: points.bWaistSide, + to: points.backPocketLeft, + x: points.backPocketLeft.x + }); + macro("vd", { + from: points.bWaistSide, + to: points.backPocketRight, + x: points.backPocketRight.x + }); + macro("hd", { + from: points.bWaistSide, + to: points.backPocketLeft, + y: points.backPocketLeft.y + }); + macro("hd", { + from: points.bWaistSide, + to: points.backPocketRight, + y: points.backPocketRight.y + }); + } + } + + return part; +} diff --git a/packages/waralee/src/pantsproto.js b/packages/waralee/src/pantsproto.js new file mode 100644 index 00000000000..b9ed0dc1feb --- /dev/null +++ b/packages/waralee/src/pantsproto.js @@ -0,0 +1,189 @@ +import { CreateCrotchPoints } from "./util"; + +export default function(part) { + let { + options, + measurements, + Point, + Path, + points, + paths/*, + Snippet, + snippets, + complete, + sa, + paperless, + macro*/ + } = part.shorthand(); + + let seatDepth = + measurements.seatDepth + measurements.seatDepth * options.waistRaise; + let circumference = measurements.seatCircumference; + let circumference4 = circumference / 4; + + points.mWaist = new Point(0, 0); + + CreateCrotchPoints(part); + + points.mLeg = points.mHip.shift(270, measurements.inseam); + points.fLegSide = points.mLeg.shift( + 180, + options.crotchFront * circumference4 + ); + points.bLegSide = points.mLeg.shift(0, options.crotchBack * circumference4); + + points.fWaistFront = points.fWaistSide.shift(180, circumference4); + points.fWaistFrontOverlap = points.fWaistFront.shift( + 180, + options.waistOverlap * circumference4 + ); + points.fHipFront = points.fHipSide.shift(180, circumference4); + points.fHipFrontOverlap = points.fHipFront.shift( + 180, + options.waistOverlap * circumference4 + ); + points.fLegFront = points.fLegSide.shift(180, circumference4); + points.fLegFrontOverlap = points.fLegFront.shift( + 180, + options.waistOverlap * circumference4 + ); + + // Calculate the distance we need to move horizontally to get to the point that will + // diagonally be the distance we're looking for (circumference/4) + let bHorDistance = Math.sqrt( + circumference4 * circumference4 - + options.backRaise * seatDepth * options.backRaise * seatDepth + ); + // Create a point that is this distance from the side. + points.bWaistBack = points.mWaist + .shift(90, options.waistBand) + .shift(0, options.crotchBack * circumference4 + bHorDistance); + + points.bWaistBackOverlap = points.bWaistBack.shift( + 0, + options.waistOverlap * circumference4 + ); + + points.bHipBack = points.bHipSide.shift(0, circumference4); + points.bHipBackOverlap = points.bHipBack.shift( + 0, + options.waistOverlap * circumference4 + ); + points.bLegBack = points.bLegSide.shift(0, circumference4); + points.bLegBackOverlap = points.bLegBack.shift( + 0, + options.waistOverlap * circumference4 + ); + + points.bWaistSideTemp = points.bWaistSide.shift(0, 2); // This is a trick to make the offset() call work. Without it, the offset is crossing the cutout line. + paths.waistBack = new Path() + .move(points.bWaistBackOverlap) + .line(points.bWaistBack) + .line(points.bWaistSideTemp) // This is a trick to make the offset() call work. Without it, the offset is crossing the cutout line. + .line(points.bWaistSide) + .setRender( false ); + paths.waistFront = new Path() + .move(points.fWaistSide) + .line(points.fWaistFront) + .line(points.fWaistFrontOverlap) + .setRender( false ); + paths.front = new Path() + .move(points.fWaistFrontOverlap) + .line(points.fHipFrontOverlap) + .line(points.fLegFrontOverlap) + .setRender( false ); + paths.back = new Path() + .move(points.bLegBackOverlap) + .line(points.bHipBackOverlap) + .line(points.bWaistBackOverlap) + .setRender( false ); + paths.leg = new Path() + .move(points.fLegFrontOverlap) + .line(points.bLegBackOverlap) + .setRender( false ); + paths.cutout = new Path() + .move(points.bWaistSide) + .curve(points.bWaistCrotchCP, points.bHipCrotchCP, points.mHip) + .curve(points.fHipCrotchCP, points.fWaistCrotchCP, points.fWaistSide) + .setRender( false ); + + paths.seam = paths.waistFront + .join(paths.front) + .join(paths.leg) + .join(paths.back) + .join(paths.waistBack) + .join(paths.cutout) + .close() + .attr("class", "fabric"); + if (options.frontPocket) { + points.frontPocketTop = points.fWaistSide + .shift( + 270, + options.frontPocketVerticalOffset * measurements.seatDepth + + options.waistBand * 2 + ) + .shift( + 180, + options.frontPocketHorizontalOffset * measurements.seatCircumference + ); + + points.frontPocketTop2 = points.frontPocketTop.shift(340, 12); + points.frontPocketBottom = points.frontPocketTop.shift( + 250, + options.frontPocketSize * measurements.seatDepth + ); + points.frontPocketBottom2 = points.frontPocketBottom.shift(340, 12); + + paths.frontPocket = new Path() + .move(points.frontPocketTop) + .line(points.frontPocketBottom) + .line(points.frontPocketBottom2) + .line(points.frontPocketTop2) + .close() + .attr("class", "fabric"); + } + + if (options.backPocket) { + points.backPocketRight = points.bWaistBack + .shiftTowards( + points.bWaistSide, + options.backPocketHorizontalOffset * measurements.seatCircumference + ) + .shift( + 270, + options.backPocketVerticalOffset * measurements.seatDepth + + options.waistBand * 2 + ); + points.backPocketLeft = points.bWaistBack + .shiftTowards( + points.bWaistSide, + options.backPocketHorizontalOffset * measurements.seatCircumference + + options.backPocketSize * measurements.seatDepth + ) + .shift( + 270, + options.backPocketVerticalOffset * measurements.seatDepth + + options.waistBand * 2 + ); + points.backPocketRight2 = points.backPocketRight.shift( + points.backPocketRight.angle(points.backPocketLeft) + 90, + 12 + ); + points.backPocketLeft2 = points.backPocketLeft.shift( + points.backPocketLeft.angle(points.backPocketRight) - 90, + 12 + ); + + paths.backPocket = new Path() + .move(points.backPocketLeft) + .line(points.backPocketLeft2) + .line(points.backPocketRight2) + .line(points.backPocketRight) + .close() + .attr("class", "fabric"); + } + + part.render = false; + + return part; +} diff --git a/packages/waralee/src/pocket.js b/packages/waralee/src/pocket.js new file mode 100644 index 00000000000..fddf294ff44 --- /dev/null +++ b/packages/waralee/src/pocket.js @@ -0,0 +1,98 @@ +export default function(part) { + let { + options, + measurements, + Point, + Path, + points, + paths, + Snippet, + snippets, + complete, + sa, + paperless, + macro + } = part.shorthand(); + + let pocketDepth = measurements.seatDepth * options.frontPocketDepthFactor; + + points.topLeft = new Point(0, 0); + points.bottomLeft = points.topLeft.shift(270, pocketDepth); + + points.topRight = points.topLeft.shift(0, pocketDepth * (1 / 3)); + points.bottomRight = points.topRight.shift(290, pocketDepth *(5/6)); + + points.bottomLeftCP = points.bottomLeft.shift(0, pocketDepth * (1 / 6)); + points.bottomRightCP = points.bottomRight.shift(225, pocketDepth * (1 / 4)); + + paths.seam = new Path() + .move(points.topLeft) + .line(points.bottomLeft) + .curve(points.bottomLeftCP, points.bottomRightCP, points.bottomRight) + .line(points.topRight) + .line(points.topLeft) + .close() + .attr("class", "fabric"); + + // Complete? + if (complete) { + macro("cutonfold", { + from: points.topLeft, + to: points.bottomLeft, + margin: 5, + offset: 10 + }); + points.title = points.topLeft.shift(270, 75).shift(0, 50); + macro("title", { + at: points.title, + title: "1x " + "cutOnFold" + " " + "fromFabric" + }); + + points.logo = points.title.shift(270, 75); + snippets.logo = new Snippet("logo", points.logo); + points.text = points.logo + .shift(-90, 25) + .attr("data-text", "Waralee") + .attr("data-text-class", "center"); + + if (sa) { + paths.sa = new Path() + .move(points.bottomLeft) + .join( new Path() + .move(points.bottomLeft) + .curve(points.bottomLeftCP, points.bottomRightCP, points.bottomRight) + .line(points.topRight) + .line(points.topLeft) + .offset(sa) + ) + .line(points.topLeft) + .attr("class", "fabric sa"); + } + } + + // Paperless? + if (paperless) { + macro("hd", { + from: points.topLeft, + to: points.topRight, + y: points.topLeft.y + 15 + }); + macro("hd", { + from: points.bottomLeft, + to: points.bottomRight, + y: points.bottomRight.y + }); + macro("vd", { + from: points.topLeft, + to: points.bottomLeft, + x: points.topLeft.x + 15 + }); + macro("vd", { + from: points.topRight, + to: points.bottomRight, + x: points.bottomRight.x + }); + } + + return part; +} diff --git a/packages/waralee/src/util.js b/packages/waralee/src/util.js new file mode 100644 index 00000000000..54418e0cb76 --- /dev/null +++ b/packages/waralee/src/util.js @@ -0,0 +1,35 @@ +function CreateCrotchPoints(part) { + let { options, measurements, points } = part.shorthand(); + + let seatDepth = measurements.seatDepth + (measurements.seatDepth *options.waistRaise ); + let circumference = measurements.seatCircumference; + let circumference4 = circumference / 4; + + points.mHip = points.mWaist.shift(270, seatDepth); + + points.fWaistSide = points.mWaist + .shift(180, options.crotchFront * circumference4) + .shift( 90, options.waistBand ); + points.fWaistCrotchCP = points.fWaistSide.shift( + 270, + seatDepth * options.crotchFactorFrontVer +options.waistBand + ); + points.fHipCrotchCP = points.mHip + .shift(180,options.crotchFront * circumference4 * options.crotchFactorFrontHor); + + points.fHipSide = points.mHip + .shift(180, options.crotchFront * circumference4 ); + + points.bWaistSide = points.mWaist + .shift( 0, options.crotchBack * circumference4) + .shift(90, options.waistBand ) + .shift(90, options.backRaise * seatDepth); + points.bWaistCrotchCP = points.bWaistSide + .shift(270, seatDepth * options.crotchFactorBackVer ); + points.bHipCrotchCP = points.mHip + .shift(0,options.crotchBack * circumference4 * options.crotchFactorBackHor); + + points.bHipSide = points.mHip.shift(0, options.crotchBack * circumference4 ); +} + +export { CreateCrotchPoints }; diff --git a/scripts/taskrunner.sh b/scripts/taskrunner.sh old mode 100755 new mode 100644 diff --git a/scripts/verdaccio.sh b/scripts/verdaccio.sh old mode 100755 new mode 100644