├── .babelrc ├── .editorconfig ├── .eslintrc ├── .github ├── FUNDING.yml └── ISSUE_TEMPLATE │ └── config.yml ├── .gitignore ├── LICENSE ├── README.md ├── config └── index.js ├── dist ├── index.js ├── index.js.map ├── index.mjs └── index.mjs.map ├── example ├── .babelrc ├── README.md ├── package-lock.json ├── package.json ├── public │ ├── App.js │ ├── favicon.ico │ ├── index.html │ └── manifest.json └── src │ ├── App.js │ ├── index.js │ └── serviceWorker.js ├── package-lock.json ├── package.json ├── rollup.config.js └── src ├── .eslintrc ├── box.js └── index.js /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | ["@babel/preset-env", { 4 | "modules": false 5 | }], 6 | "@babel/preset-react" 7 | ], 8 | "plugins": ["@babel/plugin-proposal-class-properties"] 9 | } -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | indent_style = space 6 | indent_size = 2 7 | end_of_line = lf 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "parser": "babel-eslint", 3 | "extends": [ 4 | "standard", 5 | "standard-react" 6 | ], 7 | "env": { 8 | "es6": true 9 | }, 10 | "plugins": [ 11 | "react" 12 | ], 13 | "parserOptions": { 14 | "sourceType": "module" 15 | }, 16 | "rules": { 17 | // don't force es6 functions to include space before paren 18 | "space-before-function-paren": 0, 19 | 20 | // allow specifying true explicitly for boolean props 21 | "react/jsx-boolean-value": 0 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | custom: https://freesewing.org/patrons/join 2 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | contact_links: 3 | - name: Create issues on our monorepo 4 | url: https://github.com/freesewing/freesewing/issues/new/choose 5 | about: We prefer if you create all FreeSewing issues on the freesewing monorepo. It's easier for us to keep track of things this way. 6 | - name: Chat on Discord 7 | url: https://chat.freesewing.org/ 8 | about: Reach out to us on Discord if you need help or have questions 9 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Example 2 | example/node_modules 3 | example/build 4 | # Logs 5 | logs 6 | *.log 7 | npm-debug.log* 8 | yarn-debug.log* 9 | yarn-error.log* 10 | 11 | # Runtime data 12 | pids 13 | *.pid 14 | *.seed 15 | *.pid.lock 16 | 17 | # Directory for instrumented libs generated by jscoverage/JSCover 18 | lib-cov 19 | 20 | # Coverage directory used by tools like istanbul 21 | coverage 22 | 23 | # nyc test coverage 24 | .nyc_output 25 | 26 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 27 | .grunt 28 | 29 | # Bower dependency directory (https://bower.io/) 30 | bower_components 31 | 32 | # node-waf configuration 33 | .lock-wscript 34 | 35 | # Compiled binary addons (https://nodejs.org/api/addons.html) 36 | build/Release 37 | 38 | # Dependency directories 39 | node_modules/ 40 | jspm_packages/ 41 | 42 | # TypeScript v1 declaration files 43 | typings/ 44 | 45 | # Optional npm cache directory 46 | .npm 47 | 48 | # Optional eslint cache 49 | .eslintcache 50 | 51 | # Optional REPL history 52 | .node_repl_history 53 | 54 | # Output of 'npm pack' 55 | *.tgz 56 | 57 | # Yarn Integrity file 58 | .yarn-integrity 59 | 60 | # dotenv environment variables file 61 | .env 62 | 63 | # next.js build output 64 | .next 65 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Joost De Cock 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | Freesewing logo 3 |
4 | FreeSewing 5 |

6 |

A JavaScript library for made-to-measure sewing patterns

7 |

Follow @freesewing_org on Twitter 12 | Chat with us on Discord 17 | Become a FreeSewing Patron 22 | Follow @freesewing_org on Twitter 27 |

28 | 29 | # pattern 30 | 31 | A (template repository for a) FreeSewing pattern 32 | 33 | ## Getting started 34 | 35 | There are two ways to bootstrap your FreeSewing pattern. 36 | 37 | ### Initialize via NPM 38 | 39 | Run the following command: 40 | 41 | ```sh 42 | npm init freesewing-pattern@beta 43 | ``` 44 | 45 | And follow the instructions 46 | 47 | ### Clone our template repository 48 | 49 | You can use [this pattern repository template](https://github.com/freesewing/pattern/generate) 50 | as a starting point for your pattern. After cloning the repository, follow these steps: 51 | 52 | - Run `npm install` in the root folder of the repository 53 | - Run `npm install` in the `example` folder 54 | - Run `npm start` in the root folder of the repository (keep it running) 55 | - Run `npm start` in the `example` folder (in a new terminal) 56 | 57 | Your browser will open [http://localhost:3000](http://localhost:3000/) and serve the development environment. 58 | 59 | ## Where to get help 🤯 60 | 61 | Our [chatroom on Discord](https://discord.freesewing.org/) is the best place to ask questions, 62 | share your feedback, or just hang out. 63 | 64 | If you want to report a problem, please [create an issue](https://github.com/freesewing/freesewing/issues/new). 65 | 66 | ## About FreeSewing 🤔 67 | 68 | Where the world of makers and developers collide, that's where you'll find FreeSewing. 69 | 70 | Our [core library](https://freesewing.dev/) is a *batteries-included* toolbox 71 | for parametric design of sewing patterns. It's a modular system (check our list 72 | of [plugins](https://freesewing.dev/plugins) and getting started is as simple as: 73 | 74 | ```bash 75 | npm init freesewing-pattern 76 | ``` 77 | 78 | or clone this repository. 79 | 80 | The [getting started](https://freesewing.dev/start) section on [freesewing.dev](https://freesewing.dev/) is a good 81 | entrypoint to our documentation, but you'll find a lot more there, including 82 | our [API documentation](https://freesewing.dev/api), 83 | as well as [a tutorial](https://freesewing.dev/tutorial), 84 | and [best practices](https://freesewing.dev/do). 85 | 86 | If you're a maker, checkout [freesewing.org](https://freesewing/) where you can generate 87 | our sewing patterns adapted to your measurements. 88 | 89 | ## Support FreeSewing: Become a patron 🥰 90 | 91 | FreeSewing is an open source project run by a community, 92 | and financially supported by our patrons. 93 | 94 | If you feel what we do is worthwhile, you too 95 | should [become a patron](https://freesewing.org/patrons/join). 96 | 97 | ## Links 👩‍💻 98 | 99 | - 💻 Makers website: [freesewing.org](https://freesewing.org) 100 | - 💻 Developers website: [freesewing.dev](https://freesewing.org) 101 | - 💬 Chat: On Discord via [discord.freesewing.org](https://discord.freesewing.org/) 102 | - 🐦 Twitter: [@freesewing_org](https://twitter.com/freesewing_org) 103 | - 📷 Instagram: [@freesewing_org](https://instagram.com/freesewing_org) 104 | 105 | ## License: MIT 🤓 106 | 107 | © [Joost De Cock](https://github.com/joostdecock). 108 | See [the license file](https://github.com/freesewing/freesewing/blob/develop/LICENSE) for details. 109 | 110 | -------------------------------------------------------------------------------- /config/index.js: -------------------------------------------------------------------------------- 1 | import { version } from "../package.json"; 2 | 3 | // ?? 🤔 ?? --> https://{{language}}.freesewing.dev/packages/core/config 4 | 5 | export default { 6 | name: "{{name}}", 7 | version, 8 | design: "{{author}}", 9 | code: "{{author}}", 10 | department: "{{department}}", 11 | type: "{{type}}", 12 | difficulty: 3, 13 | tags: [ 14 | "freesewing", 15 | "design", 16 | "diy", 17 | "fashion", 18 | "made to measure", 19 | "parametric design", 20 | "{{type}}", 21 | "sewing", 22 | "sewing pattern" 23 | ], 24 | optionGroups: { 25 | fit: ["size"] 26 | }, 27 | measurements: [], 28 | dependencies: {}, 29 | inject: {}, 30 | hide: [], 31 | parts: ["box"], 32 | options: { 33 | size: { pct: 50, min: 10, max: 100 } 34 | } 35 | }; 36 | -------------------------------------------------------------------------------- /dist/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } 4 | 5 | var freesewing = _interopDefault(require('@freesewing/core')); 6 | var plugins = _interopDefault(require('@freesewing/plugin-bundle')); 7 | 8 | var version = "0.0.0"; 9 | 10 | var config = { 11 | name: "{{name}}", 12 | version: version, 13 | design: "{{author}}", 14 | code: "{{author}}", 15 | department: "{{department}}", 16 | type: "{{type}}", 17 | difficulty: 3, 18 | tags: ["freesewing", "design", "diy", "fashion", "made to measure", "parametric design", "{{type}}", "sewing", "sewing pattern"], 19 | optionGroups: { 20 | fit: ["size"] 21 | }, 22 | measurements: [], 23 | dependencies: {}, 24 | inject: {}, 25 | hide: [], 26 | parts: ["box"], 27 | options: { 28 | size: { 29 | pct: 50, 30 | min: 10, 31 | max: 100 32 | } 33 | } 34 | }; 35 | 36 | function draftBox (part) { 37 | var _part$shorthand = part.shorthand(), 38 | options = _part$shorthand.options, 39 | Point = _part$shorthand.Point, 40 | Path = _part$shorthand.Path, 41 | points = _part$shorthand.points, 42 | paths = _part$shorthand.paths, 43 | Snippet = _part$shorthand.Snippet, 44 | snippets = _part$shorthand.snippets, 45 | complete = _part$shorthand.complete, 46 | sa = _part$shorthand.sa, 47 | paperless = _part$shorthand.paperless, 48 | macro = _part$shorthand.macro; 49 | 50 | var w = 500 * options.size; 51 | points.topLeft = new Point(0, 0); 52 | points.topRight = new Point(w, 0); 53 | points.bottomLeft = new Point(0, w / 2); 54 | points.bottomRight = new Point(w, w / 2); 55 | paths.seam = new Path().move(points.topLeft).line(points.bottomLeft).line(points.bottomRight).line(points.topRight).line(points.topLeft).close().attr("class", "fabric"); // Complete? 56 | 57 | if (complete) { 58 | points.logo = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5); 59 | snippets.logo = new Snippet("logo", points.logo); 60 | points.text = points.logo.shift(-90, w / 8).attr("data-text", "hello").attr("data-text-class", "center"); 61 | 62 | if (sa) { 63 | paths.sa = paths.seam.offset(sa).attr("class", "fabric sa"); 64 | } 65 | } // Paperless? 66 | 67 | 68 | if (paperless) { 69 | macro("hd", { 70 | from: points.bottomLeft, 71 | to: points.bottomRight, 72 | y: points.bottomLeft.y + sa + 15 73 | }); 74 | macro("vd", { 75 | from: points.bottomRight, 76 | to: points.topRight, 77 | x: points.topRight.x + sa + 15 78 | }); 79 | } 80 | 81 | return part; 82 | } 83 | 84 | var Pattern = new freesewing.Design(config, plugins); // Attach the draft methods to the prototype 85 | 86 | Pattern.prototype.draftBox = draftBox; 87 | 88 | module.exports = Pattern; 89 | //# sourceMappingURL=index.js.map 90 | -------------------------------------------------------------------------------- /dist/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sources":["../config/index.js","../src/box.js","../src/index.js"],"sourcesContent":["import { version } from \"../package.json\";\n\n// ?? 🤔 ?? --> https://{{language}}.freesewing.dev/packages/core/config\n\nexport default {\n name: \"{{name}}\",\n version,\n design: \"{{author}}\",\n code: \"{{author}}\",\n department: \"{{department}}\",\n type: \"{{type}}\",\n difficulty: 3,\n tags: [\n \"freesewing\",\n \"design\",\n \"diy\",\n \"fashion\",\n \"made to measure\",\n \"parametric design\",\n \"{{type}}\",\n \"sewing\",\n \"sewing pattern\"\n ],\n optionGroups: {\n fit: [\"size\"]\n },\n measurements: [],\n dependencies: {},\n inject: {},\n hide: [],\n parts: [\"box\"],\n options: {\n size: { pct: 50, min: 10, max: 100 }\n }\n};\n","export default function(part) {\n let {\n options,\n Point,\n Path,\n points,\n paths,\n Snippet,\n snippets,\n complete,\n sa,\n paperless,\n macro\n } = part.shorthand();\n\n let w = 500 * options.size;\n points.topLeft = new Point(0, 0);\n points.topRight = new Point(w, 0);\n points.bottomLeft = new Point(0, w / 2);\n points.bottomRight = new Point(w, w / 2);\n\n paths.seam = new Path()\n .move(points.topLeft)\n .line(points.bottomLeft)\n .line(points.bottomRight)\n .line(points.topRight)\n .line(points.topLeft)\n .close()\n .attr(\"class\", \"fabric\");\n\n // Complete?\n if (complete) {\n points.logo = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5);\n snippets.logo = new Snippet(\"logo\", points.logo);\n points.text = points.logo\n .shift(-90, w / 8)\n .attr(\"data-text\", \"hello\")\n .attr(\"data-text-class\", \"center\");\n\n if (sa) {\n paths.sa = paths.seam.offset(sa).attr(\"class\", \"fabric sa\");\n }\n }\n\n // Paperless?\n if (paperless) {\n macro(\"hd\", {\n from: points.bottomLeft,\n to: points.bottomRight,\n y: points.bottomLeft.y + sa + 15\n });\n macro(\"vd\", {\n from: points.bottomRight,\n to: points.topRight,\n x: points.topRight.x + sa + 15\n });\n }\n\n return part;\n}\n","import freesewing from \"@freesewing/core\";\nimport plugins from \"@freesewing/plugin-bundle\";\nimport config from \"../config\";\nimport draftBox from \"./box\";\n\n// Create new design\nconst Pattern = new freesewing.Design(config, plugins);\n\n// Attach the draft methods to the prototype\nPattern.prototype.draftBox = draftBox;\n\nexport default Pattern;\n"],"names":["name","version","design","code","department","type","difficulty","tags","optionGroups","fit","measurements","dependencies","inject","hide","parts","options","size","pct","min","max","part","shorthand","Point","Path","points","paths","Snippet","snippets","complete","sa","paperless","macro","w","topLeft","topRight","bottomLeft","bottomRight","seam","move","line","close","attr","logo","shiftFractionTowards","text","shift","offset","from","to","y","x","Pattern","freesewing","Design","config","plugins","prototype","draftBox"],"mappings":";;;;;;;;;AAIA,aAAe;EACbA,IAAI,EAAE,UADO;EAEbC,OAAO,EA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,CAAkBc,CAAlB,GAAsBpB,EAAtB,GAA2B;KAH3B,CAAL;IAKAE,KAAK,CAAC,IAAD,EAAO;MACVgB,IAAI,EAAEvB,MAAM,CAACY,WADH;MAEVY,EAAE,EAAExB,MAAM,CAACU,QAFD;MAGVgB,CAAC,EAAE1B,MAAM,CAACU,QAAP,CAAgBgB,CAAhB,GAAoBrB,EAApB,GAAyB;KAHzB,CAAL;;;SAOKT,IAAP;;;ACpDF,IAAM+B,OAAO,GAAG,IAAIC,UAAU,CAACC,MAAf,CAAsBC,MAAtB,EAA8BC,OAA9B,CAAhB;;AAGAJ,OAAO,CAACK,SAAR,CAAkBC,QAAlB,GAA6BA,QAA7B;;;;"} -------------------------------------------------------------------------------- /dist/index.mjs: -------------------------------------------------------------------------------- 1 | import freesewing from '@freesewing/core'; 2 | import plugins from '@freesewing/plugin-bundle'; 3 | 4 | var version = "0.0.0"; 5 | 6 | var config = { 7 | name: "{{name}}", 8 | version: version, 9 | design: "{{author}}", 10 | code: "{{author}}", 11 | department: "{{department}}", 12 | type: "{{type}}", 13 | difficulty: 3, 14 | tags: ["freesewing", "design", "diy", "fashion", "made to measure", "parametric design", "{{type}}", "sewing", "sewing pattern"], 15 | optionGroups: { 16 | fit: ["size"] 17 | }, 18 | measurements: [], 19 | dependencies: {}, 20 | inject: {}, 21 | hide: [], 22 | parts: ["box"], 23 | options: { 24 | size: { 25 | pct: 50, 26 | min: 10, 27 | max: 100 28 | } 29 | } 30 | }; 31 | 32 | function draftBox (part) { 33 | var _part$shorthand = part.shorthand(), 34 | options = _part$shorthand.options, 35 | Point = _part$shorthand.Point, 36 | Path = _part$shorthand.Path, 37 | points = _part$shorthand.points, 38 | paths = _part$shorthand.paths, 39 | Snippet = _part$shorthand.Snippet, 40 | snippets = _part$shorthand.snippets, 41 | complete = _part$shorthand.complete, 42 | sa = _part$shorthand.sa, 43 | paperless = _part$shorthand.paperless, 44 | macro = _part$shorthand.macro; 45 | 46 | var w = 500 * options.size; 47 | points.topLeft = new Point(0, 0); 48 | points.topRight = new Point(w, 0); 49 | points.bottomLeft = new Point(0, w / 2); 50 | points.bottomRight = new Point(w, w / 2); 51 | paths.seam = new Path().move(points.topLeft).line(points.bottomLeft).line(points.bottomRight).line(points.topRight).line(points.topLeft).close().attr("class", "fabric"); // Complete? 52 | 53 | if (complete) { 54 | points.logo = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5); 55 | snippets.logo = new Snippet("logo", points.logo); 56 | points.text = points.logo.shift(-90, w / 8).attr("data-text", "hello").attr("data-text-class", "center"); 57 | 58 | if (sa) { 59 | paths.sa = paths.seam.offset(sa).attr("class", "fabric sa"); 60 | } 61 | } // Paperless? 62 | 63 | 64 | if (paperless) { 65 | macro("hd", { 66 | from: points.bottomLeft, 67 | to: points.bottomRight, 68 | y: points.bottomLeft.y + sa + 15 69 | }); 70 | macro("vd", { 71 | from: points.bottomRight, 72 | to: points.topRight, 73 | x: points.topRight.x + sa + 15 74 | }); 75 | } 76 | 77 | return part; 78 | } 79 | 80 | var Pattern = new freesewing.Design(config, plugins); // Attach the draft methods to the prototype 81 | 82 | Pattern.prototype.draftBox = draftBox; 83 | 84 | export default Pattern; 85 | //# sourceMappingURL=index.mjs.map 86 | -------------------------------------------------------------------------------- /dist/index.mjs.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.mjs","sources":["../config/index.js","../src/box.js","../src/index.js"],"sourcesContent":["import { version } from \"../package.json\";\n\n// ?? 🤔 ?? --> https://{{language}}.freesewing.dev/packages/core/config\n\nexport default {\n name: \"{{name}}\",\n version,\n design: \"{{author}}\",\n code: \"{{author}}\",\n department: \"{{department}}\",\n type: \"{{type}}\",\n difficulty: 3,\n tags: [\n \"freesewing\",\n \"design\",\n \"diy\",\n \"fashion\",\n \"made to measure\",\n \"parametric design\",\n \"{{type}}\",\n \"sewing\",\n \"sewing pattern\"\n ],\n optionGroups: {\n fit: [\"size\"]\n },\n measurements: [],\n dependencies: {},\n inject: {},\n hide: [],\n parts: [\"box\"],\n options: {\n size: { pct: 50, min: 10, max: 100 }\n }\n};\n","export default function(part) {\n let {\n options,\n Point,\n Path,\n points,\n paths,\n Snippet,\n snippets,\n complete,\n sa,\n paperless,\n macro\n } = part.shorthand();\n\n let w = 500 * options.size;\n points.topLeft = new Point(0, 0);\n points.topRight = new Point(w, 0);\n points.bottomLeft = new Point(0, w / 2);\n points.bottomRight = new Point(w, w / 2);\n\n paths.seam = new Path()\n .move(points.topLeft)\n .line(points.bottomLeft)\n .line(points.bottomRight)\n .line(points.topRight)\n .line(points.topLeft)\n .close()\n .attr(\"class\", \"fabric\");\n\n // Complete?\n if (complete) {\n points.logo = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5);\n snippets.logo = new Snippet(\"logo\", points.logo);\n points.text = points.logo\n .shift(-90, w / 8)\n .attr(\"data-text\", \"hello\")\n .attr(\"data-text-class\", \"center\");\n\n if (sa) {\n paths.sa = paths.seam.offset(sa).attr(\"class\", \"fabric sa\");\n }\n }\n\n // Paperless?\n if (paperless) {\n macro(\"hd\", {\n from: points.bottomLeft,\n to: points.bottomRight,\n y: points.bottomLeft.y + sa + 15\n });\n macro(\"vd\", {\n from: points.bottomRight,\n to: points.topRight,\n x: points.topRight.x + sa + 15\n });\n }\n\n return part;\n}\n","import freesewing from \"@freesewing/core\";\nimport plugins from \"@freesewing/plugin-bundle\";\nimport config from \"../config\";\nimport draftBox from \"./box\";\n\n// Create new design\nconst Pattern = new freesewing.Design(config, plugins);\n\n// Attach the draft methods to the prototype\nPattern.prototype.draftBox = draftBox;\n\nexport default Pattern;\n"],"names":["name","version","design","code","department","type","difficulty","tags","optionGroups","fit","measurements","dependencies","inject","hide","parts","options","size","pct","min","max","part","shorthand","Point","Path","points","paths","Snippet","snippets","complete","sa","paperless","macro","w","topLeft","topRight","bottomLeft","bottomRight","seam","move","line","close","attr","logo","shiftFractionTowards","text","shift","offset","from","to","y","x","Pattern","freesewing","Design","config","plugins","prototype","draftBox"],"mappings":";;;;;AAIA,a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AFD;MAGVa,CAAC,EAAEzB,MAAM,CAACW,UAAP,CAAkBc,CAAlB,GAAsBpB,EAAtB,GAA2B;KAH3B,CAAL;IAKAE,KAAK,CAAC,IAAD,EAAO;MACVgB,IAAI,EAAEvB,MAAM,CAACY,WADH;MAEVY,EAAE,EAAExB,MAAM,CAACU,QAFD;MAGVgB,CAAC,EAAE1B,MAAM,CAACU,QAAP,CAAgBgB,CAAhB,GAAoBrB,EAApB,GAAyB;KAHzB,CAAL;;;SAOKT,IAAP;;;ACpDF,IAAM+B,OAAO,GAAG,IAAIC,UAAU,CAACC,MAAf,CAAsBC,MAAtB,EAA8BC,OAA9B,CAAhB;;AAGAJ,OAAO,CAACK,SAAR,CAAkBC,QAAlB,GAA6BA,QAA7B;;;;"} -------------------------------------------------------------------------------- /example/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "plugins": [ 3 | ["prismjs", { 4 | "languages": ["javascript", "css", "markup"], 5 | "plugins": ["line-numbers"], 6 | "theme": "twilight", 7 | "css": true 8 | }] 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /example/README.md: -------------------------------------------------------------------------------- 1 |

2 | Freesewing logo 3 |
4 | FreeSewing v2 5 |

6 |

A JavaScript library for made-to-measure sewing patterns

7 |

Follow @freesewing_org on Twitter 12 | Chat with us on Gitter 17 | Become a FreeSewing Patron 22 | Follow @freesewing_org on Twitter 27 | 28 |

29 | 30 | # aaron example 31 | 32 | This project was bootstrapped with [Create Freesewing Pattern](https://en.freesewing.dev/create-freesewing-pattern): 33 | 34 | ```js 35 | npm init freesewing-pattern 36 | ``` 37 | 38 | This example folder is part of the local development environment. 39 | It is **not** part of the pattern's source code. 40 | 41 | To run this example, follow these steps: 42 | 43 | - In the folder above this one, run: `yarn start` (or `npm start`) 44 | - Then, in new terminal, run the same command in this folder: `yarn start` (or `npm start`) 45 | 46 | This will spin up the development environment, similar to [our online demo](https://aaron.freesewing.dev/). 47 | 48 | ## About FreeSewing 🤔 49 | 50 | Where the world of makers and developers collide, that's where you'll find FreeSewing. 51 | 52 | Our [core library](https://freesewing.dev/en/freesewing) is a *batteries-included* toolbox 53 | for parametric design of sewing patterns. It's a modular system (check our list 54 | of [plugins](https://freesewing.dev/en/plugins) and getting started is as simple as: 55 | 56 | ```bash 57 | npm init freesewing-pattern 58 | ``` 59 | 60 | The [getting started] section on [freesewing.dev](https://freesewing.dev/) is a good 61 | entrypoint to our documentation, but you'll find a lot more there, including 62 | our [API documentation](https://freesewing.dev/en/freesewing/api), 63 | as well as [examples](https://freesewing.dev/en/freesewing/examples), 64 | and [best practices](https://freesewing.dev/en/do). 65 | 66 | If you're a maker, checkout [freesewing.org](https://freesewing/) where you can generate 67 | our sewing patterns adapted to your measurements. 68 | 69 | ## Support FreeSewing: Become a patron 🥰 70 | 71 | FreeSewing is an open source project run by a community, 72 | and financially supported by our patrons. 73 | 74 | If you feel what we do is worthwhile, you too 75 | should [become a patron](https://freesewing.org/patrons/join). 76 | 77 | ## Links 👩‍💻 78 | 79 | - 💻 Makers website: [freesewing.org](https://freesewing.org) 80 | - 💻 Developers website: [freesewing.dev](https://freesewing.org) 81 | - 💬 Chat: [gitter.im/freesewing](https://gitter.im/freesewing/freesewing) 82 | - 🐦 Twitter: [@freesewing_org](https://twitter.com/freesewing_org) 83 | - 📷 Instagram: [@freesewing_org](https://instagram.com/freesewing_org) 84 | 85 | ## License: MIT 🤓 86 | 87 | © [Joost De Cock](https://github.com/joostdecock). 88 | See [the license file](https://github.com/freesewing/freesewing/blob/develop/LICENSE) for details. 89 | 90 | ## Where to get help 🤯 91 | 92 | Our [chatroom on Gitter](https://gitter.im) is the best place to ask questions, 93 | share your feedback, or just hang out. 94 | 95 | If you want to report a problem, please [create an issue](https://github.com/freesewing/freesewing/issues/new). 96 | 97 | -------------------------------------------------------------------------------- /example/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "name": "pattern-example", 4 | "homepage": "https://freesewing.github.io/pattern-example", 5 | "version": "0.0.0", 6 | "dependencies": { 7 | "@freesewing/components": "beta", 8 | "@freesewing/core": "beta", 9 | "@freesewing/css-theme": "beta", 10 | "@freesewing/i18n": "beta", 11 | "@freesewing/models": "beta", 12 | "@freesewing/mui-theme": "beta", 13 | "@freesewing/pattern-info": "beta", 14 | "@freesewing/plugin-bundle": "beta", 15 | "@freesewing/plugin-i18n": "beta", 16 | "@freesewing/plugin-svgattr": "beta", 17 | "@freesewing/utils": "beta", 18 | "@material-ui/core": "^4.0.1", 19 | "@material-ui/icons": "^4.0.1", 20 | "@material-ui/lab": "^v4.0.0-alpha.14", 21 | "pattern": "file:..", 22 | "prismjs": "1.16.0", 23 | "react": "^16.8", 24 | "react-dom": "^16.8", 25 | "typeface-roboto-condensed": "latest" 26 | }, 27 | "scripts": { 28 | "start": "react-scripts start", 29 | "build": "react-scripts build", 30 | "test": "react-scripts test", 31 | "eject": "react-scripts eject" 32 | }, 33 | "eslintConfig": { 34 | "extends": "react-app" 35 | }, 36 | "browserslist": [ 37 | ">0.2%", 38 | "not dead", 39 | "not ie <= 11", 40 | "not op_mini all" 41 | ], 42 | "devDependencies": { 43 | "axios": "^0.19.0", 44 | "babel-plugin-prismjs": "1.0.2", 45 | "react-scripts": "^3.0.1", 46 | "tlds": "^1.203.1" 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /example/public/App.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import freesewing from "@freesewing/core"; 3 | import { Workbench } from "@freesewing/components"; 4 | import "typeface-roboto-condensed"; 5 | import "@freesewing/css-theme"; 6 | import "./App.css"; 7 | 8 | import Pattern from "pattern"; 9 | 10 | const App = props => { 11 | let instance = new Pattern(); 12 | let config = instance.config; 13 | return ( 14 | 20 | ); 21 | }; 22 | 23 | export default App; 24 | -------------------------------------------------------------------------------- /example/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/freesewing/pattern/efc422b373b218dadbd0b3572394af667d894e32/example/public/favicon.ico -------------------------------------------------------------------------------- /example/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 22 | Pattern 23 | 24 | 25 | 28 |
29 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /example/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "aaron", 3 | "name": "aaron", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | } 10 | ], 11 | "start_url": ".", 12 | "display": "standalone", 13 | "theme_color": "#000000", 14 | "background_color": "#ffffff" 15 | } 16 | -------------------------------------------------------------------------------- /example/src/App.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import freesewing from "@freesewing/core"; 3 | import Workbench from "@freesewing/components/Workbench"; 4 | import "typeface-roboto-condensed"; 5 | import "@freesewing/css-theme"; 6 | 7 | import Pattern from "pattern"; 8 | 9 | const App = props => { 10 | let instance = new Pattern(); 11 | let config = instance.config; 12 | return ( 13 | 19 | ); 20 | }; 21 | 22 | export default App; 23 | -------------------------------------------------------------------------------- /example/src/index.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import ReactDOM from "react-dom"; 3 | import App from "./App"; 4 | import * as serviceWorker from "./serviceWorker"; 5 | 6 | ReactDOM.render(, document.getElementById("root")); 7 | 8 | // If you want your app to work offline and load faster, you can change 9 | // unregister() to register() below. Note this comes with some pitfalls. 10 | // Learn more about service workers: http://bit.ly/CRA-PWA 11 | serviceWorker.unregister(); 12 | -------------------------------------------------------------------------------- /example/src/serviceWorker.js: -------------------------------------------------------------------------------- 1 | // In production, we register a service worker to serve assets from local cache. 2 | 3 | // This lets the app load faster on subsequent visits in production, and gives 4 | // it offline capabilities. However, it also means that developers (and users) 5 | // will only see deployed updates on the "N+1" visit to a page, since previously 6 | // cached resources are updated in the background. 7 | 8 | // To learn more about the benefits of this model, read https://goo.gl/KwvDNy. 9 | // This link also includes instructions on opting out of this behavior. 10 | 11 | const isLocalhost = Boolean( 12 | window.location.hostname === "localhost" || 13 | // [::1] is the IPv6 localhost address. 14 | window.location.hostname === "[::1]" || 15 | // 127.0.0.1/8 is considered localhost for IPv4. 16 | window.location.hostname.match( 17 | /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ 18 | ) 19 | ); 20 | 21 | export function register(config) { 22 | if (process.env.NODE_ENV === "production" && "serviceWorker" in navigator) { 23 | // The URL constructor is available in all browsers that support SW. 24 | const publicUrl = new URL(process.env.PUBLIC_URL, window.location); 25 | if (publicUrl.origin !== window.location.origin) { 26 | // Our service worker won't work if PUBLIC_URL is on a different origin 27 | // from what our page is served on. This might happen if a CDN is used to 28 | // serve assets; see https://github.com/facebook/create-react-app/issues/2374 29 | return; 30 | } 31 | 32 | window.addEventListener("load", () => { 33 | const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; 34 | 35 | if (isLocalhost) { 36 | // This is running on localhost. Let's check if a service worker still exists or not. 37 | checkValidServiceWorker(swUrl, config); 38 | 39 | // Add some additional logging to localhost, pointing developers to the 40 | // service worker/PWA documentation. 41 | navigator.serviceWorker.ready.then(() => { 42 | console.log( 43 | "This web app is being served cache-first by a service " + 44 | "worker. To learn more, visit https://goo.gl/SC7cgQ" 45 | ); 46 | }); 47 | } else { 48 | // Is not local host. Just register service worker 49 | registerValidSW(swUrl, config); 50 | } 51 | }); 52 | } 53 | } 54 | 55 | function registerValidSW(swUrl, config) { 56 | navigator.serviceWorker 57 | .register(swUrl) 58 | .then(registration => { 59 | registration.onupdatefound = () => { 60 | const installingWorker = registration.installing; 61 | installingWorker.onstatechange = () => { 62 | if (installingWorker.state === "installed") { 63 | if (navigator.serviceWorker.controller) { 64 | // At this point, the old content will have been purged and 65 | // the fresh content will have been added to the cache. 66 | // It's the perfect time to display a "New content is 67 | // available; please refresh." message in your web app. 68 | console.log("New content is available; please refresh."); 69 | 70 | // Execute callback 71 | if (config.onUpdate) { 72 | config.onUpdate(registration); 73 | } 74 | } else { 75 | // At this point, everything has been precached. 76 | // It's the perfect time to display a 77 | // "Content is cached for offline use." message. 78 | console.log("Content is cached for offline use."); 79 | 80 | // Execute callback 81 | if (config.onSuccess) { 82 | config.onSuccess(registration); 83 | } 84 | } 85 | } 86 | }; 87 | }; 88 | }) 89 | .catch(error => { 90 | console.error("Error during service worker registration:", error); 91 | }); 92 | } 93 | 94 | function checkValidServiceWorker(swUrl, config) { 95 | // Check if the service worker can be found. If it can't reload the page. 96 | fetch(swUrl) 97 | .then(response => { 98 | // Ensure service worker exists, and that we really are getting a JS file. 99 | if ( 100 | response.status === 404 || 101 | response.headers.get("content-type").indexOf("javascript") === -1 102 | ) { 103 | // No service worker found. Probably a different app. Reload the page. 104 | navigator.serviceWorker.ready.then(registration => { 105 | registration.unregister().then(() => { 106 | window.location.reload(); 107 | }); 108 | }); 109 | } else { 110 | // Service worker found. Proceed as normal. 111 | registerValidSW(swUrl, config); 112 | } 113 | }) 114 | .catch(() => { 115 | console.log( 116 | "No internet connection found. App is running in offline mode." 117 | ); 118 | }); 119 | } 120 | 121 | export function unregister() { 122 | if ("serviceWorker" in navigator) { 123 | navigator.serviceWorker.ready.then(registration => { 124 | registration.unregister(); 125 | }); 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@freesewing/pattern", 3 | "version": "0.0.0", 4 | "description": "A FreeSewing pattern (template)", 5 | "author": "Joost De Cock (https://github.com/joostdecock)", 6 | "homepage": "https://freesewing.org/", 7 | "repository": "github:freesewing/pattern", 8 | "license": "MIT", 9 | "bugs": { 10 | "url": "https://github.com/freesewing/pattern/issues" 11 | }, 12 | "keywords": [ 13 | "freesewing", 14 | "design", 15 | "diy", 16 | "fashion", 17 | "made to measure", 18 | "parametric design", 19 | "pattern", 20 | "sewing", 21 | "sewing pattern" 22 | ], 23 | "main": "dist/index.js", 24 | "module": "dist/index.mjs", 25 | "scripts": { 26 | "clean": "rimraf dist", 27 | "build": "npm run clean && rollup -c", 28 | "test": "echo \"aaron: No tests configured. Perhaps you'd like to do this?\" && exit 0", 29 | "start": "rollup -c -w", 30 | "prettier": "npx prettier --write 'src/*'" 31 | }, 32 | "prettier": "@freesewing/prettier-config", 33 | "peerDependencies": { 34 | "@freesewing/core": "beta", 35 | "@freesewing/plugin-bundle": "beta", 36 | "@freesewing/brian": "beta" 37 | }, 38 | "dependencies": {}, 39 | "devDependencies": { 40 | "@babel/plugin-proposal-class-properties": "^7.0.0", 41 | "@freesewing/components": "beta", 42 | "@freesewing/css-theme": "beta", 43 | "@freesewing/i18n": "beta", 44 | "@freesewing/mui-theme": "beta", 45 | "@freesewing/patterns": "beta", 46 | "@freesewing/plugin-bust": "beta", 47 | "@freesewing/plugin-buttons": "beta", 48 | "@freesewing/plugin-flip": "beta", 49 | "@freesewing/prettier-config": "2.0.0-beta.37", 50 | "@freesewing/utils": "beta", 51 | "@material-ui/core": "4.0.1", 52 | "@material-ui/icons": "4.0.1", 53 | "@material-ui/lab": "^v4.0.0-alpha.14", 54 | "@svgr/rollup": "^2.4.1", 55 | "babel-eslint": "10.0.1", 56 | "babel-jest": "24.7.1", 57 | "cross-env": "^5.1.4", 58 | "eslint": "^5.16.0", 59 | "gh-pages": "^1.2.0", 60 | "jest": "24.7.1", 61 | "prop-types": "15.7.2", 62 | "react": "^16.8", 63 | "react-dom": "^16.8", 64 | "react-intl": "2.8.0", 65 | "react-scripts": "^3.0.0", 66 | "rollup": "^0.64.1", 67 | "rollup-plugin-babel": "^4.0.1", 68 | "rollup-plugin-babel-minify": "^7.0.0", 69 | "rollup-plugin-commonjs": "^9.1.3", 70 | "rollup-plugin-json": "^3.1.0", 71 | "rollup-plugin-node-resolve": "^3.3.0", 72 | "rollup-plugin-peer-deps-external": "^2.2.0", 73 | "rollup-plugin-postcss": "^1.6.2", 74 | "rollup-plugin-url": "^1.4.0", 75 | "webpack": "4.29.6" 76 | }, 77 | "files": [ 78 | "dist/*", 79 | "README.md", 80 | "package.json" 81 | ], 82 | "publishConfig": { 83 | "access": "public", 84 | "tag": "beta" 85 | }, 86 | "engines": { 87 | "node": ">=8.0.0", 88 | "npm": ">=5" 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /rollup.config.js: -------------------------------------------------------------------------------- 1 | import babel from "rollup-plugin-babel"; 2 | import resolve from "rollup-plugin-node-resolve"; 3 | import commonjs from "rollup-plugin-commonjs"; 4 | import json from "rollup-plugin-json"; 5 | import minify from "rollup-plugin-babel-minify"; 6 | import url from "rollup-plugin-url"; 7 | import postcss from "rollup-plugin-postcss"; 8 | import peerDepsExternal from "rollup-plugin-peer-deps-external"; 9 | import { 10 | name, 11 | version, 12 | description, 13 | author, 14 | license, 15 | main, 16 | module 17 | } from "./package.json"; 18 | 19 | const output = [ 20 | { 21 | file: main, 22 | format: "cjs", 23 | sourcemap: true 24 | } 25 | ]; 26 | if (typeof module !== "undefined") 27 | output.push({ 28 | file: module, 29 | format: "es", 30 | sourcemap: true 31 | }); 32 | 33 | export default { 34 | input: "src/index.js", 35 | output, 36 | plugins: [ 37 | peerDepsExternal(), 38 | resolve({ modulesOnly: true }), 39 | url(), 40 | commonjs(), 41 | json(), 42 | postcss({ 43 | modules: true 44 | }), 45 | babel({ 46 | exclude: "node_modules/**", 47 | plugins: ["@babel/plugin-proposal-object-rest-spread"] 48 | }), 49 | minify({ 50 | comments: false, 51 | sourceMap: true, 52 | banner: `/**\n * ${name} | v${version}\n * ${description}\n * (c) ${new Date().getFullYear()} ${author}\n * @license ${license}\n */` 53 | }) 54 | ] 55 | }; 56 | -------------------------------------------------------------------------------- /src/.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "jest": true 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /src/box.js: -------------------------------------------------------------------------------- 1 | export default function(part) { 2 | let { 3 | options, 4 | Point, 5 | Path, 6 | points, 7 | paths, 8 | Snippet, 9 | snippets, 10 | complete, 11 | sa, 12 | paperless, 13 | macro 14 | } = part.shorthand() 15 | 16 | let w = 500 * options.size 17 | points.topLeft = new Point(0, 0) 18 | points.topRight = new Point(w, 0) 19 | points.bottomLeft = new Point(0, w / 2) 20 | points.bottomRight = new Point(w, w / 2) 21 | 22 | paths.seam = new Path() 23 | .move(points.topLeft) 24 | .line(points.bottomLeft) 25 | .line(points.bottomRight) 26 | .line(points.topRight) 27 | .line(points.topLeft) 28 | .close() 29 | .attr('class', 'fabric') 30 | 31 | // Complete? 32 | if (complete) { 33 | points.logo = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5) 34 | snippets.logo = new Snippet('logo', points.logo) 35 | points.text = points.logo 36 | .shift(-90, w / 8) 37 | .attr('data-text', 'hello') 38 | .attr('data-text-class', 'center') 39 | 40 | if (sa) { 41 | paths.sa = paths.seam.offset(sa).attr('class', 'fabric sa') 42 | } 43 | } 44 | 45 | // Paperless? 46 | if (paperless) { 47 | macro('hd', { 48 | from: points.bottomLeft, 49 | to: points.bottomRight, 50 | y: points.bottomLeft.y + sa + 15 51 | }) 52 | macro('vd', { 53 | from: points.bottomRight, 54 | to: points.topRight, 55 | x: points.topRight.x + sa + 15 56 | }) 57 | } 58 | 59 | return part 60 | } 61 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | import freesewing from '@freesewing/core' 2 | import plugins from '@freesewing/plugin-bundle' 3 | import config from '../config' 4 | import draftBox from './box' 5 | 6 | // Create new design 7 | const Pattern = new freesewing.Design(config, plugins) 8 | 9 | // Attach the draft methods to the prototype 10 | Pattern.prototype.draftBox = draftBox 11 | 12 | export default Pattern 13 | --------------------------------------------------------------------------------