1
0
Fork 0

feat: Initial draft of Titan pattern

This commit is contained in:
Joost De Cock 2020-05-17 18:08:44 +02:00
parent 5e4eee8949
commit 05e56f2266
21 changed files with 1420 additions and 0 deletions

View file

@ -56,6 +56,7 @@ simone: 'A FreeSewing pattern for a button down shirt (Simone = Simon for people
sven: 'A FreeSewing pattern for a straightforward sweater'
tamiko: 'A FreeSewing pattern for a zero-waste top'
theo: 'A FreeSewing pattern for classic trousers'
titan: 'A FreeSewing block for trousers'
trayvon: 'A FreeSewing pattern for a tie'
tutorial: "A FreeSewing pattern for a baby bib that's used in our tutorial"
utils: 'A collection of utilities shared across freesewing frontend projects'

112
packages/titan/CHANGELOG.md Normal file
View file

@ -0,0 +1,112 @@
# Change log for: @freesewing/titan
## Unreleased
**Note:** Version bump only for package titan
## 2.6.0 (2020-05-01)
**Note:** Version bump only for package titan
## 2.5.0 (2020-04-05)
**Note:** Version bump only for package titan
## 2.4.6 (2020-03-23)
**Note:** Version bump only for package titan
## 2.4.5 (2020-03-19)
**Note:** Version bump only for package titan
## 2.4.4 (2020-03-15)
**Note:** Version bump only for package titan
## 2.4.3 (2020-03-12)
**Note:** Version bump only for package titan
## 2.4.2 (2020-03-08)
**Note:** Version bump only for package titan
## 2.4.1 (2020-03-04)
**Note:** Version bump only for package titan
## 2.4.0 (2020-02-29)
**Note:** Version bump only for package titan
## 2.3.0 (2020-02-23)
**Note:** Version bump only for package titan
## 2.2.0 (2020-02-22)
**Note:** Version bump only for package titan
## 2.1.9 (2020-01-18)
**Note:** Version bump only for package titan
## 2.1.8 (2019-12-16)
**Note:** Version bump only for package titan
## 2.1.7 (2019-12-15)
**Note:** Version bump only for package titan
## 2.1.6 (2019-11-24)
**Note:** Version bump only for package titan
## 2.1.5 (2019-11-19)
**Note:** Version bump only for package titan
## 2.1.4 (2019-11-01)
**Note:** Version bump only for package titan
## 2.1.3 (2019-10-18)
**Note:** Version bump only for package titan
## 2.1.2 (2019-10-14)
**Note:** Version bump only for package titan
## 2.1.1 (2019-10-13)
**Note:** Version bump only for package titan
## 2.1.0 (2019-10-06)
**Note:** Version bump only for package titan
## 2.0.4 (2019-09-27)
**Note:** Version bump only for package titan
## 2.0.3 (2019-09-15)
**Note:** Version bump only for package titan
## 2.0.2 (2019-09-06)
**Note:** Version bump only for package titan
## 2.0.1 (2019-09-01)
**Note:** Version bump only for package titan
## 2.0.0 (2019-08-25)
This is the **initial release**, and the start of this change log.
Prior to version 2, FreeSewing was not a JavaScript project.
As such, that history is out of scope for this change log.

99
packages/titan/README.md Normal file
View file

@ -0,0 +1,99 @@
![FreeSewing](https://freesewing.org/banner.jpg)
<p align='center'><a
href="https://www.npmjs.com/package/@freesewing/titan"
title="@freesewing/titan on NPM"
><img src="https://img.shields.io/npm/v/@freesewing/titan.svg"
alt="@freesewing/titan on NPM"/>
</a><a
href="https://opensource.org/licenses/MIT"
title="License: MIT"
><img src="https://img.shields.io/npm/l/@freesewing/titan.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%3Atitan"
title="Open issues tagged pkg:titan"
><img src="https://img.shields.io/github/issues/freesewing/freesewing/pkg:titan.svg?label=Issues"
alt="Open issues tagged pkg:titan"/>
</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/chat"
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>
## What am I looking at? 🤔
This repository is our _monorepo_ holding [all our NPM packages](https://www.npmjs.com/search?q=keywords:freesewing).
This folder holds **@freesewing/titan**
A FreeSewing block for trousers
## About FreeSewing 💀
Where the world of makers and developers collide, that's where you'll find FreeSewing.
Our [core library](https://freesewing.dev/reference/api/) is a _batteries-included_ toolbox
for parametric design of sewing patterns. It's a modular system (check our list
of [plugins](https://freesewing.dev/reference/plugins/) and getting started is as simple as:
```bash
npm init freesewing-pattern
```
The [getting started](https://freesewing.dev/guides/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 reference](https://freesewing.dev/reference/api/),
as well as [our turorial](https://freesewing.dev/tutorials/pattern-design/),
and [howtos](https://freesewing.dev/howtos/).
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.dev)
- 💬 Chat: [gitter.im/freesewing](https://gitter.im/freesewing/chat)
- 🐦 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/freesewing/chat) 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,76 @@
import { version } from '../package.json'
export default {
name: 'titan',
version,
design: 'Debra Bean',
code: 'Joost De Cock',
department: 'unisex',
type: 'block',
difficulty: 3,
tags: ['bottom', 'basics'],
optionGroups: {
fit: ['seatEase', 'upperLegEase', 'backRise', 'kneeEase', 'ankleEase', 'frontWaistRise'],
advanced: [
'crotchExtension',
'backWaistDart',
'backWaistDartLength',
'crossSeamCurveStart',
'crossSeamCurveBend',
'legBalance',
'inseamCurve',
'outseamCurveKnee',
'outseamCurveSeat',
'frontWaistDart',
'frontWaistDartLength',
'flyCurveBend'
]
},
measurements: [
'ankleEntry',
'backWaist',
'crotchDepth',
'crossSeam',
'frontCrossSeam',
'backSeat',
'seatCircumference',
'kneeCircumference',
'naturalWaist',
'naturalWaistToFloor',
'naturalWaistToKnee',
'naturalWaistToSeat',
'upperLegCircumference'
],
parts: ['back', 'front'],
options: {
backWaistFactor: 0.145,
grainlineBackFactor: 0.5125,
crossSeamFitBalance: 0.5,
fitCrossSeam: true,
fitFrontCrossSeam: true,
fitBackCrossSeam: true,
flySlopeHinge: 0.54,
flySlopeFactor: 0.09,
frontGrainLineFactor: 0.52,
frontCrotchExtension: 1.07, // 7% longer at the front
flyCurveStart: 0.25,
seatEase: { pct: 1, min: 0, max: 5 },
upperLegEase: { pct: 8.5, min: 5, max: 12 },
crotchExtension: { pct: 5, min: 3, max: 7 },
backWaistDart: { pct: 12, min: 5, max: 20 },
backWaistDartLength: { pct: 28.5, min: 15, max: 45 },
backRise: { pct: 8, min: 3, max: 13 },
crossSeamCurveStart: { pct: 25, min: 0, max: 45 },
crossSeamCurveBend: { pct: 65, min: 45, max: 95 },
kneeEase: { pct: 6, min: 1, max: 25 },
ankleEase: { pct: 6, min: 1, max: 25 },
legBalance: { pct: 75, min: 25, max: 100 },
inseamCurve: { pct: 35, min: 20, max: 50 },
outseamCurveKnee: { pct: 35, min: 20, max: 50 },
outseamCurveSeat: { pct: 60, min: 40, max: 80 },
frontWaistDart: { pct: 5, min: 3, max: 20 },
frontWaistDartLength: { pct: 45, min: 25, max: 65 },
frontWaistRise: { pct: 2.5, min: 0, max: 10 },
flyCurveBend: { pct: 88, min: 70, max: 100 }
}
}

View file

@ -0,0 +1,77 @@
# Titan drafting instructions
As provided by @dfbean
## Back
| Action | # Value | Draft value (cm) | Code value (mm) | Drafter comments | Programmer comments |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | ------------------------------------------- | -------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Make a point, label A | | | | | |
| Square line down # from A, mark point at end, label D | crotch depth | 31.1 | 311 | | used `crotchDepth` measurement |
| On line A-D, measure # from point A, mark new point, label C | hip depth | 22.9 | 229 | | used `naturalWaistToSeat` measurement |
| From point A, square a line # left, mark endpoint, label H | back hip arc + .3cm | 28.2 | -281.79 | .3cm for ease | used `hipsEase` option, `backHipArc` measurement provided by the `measurements` plugin (part of titan for now) |
| From point C, square a line # left, mark endpoint, label F | back hip arc + .3cm | 28.2 | -281.79 | .3cm for ease | |
| From point D, square a line #, mark endpoint, label I | Use greater of 1.25 x (back hip arc + .3) | 35.3 | 352.2375 | this step incorporates a subsequent fit check, and includes some adjustments required to draft this piece independent of the front piece. | |
| | **OR**, (upperleg + 3.8 + 1.9) (front hip arc + .3+ front crotch extension) | (64.8 + 3.8 + 1.9) (25.4 +.3 +5.7) = 39.1 | 393.23 | Includes 3.8 cm recommended crotch ease and 1.9cm placeholder that will be removed later. | used `upperLegEase` and `crotchExtension` options. `crotchExtension` being based on `hipsCircumference` measurement |
| Starting at point H, square down through point F, till intersecting with line D-I. Label intersection point G | | | | | |
| On line G-H, measure # from point G, mark endpoint, label X | .5(crotch depth) | 15.6 | 155.5 | | |
| On line A-H, measure # from point H, toward point A, mark point, label N | 4.5 | 4.5 | 45.1 | Fixed value, sets reference point for back waist | This doesn't work for us. We can't just put in an arbitrary 4.5cm value. That doesn't scale. So I've added a static option called `backWaistFactor` that is 14.5% of the `crotchDepth` measurement. That way, the slant of the back seam should always be the same. This might need tweaking though. |
| On line A-H, measure from point N toward point A, # mark endpoint, label O | back waist arc + 2.5 | 22.8 | 227.36 | 2.5 fixed value for dart width. Ok that it's fixed, it's mostly a placeholder and gets removed, rolled or replaced in pant patterns. If additional shaping is required it can be placed in hip curve. | I've added the `backWaistDart` option which is 12% of the `backWaistArc` measurement, which gives us 24.36mm |
| On line A-H, measure from point N # toward O, mark endpoint, label P | .5 (back waist arc + 2.5) | 11.4 | 113.68 | 2.5 fixed value for dart placement. | went with time .56 instead of fixed value |
| Square line # down from P, mark endpoint, no label | | 8.9 | 88.64 | Fixed value for dart length. See previous note onfixed dart value. | Added the `backWaistDartLength` option, which is based on the `crotchDepth` measurement. 28.5% by default |
| Square out # from P on both sides, mark endpoints, no label. | | 1.0 | 12.5 | 1.0 Fixed value for dart width. See previous note. | Earlier on, draft instructions specify _2.5cm fixed value for dart width_. Now, it's _1cm fixed value for (half of the) dart width_. Rather than an introduce a 0.5cm error, I've kept the dart width at 2.5 cm (12.5mm to each side). |
| Square up # from point N, mark endpoint, label T | 2.5 | 2.5 | -24.88 | Fixed value for height of back rise. | Once again not loving the fixed 2.5cm value here. But I'm not certain whether it's best to make this a fraction of `crotchDepth` or rather `backWaistArc`. Went with `crotchDepth` since it is a vertical measurement after all. Added the `backRise` option for this. |
| Draw a line from T, through X, to line D-I, no label | | | -320.67 | | Point name: `extendedBackSeam` |
| Square # up/left diagonally from G , mark endpoint, label g | 4.4 | 4.4 | 44 | Fixed value as reference for crotch curve. | I'm a bit confused here about the _fixed value_ note here. The intersection of the line from `T` through `X` and a line from `G` 45 degrees NW can only intersect in 1 point. It so happens that point is 4.4cm from G, but why is it described as a _fixed value_? |
| Draw curve touching X and g, ending at/near I, blend at g if needed. | | | | | I had a look at the hand-drawn version, and I do find the bend of this curve to be really sharp. I have approximated it in the code, but I have also added the `backSeamCurveStart` and `backSeamCurveBend` options to control the curvature. |
| Draw slightly curved line from T to O. | | | | |
| Draw dart legs through side points, up to curved T-O line | | | | |
| True dart by raising shorter leg and redrawing line to O. | | | | We don't _true_, we just get it right :) |
| Draw hip curve from just above C to O | | | | | Just above C? Why just above C as C marks the fullest part of the seat? |
| On line D-I, mark new point # to left of D, label V | 1 | 1 | 9.84 | Fixed point as reference for hip curve. This value was already included in line D-I, so that it could be removed at this stage. | This seems a bit random. I don't see any reference to _1cm_ when constructing point I, so not sure where to get this from. See next step for workaround |
| On line D-I, mark new point # halfway between between V and I, label W | | 19.0 | 191.5 | I measured/divided manually, you'll let the computer do this. | Went with 51.25% instead (because of the 1cm). Stored in the static `grainlineBackFactor` option |
| From point W, square up to line A-H (waistline) and down # waist to ankle, to knee and # to ankle to create grainline Mark knee and ankle points | | 100.3, 61.0 | 1053, 610 | Threw this in so I could complete the crotch and hip curves. | We have a `naturalWaistToFloor` measurement. Adding `naturalWaistToAnkle` seems excessive. I'm drafting this block to the floor and will leave it to the designer how long they want things. I guesstimated 105.3cm for the fit model. |
| At knee point square and center a # line, mark endpoints, no label | (knee circ / 2) + 2.5 | (40.6/2) + 2.5 = 22.8 | 221.2 | Knee and ankle circs are needed to build hip and crotch curves correctly. I used my measurement with 1 inch of ease allocated to the back. I want to fiddle with this and get your comments. | Is it custom to only apply ease to the back? I've added a `kneeEase` options for this combined with that `legBalance` option to control this. Default = 75% (meaning that 75% of ease is applied to the back) |
| At ankle point, square and center a line, mark endpoints, no label | (ankle entry circ / 2) - 2.5 | (31.8/2) + 2.5 = 18.4 | 173.4 | Same approach as the knee, just to have a point to work with. See above note about revisiting after testing. | I noticed we don't have an `ankleCircumference` measurement, but only `ankleEntry`. I've based it on the latter for now, but this feels a bit contra-intuitive. Added `ankleEase` option for this. |
| Draw a line from ankle points, through knee points, to line D-I. | | | Creates in/out seams and guide for hip and crotch curves | |
| Draw curve down from I to inseam, blending curve into seam about midway between knee and line D-I. Ensure first inch of curve down from I is at 90 degree angle to upward curve from I. | | | | | Ignored the 90 degree thing for now. Added `inseamCurve` option to control shape of curve. |
| Draw curve down from V to outseam, blending curve into seam about midway between knee and line D-I. | | | | | I've added the `outSeamCurveKnee` and `outSeamCurveSeat` options to control this. Set the defaults so that the curve deviates 1cm (9.66mm to be exact) at the D-I line as instructed earlier |
| Correct crotch length by pitching crotch seam up/down at point F. | back crotch length (T-X-g-I) = pitch up | 45.2 40 = 5.2 | | Lucky you, the computer will handle this! Negative result means downward pitch | Implemented by slashing horizontally, then rotating, in combination with shifting the tip of the inseam outwards. The balance between these two ways to increase (or decrease) the cross seam is the `crossSeamFitBalance` option which defaults to `0.5`. Once the cross seam is the correct length, we also make sure we respect the horizontal distance from cross seam to side by shifting the side seam outwards. |
## Front
| Action | # Value | Draft value (cm) | Code value (mm) | Drafter comments | Programmer comments |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------- | ----------------- | ------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Make a point, label A | | | | | |
| Square line down # from A, mark point at end, label D | crotch depth | 31.1 | 311 | | used `crotchDepth` measurement |
| On line A-D, measure # from point A, mark new point, label C | hip depth | 22.9 | 229 | | used `naturalWaistToSeat` measurement |
| From point A, square a line # right mark endpoint, label L | front hip arc + .3cm | 25.4 + .3 = 25.7 | 256.54 | .3cm for ease | used `hipsEase` option, `frontHipArc` measurement provided by the `measurements` plugin (part of titan for now) |
| From point C, square a line # right, mark endpoint, label J | front hip arc + .3cm | 25.4 + .3 = 25.7 | 256.54 | .3cm for ease | |
| From point D, square a line # right, mark endpoint, label K | front hip arc + .3cm | 25.4 + .3 = 25.7 | 256.54 | .3 cm for ease | |
| Extend line D-K # to the right, label endpoint M | crotch extension | | | | Used `crotchExtension` option (same as back) as basis but applied a `7%` extra stored in fixed option `crotchFrontExtention` |
| Connect L to K touching J | | | | | |
| On line L-K, measure # from point from K, mark endpoint, label X | .5(crotch depth) + 1.3 | 15.5 + 1.3 = 16.8 | 18.8 | | Went with `54%` of `crotchDepth` instead. Created a new option for this: `flySlopeHinge`, fixed to `0.54` |
| On line A-L, measure # from point L, mark point, label Q | 1.3 | 1.3 | 12.88 | | Based this on the vertical distance between X and L, this should keep the slop consistent across sizes. Created new option for this: `flySlopeFactor`, fixed to `0.09` |
| On line A-L, measure # from point Q toward point A, mark endpoint, label R | front waist arc + 1.9 | 20.3 + 1.9 = 22.2 | 19.05 | 1.9 fixed value for dart width. OK that it's fixed, it's mostly a placeholder and gets removed, rolled or replaced in pant patterns. If additional shaping is required it can be placed in hip curve. | Added the `frontWaistDart` option which defaults to `7.5%` |
| On line A-L, measure # from point Q toward R, mark endpoint, label S | 8.3 | 8.3 | 81.9 | fixed value for dart placement. See previous note on fixed dart value | Went with `frontWaistDartLocation` option which is be default `30%` from `Q` towards `R` |
| Square line # down from S, mark endpoint, no label | 6.4 | 6.4 | 64.38 | Fixed value for dart length. See previous note on fixed dart value. | Went with `frontWaistDartLenght` option, which defaults to `45%` (based on distance down to `X`) |
| Square out # from S on both sides, mark endpoints, no label. | .6 | .6 | 6.35 | Fixed value for dart width. See previous note. | Earlier, you used `1.9` as a fixed value for dart with. Now, half the dart width is `0.6` 7mm went missing somewhere and I can't see what happened to them. So, I aimed for `12.7mm` dart width and am thus not respecting the `19mm` above |
| Square up # from point Q, mark endpoint, label U | .6 | .6 | 6.35 | Fixed value for waistband reference | Created `frontWaistRise` options for this, defaults to `2.5%` (of `frontWaistArc` measurement) |
| Draw a line from U, through X, to line D-K-M, no label | | | | |
| Square # up/right diagonally from K , mark endpoint, label k | 3.2 | 3.2 | | Fixed value as reference for crotch curve. | Didn't bother with this, as it's not a point we'll use in construction, but merely an indicator where our curve should be. |
| Draw curve touching X, k and M, blend at k if needed. | | | | | Similar options as the back: `flyCurveStart` and `flyCurveBend` |
| Draw slightly curved line from U to R | | | | | If there's a curve in your drawing, it's too subtle to see. So I just used a straight line as that makes handling the dart so so much easier. On that note, we've already constructed the dart at this point. Now we don't only have to move it, but it's also no longer on a horizontal line, so we have to slightly rotate it. AS such, I'm going to move the construction of the dart further down the code so that we construct it in the right place rather than moving it afterwards. |
| Draw dart legs through side points, up to curved U-R line | | | | | | |
| True dart by raising shorter leg and redrawing line to R | | | | | No trueing needed, our dart is correct already |
| Draw hip curve from just above C to R | | | | | Same remark as for the back: Why just above C as C marks the fullest part of the seat? |
| On line D-M, mark new point # to right of D, label Y | 1.0 | 1.0 | | Fixed point as reference for hip curve. This value was already included in line D-I, so that it could be removed at this stage. | This is one of those control points not actuall used in construction. Will just use `52%` of the horizontal distance instead, stored in the `frontGrainLineFactor` option |
| On line D-M, mark new point halfway between between Y and M, label Z | | 15.2 | 153 | Value only for reference, you use that new-fangled computer to generate this. | Why did we go through all that trouble figuring out where to put the dart, when we now determine this is the grainline, which is probably where the dart should be anyway? |
| From point Z, square up to line A-L (waistline) and down # to waist to ankle, knee and # to ankle to create grainline Mark knee and ankle waist to knee points | | 100.3 | | | | We have a `naturalWaistToFloor` measurement. Adding `naturalWaistToAnkle` seems excessive. I'm drafting this block to the floor and will leave it to the designer how long they want things. I guesstimated 105.3cm for the fit model. |
| At knee point square and center a # line, mark endpoints, no label | knee circ / 2 | 40.6/2 = 20.3 | 209.1 | Threw this in so I could complete the crotch and hip curves. Knee and ankle circ”s are needed to build hip and crotch curves correctly. I used my measurements with 1 inch of ease at knee, allocated to the back. I want to fiddle with this and get your comments. | I used the `kneeEase` and `legBalance` options for this (same as in the back). Hence slightly different value |
| At ankle point, square and center a line, mark endpoints, no label | ankle entry circ / 2 | 31.8/2 = 15.9 | `163.76` because we added `ankleEase` | Same approach as the knee, just to have a point to work with. See above note about revisiting after testing. | Note that we're drafting to the floor |
| Draw a line from ankle points, through knee points, to line D-M Creates in/out seams and guide for hip and crotch curves | | | | | |
| Draw curve down from M to inseam, blending curve into seam about midway between knee and line D-M. Ensure first inch of curve down from M is at 90 degree angle to upward curve from M. | | | | | |
| Draw curve down from Y to outseam, blending curve into seam about midway between knee and line D-M. | | | | | |
| Correct crotch length by pitching crotch seam up/down at point J | | | | | |
All implemented. And more. For one thing, there's no trueing of the inseam and outseam here.

View file

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

View file

@ -0,0 +1,95 @@
<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>
# trayvon 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://trayvon.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": "titan-example",
"homepage": "https://freesewing.github.io/titan",
"version": "0.0.0",
"private": true,
"dependencies": {
"@freesewing/components": "latest",
"@freesewing/core": "latest",
"@freesewing/css-theme": "latest",
"@freesewing/i18n": "latest",
"@freesewing/models": "latest",
"@freesewing/mui-theme": "latest",
"@freesewing/pattern-info": "latest",
"@freesewing/plugin-bundle": "latest",
"@freesewing/plugin-theme": "latest",
"@freesewing/plugin-i18n": "latest",
"@freesewing/plugin-svgattr": "latest",
"@freesewing/utils": "latest",
"@material-ui/core": "^4.4.0",
"@material-ui/icons": "^4.2.1",
"@material-ui/lab": "^v4.0.0-alpha.25",
"pattern": "link:..",
"prismjs": "1.17.1",
"react": "^16.9",
"react-dom": "^16.9",
"react-scripts": "^3.1.1",
"file-saver": "^2.0.2",
"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.1.1"
}
}

View file

@ -0,0 +1,16 @@
import React from 'react'
import freesewing from '@freesewing/core'
import { Workbench } from '@freesewing/components'
import 'typeface-roboto-condensed'
import '@freesewing/css-theme'
import './App.css'
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

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>titan</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": "titan",
"name": "titan",
"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,34 @@
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
// Adding untranslated strings
let translations = {
'measurements.ankleEntry': 'Ankle entry',
'measurements.backWaist': 'Back waist',
'measurements.crotchDepth': 'Crotch depth',
'measurements.crotchLength': 'Crotch length',
'measurements.frontCrotchLength': 'Front crotch length',
'measurements.frontHip': 'Front hip'
}
return (
<Workbench
freesewing={freesewing}
Pattern={Pattern}
config={config}
userLanguage="en"
translations={translations}
/>
)
}
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,123 @@
// 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()
})
}
}

View file

@ -0,0 +1,48 @@
{
"name": "@freesewing/titan",
"version": "2.6.0",
"description": "A FreeSewing block for trousers",
"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",
"sewing"
],
"main": "dist/index.js",
"module": "dist/index.mjs",
"scripts": {
"clean": "rimraf dist",
"build": "npm run clean && rollup -c",
"test": "echo \"titan: 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"
},
"peerDependencies": {},
"dependencies": {},
"devDependencies": {},
"files": [
"dist/*",
"README.md",
"package.json"
],
"publishConfig": {
"access": "public",
"tag": "latest"
},
"engines": {
"node": ">=8.0.0",
"npm": ">=5"
}
}

View file

@ -0,0 +1,41 @@
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 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 }),
commonjs(),
json(),
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 */`
})
]
}

253
packages/titan/src/back.js Normal file
View file

@ -0,0 +1,253 @@
export default (part) => {
let {
points,
Point,
paths,
Path,
measurements,
options,
complete,
paperless,
store,
macro,
utils,
snippets,
Snippet
} = part.shorthand()
points.A = new Point(0, 0)
points.D = new Point(0, measurements.crotchDepth)
points.C = new Point(0, measurements.naturalWaistToSeat)
points.H = new Point(-1 * measurements.backSeatArc * (1 + options.seatEase), 0)
points.F = new Point(points.H.x, points.C.y)
// For the widest point of our trouser block, we'll use whichever is widest:
// A: 1.25 times the (backSeatArc + ease)
// B: (upperLegCircumference + ease) - ((frontSeatArc + ease) * (1 + crotchExtension))
let crotchWidthOptionA = measurements.backSeatArc * (1 + options.seatEase) * 1.25
let crotchWidthOptionB =
measurements.upperLegCircumference * (1 + options.upperLegEase) -
measurements.frontSeatArc * (1 + options.seatEase) -
measurements.seatCircumference * options.crotchExtension
points.I = new Point(
crotchWidthOptionA > crotchWidthOptionB ? crotchWidthOptionA : crotchWidthOptionB * -1,
points.D.y
)
points.G = new Point(points.H.x, points.D.y)
points.X = points.G.shift(90, measurements.crotchDepth / 2)
points.N = points.H.shift(0, measurements.crotchDepth * options.backWaistFactor)
points.O = points.N.shift(0, measurements.backWaistArc * (1 + options.backWaistDart))
// Back dart
points.P = points.N.shift(0, measurements.backWaistArc * 0.56)
points.dartTip = points.P.shift(-90, measurements.crotchDepth * options.backWaistDartLength)
points.theoreticDart1 = points.P.shift(0, (measurements.backWaistArc * options.backWaistDart) / 2)
points.theoreticDart2 = points.theoreticDart1.flipX(points.P)
points.T = points.N.shift(90, measurements.crotchDepth * options.backRise)
points.extendedBackSeam = utils.beamsIntersect(points.I, points.D, points.T, points.X)
points.g = utils.beamsIntersect(
points.G,
points.G.shift(135, 10),
points.extendedBackSeam,
points.X
)
points.f = utils.beamsIntersect(points.C, points.F, points.T, points.X)
points.crossSeamCurveStart = points.f.shiftFractionTowards(
points.extendedBackSeam,
options.crossSeamCurveStart
)
points.crossSeamCurveCp = points.crossSeamCurveStart.shiftFractionTowards(
points.extendedBackSeam,
options.crossSeamCurveBend
)
// To insert a dart into a curve, we need to split the curve in two halves
// Rather than split the whole curve, we split one that is what we'd end
// up with with a closed dart, then shift the control points by half a dart.
let dartWidth = points.theoreticDart1.dx(points.theoreticDart2) / 2
let closedDartCurveEndpoint = points.T.shift(0, dartWidth)
// Insert dart into waist seamline
points.midDart = utils.curveIntersectsX(
points.O,
points.theoreticDart1,
closedDartCurveEndpoint,
closedDartCurveEndpoint,
points.dartTip.x
)
points.dart1 = new Point(points.theoreticDart1.x, points.midDart.y)
points.dart2 = new Point(points.theoreticDart2.x, points.midDart.y)
// Two halves
let [pathA, pathB] = new Path()
.move(points.O)
.curve_(points.theoreticDart1, closedDartCurveEndpoint)
.attr('class', 'stroke-xl lining')
.split(points.midDart)
// Extract control points from splitted curve
points.OCp2 = pathA.ops[1].cp1
points.dart1Cp1 = pathA.ops[1].cp2.shift(0, dartWidth / 2)
points.dart2Cp2 = pathB.ops[1].cp1.shift(180, dartWidth / 2)
points.CCp2 = points.C.shiftFractionTowards(points.A, 0.3)
points.W = points.D.shiftFractionTowards(points.I, options.grainlineBackFactor)
points.grainlineTop = utils.beamsIntersect(
points.W,
points.W.shift(90, 10),
points.dart2,
points.T
)
points.knee = new Point(points.grainlineTop.x, measurements.naturalWaistToKnee)
points.floor = new Point(points.grainlineTop.x, measurements.naturalWaistToFloor)
points.grainlineBottom = points.floor
let kneeEase = (measurements.kneeCircumference * options.kneeEase * options.legBalance) / 2
points.kneeOut = points.knee.shift(0, measurements.kneeCircumference / 4 + kneeEase)
points.kneeIn = points.kneeOut.flipX(points.knee)
// FIXME: We're using ankleEntry here. But I think ankleCircumference would make more sense
let ankleEase = (measurements.ankleEntry * options.ankleEase * options.legBalance) / 2
points.floorOut = points.floor.shift(0, measurements.ankleEntry / 4 + ankleEase)
points.floorIn = points.floorOut.flipX(points.floor)
points.kneeInCp1 = points.floorIn.shiftFractionTowards(points.kneeIn, 1 + options.inseamCurve)
points.kneeOutCp2 = points.floorOut.shiftFractionTowards(
points.kneeOut,
1 + options.outseamCurveKnee
)
points.CCp1 = points.A.shiftFractionTowards(points.C, 1 + options.outseamCurveSeat)
// Path prior to fitting the cross seam
/*
paths.origSeam = new Path()
.move(points.T)
.line(points.crossSeamCurveStart)
.curve_(points.crossSeamCurveCp, points.I)
._curve(points.kneeInCp1, points.kneeIn)
.line(points.floorIn)
.line(points.floorOut)
.line(points.kneeOut)
.curve(points.kneeOutCp2, points.CCp1, points.C)
.curve_(points.CCp2, points.O)
.curve(points.OCp2, points.dart1Cp1, points.dart1)
.line(points.dartTip)
.line(points.dart2)
.curve_(points.dart2Cp2, points.T)
.attr('class', 'fabric')
*/
// Should we fit the cross seam?
if (options.fitCrossSeam && options.fitBackCrossSeam) {
// Helper method to calculate the actual length of the cross seam
const crossSeamDelta = () => {
let len = new Path()
.move(points.T)
.line(points.crossSeamCurveStart)
.curve_(points.crossSeamCurveCp, points.I)
.length()
return len - measurements.backCrossSeam
}
// Clone some points
points.fPreSpread = points.f.clone()
points.fPostSpread = points.f.clone()
points.CPreShift = points.C.clone()
// Points involved in the slash and rotate
let rotate = [
'fPostSpread',
'T',
'midDart',
'dart1',
'dart2',
'dartTip',
'dart2Cp2',
'dart1Cp1',
'OCp2',
'O',
'CCp1',
'CCp2'
]
// Get to work
let delta = crossSeamDelta()
let run = 0
do {
run++
for (const i of rotate)
points[i] = points[i].rotate((delta / 5) * options.crossSeamFitBalance, points.C)
points.I = points.I.shift(0, (delta / 2.5) * (1 - options.crossSeamFitBalance))
points.extendedBackSeam = utils.beamsIntersect(
points.I,
points.D,
points.T,
points.crossSeamCurveStart
)
points.f = utils.beamsIntersect(points.C, points.F, points.T, points.crossSeamCurveStart)
points.crossSeamCurveStart = points.f.shiftFractionTowards(
points.extendedBackSeam,
options.crossSeamCurveStart
)
points.crossSeamCurveCp = points.crossSeamCurveStart.shiftFractionTowards(
points.extendedBackSeam,
options.crossSeamCurveBend
)
delta = crossSeamDelta()
} while (Math.abs(delta) > 0.5 && run < 50)
// Now assure the horizontal width is respected
let angle = points.C.angle(points.fPostSpread)
points.tmp = utils.beamsIntersect(
points.C,
points.fPostSpread,
points.T,
points.crossSeamCurveStart
)
let distance = points.fPostSpread.dist(points.tmp)
for (const i of ['C', 'CCp1', 'CCp2']) points[i] = points[i].shift(angle - 180, distance)
}
// Store inseam & outseam length
store.set(
'inseamBack',
new Path().move(points.I)._curve(points.kneeInCp1, points.kneeIn).line(points.floorIn).length()
)
store.set(
'outseamBack',
new Path()
.move(points.O)
._curve(points.CCp2, points.C)
.curve(points.CCp1, points.kneeOutCp2, points.kneeOut)
.line(points.floorOut)
.length()
)
paths.seam = new Path()
.move(points.T)
.line(points.crossSeamCurveStart)
.curve_(points.crossSeamCurveCp, points.I)
._curve(points.kneeInCp1, points.kneeIn)
.line(points.floorIn)
.line(points.floorOut)
.line(points.kneeOut)
.curve(points.kneeOutCp2, points.CCp1, points.C)
.curve_(points.CCp2, points.O)
.curve(points.OCp2, points.dart1Cp1, points.dart1)
.line(points.dartTip)
.line(points.dart2)
.curve_(points.dart2Cp2, points.T)
.attr('class', 'fabric')
if (complete) {
macro('grainline', {
from: points.grainlineTop,
to: points.grainlineBottom
})
if (paperless) {
}
}
return part
}

252
packages/titan/src/front.js Normal file
View file

@ -0,0 +1,252 @@
export default (part) => {
let {
points,
Point,
paths,
Path,
measurements,
options,
complete,
paperless,
store,
macro,
utils,
snippets,
Snippet
} = part.shorthand()
points.A = new Point(0, 0)
points.D = new Point(0, measurements.crotchDepth)
points.C = new Point(0, measurements.naturalWaistToSeat)
points.L = new Point(measurements.frontSeatArc * (1 + options.seatEase), 0)
points.J = new Point(points.L.x, points.C.y)
points.K = new Point(points.L.x, points.D.y)
points.M = points.K.shift(
0,
measurements.seatCircumference * options.crotchExtension * options.frontCrotchExtension
)
points.X = points.K.shiftFractionTowards(points.L, options.flySlopeHinge)
points.Q = points.L.shift(180, points.X.y * options.flySlopeFactor)
points.R = points.Q.shift(180, measurements.frontWaistArc * (1 + options.frontWaistDart))
points.U = points.Q.shift(90, measurements.frontWaistArc * options.frontWaistRise)
points.flyCurveMax = utils.beamsIntersect(points.U, points.X, points.M, points.M.shift(165, 10))
points.flyCurveStart = points.X.shiftFractionTowards(points.flyCurveMax, options.flyCurveStart)
points.flyCurveCp2 = points.flyCurveStart.shiftFractionTowards(
points.flyCurveMax,
options.flyCurveBend
)
points.flyCurveCp1 = points.M.shiftFractionTowards(points.flyCurveMax, options.flyCurveBend)
points.CCp1 = points.C.shift(90, points.C.y / 2)
points.Z = points.D.shiftFractionTowards(points.M, 0.52)
points.S = utils.beamsIntersect(points.Z, points.Z.shift(90, 10), points.R, points.U)
points.dartTip = points.S.shift(-90, points.X.y * options.frontWaistDartLength)
points.dart1 = points.S.shift(0, (measurements.frontWaistArc * options.frontWaistDart) / 2)
points.dart2 = points.dart1.rotate(180, points.S)
points.grainlineTop = points.S.clone()
points.floor = new Point(points.grainlineTop.x, measurements.naturalWaistToFloor)
points.grainlineBottom = points.floor
points.knee = new Point(points.grainlineTop.x, measurements.naturalWaistToKnee)
let kneeEase = (measurements.kneeCircumference * options.kneeEase * (1 - options.legBalance)) / 2
points.kneeOut = points.knee.shift(180, measurements.kneeCircumference / 4 + kneeEase)
points.kneeIn = points.kneeOut.flipX(points.knee)
// FIXME: We're using ankleEntry here. But I think ankleCircumference would make more sense
let ankleEase = (measurements.ankleEntry * options.ankleEase * (1 - options.legBalance)) / 2
points.floorOut = points.floor.shift(180, measurements.ankleEntry / 4 + ankleEase)
points.floorIn = points.floorOut.flipX(points.floor)
points.kneeInCp2 = points.floorIn.shiftFractionTowards(points.kneeIn, 1 + options.inseamCurve)
points.kneeOutCp1 = points.floorOut.shiftFractionTowards(
points.kneeOut,
1 + options.outseamCurveKnee
)
points.CCp2 = points.CCp1.rotate(180, points.C)
// Quick method to draw the path
const seamPath = () =>
new Path()
.move(points.R)
._curve(points.CCp1, points.C)
.curve(points.CCp2, points.kneeOutCp1, points.kneeOut)
.line(points.floorOut)
.line(points.floorIn)
.line(points.kneeIn)
.curve_(points.kneeInCp2, points.M)
.curve(points.flyCurveCp1, points.flyCurveCp2, points.flyCurveStart)
.line(points.U)
.line(points.dart1)
.line(points.dartTip)
.line(points.dart2)
.line(points.R)
.close()
// Path before fitting cross seam
//paths.origSeam = seamPath()
// Should we fit the cross seam?
if (options.fitCrossSeam && options.fitFrontCrossSeam) {
// Helper method to calculate the actual length of the cross seam
const crossSeamDelta = () => {
let len = new Path()
.move(points.U)
.line(points.flyCurveStart)
.curve(points.flyCurveCp2, points.flyCurveCp1, points.M)
.length()
return len - measurements.frontCrossSeam
}
let rotate = ['flyCurveStart', 'X', 'U', 'L', 'Q', 'dart1', 'dart2', 'S', 'dartTip', 'R']
// Store the original flycurve
const flyCurvePreFit = new Path()
.move(points.flyCurveStart)
.curve(points.flyCurveCp2, points.flyCurveCp1, points.M)
// Get to work
let delta = crossSeamDelta()
let run = 0
do {
run++
for (const i of rotate)
points[i] = points[i].rotate((delta / -5) * options.crossSeamFitBalance, points.C)
points.M = points.flyCurveCp1.shiftOutwards(
points.M,
(delta / -1) * (1 - options.crossSeamFitBalance)
)
points.flyCurveMax = utils.beamsIntersect(
points.U,
points.X,
points.M,
points.M.shift(165, 10)
)
points.flyCurveStart = points.X.shiftFractionTowards(
points.flyCurveMax,
options.flyCurveStart
)
points.flyCurveCp2 = points.flyCurveStart.shiftFractionTowards(
points.flyCurveMax,
options.flyCurveBend
)
points.flyCurveCp1 = points.M.shiftFractionTowards(points.flyCurveMax, options.flyCurveBend)
delta = crossSeamDelta()
} while (Math.abs(delta) > 0.5 && run < 5)
// Now assure the horizontal width is respected
const flyCurvePostFit = new Path()
.move(points.flyCurveStart)
.curve(points.flyCurveCp2, points.flyCurveCp1, points.M)
for (const i of ['CCp1', 'C', 'CCp2'])
points[i] = points[i].shift(
180,
flyCurvePostFit.intersectsY(points.C.y)[0].x - flyCurvePreFit.intersectsY(points.C.y)[0].x
)
}
//paths.intermediateSeam = seamPath().attr('class', 'various')
/*
* With the cross seams matched back and front,
* we still have to match the inseam and outseam
* (positive values = front is too long)
*/
const inseamDelta = () => {
store.set(
'inseamFront',
new Path()
.move(points.M)
._curve(points.kneeInCp2, points.kneeIn)
.line(points.floorIn)
.length()
)
return store.get('inseamFront') - store.get('inseamBack')
}
const outseamDelta = () => {
store.set(
'outseamFront',
new Path()
.move(points.R)
._curve(points.CCp1, points.C)
.curve(points.CCp2, points.kneeOutCp1, points.kneeOut)
.line(points.floorOut)
.length()
)
return store.get('outseamFront') - store.get('outseamBack')
}
const seamDelta = () => {
let inseam = inseamDelta()
let outseam = outseamDelta()
return Math.abs(inseam) > Math.abs(outseam) ? outseam : inseam
}
if ((inseamDelta() < 0 && outseamDelta() < 0) || (inseamDelta() > 0 && outseamDelta() > 0)) {
// Front is too short/long on both sides. Figure out smallest delta
let shift = [
'kneeInCp2',
'kneeOutCp1',
'kneeIn',
'kneeOut',
'knee',
'floorIn',
'floorOut',
'floor',
'grainlineBottom'
]
let delta = seamDelta()
let run = 0
do {
run++
for (const i of shift) points[i] = points[i].shift(90, delta)
delta = seamDelta()
} while (Math.abs(delta) > 1 && run < 10)
} else {
// There's an inbalance between back and front. Let's assume this will never happen
throw new Error('Unhandled inbalance between front and back inseam/outseam lengths')
}
// Which one needs fixing?
// in any case, we'll slash from R to M to fix this
let deltaMethod, factor
if (Math.abs(inseamDelta()) > 1) {
deltaMethod = inseamDelta
factor = -1
} else {
deltaMethod - outseamDelta
factor = 1
}
let rotate = [
'dart1',
'dart2',
'S',
'dartTip',
'U',
'Q',
'X',
'flyCurveStart',
'flyCurveCp1',
'flyCurveCp2'
]
rotate.push(factor === -1 ? 'M' : 'R')
let run = 0
let delta = deltaMethod()
do {
for (const i of rotate)
points[i] = points[i].rotate((delta / 10) * factor, points[factor === -1 ? 'R' : 'M'])
run++
delta = deltaMethod()
} while (Math.abs(delta) > 1 && run < 20)
paths.seam = seamPath().attr('class', 'fabric')
if (complete) {
macro('grainline', {
from: points.grainlineTop,
to: points.grainlineBottom
})
if (paperless) {
}
}
return part
}

View file

@ -0,0 +1,48 @@
import freesewing from '@freesewing/core'
import plugins from '@freesewing/plugin-bundle'
import config from '../config'
// Parts
import draftBack from './back'
import draftFront from './front'
const pluginMeasurements = {
name: 'measurements',
version: '0.0.1',
hooks: {
preDraft: function ({ settings }) {
if (
typeof settings.measurements.backSeat !== 'undefined' &&
typeof settings.measurements.seatCircumference !== 'undefined'
) {
settings.measurements.frontSeat =
settings.measurements.seatCircumference - settings.measurements.backSeat
settings.measurements.backSeatArc = settings.measurements.backSeat / 2
settings.measurements.frontSeatArc = settings.measurements.frontSeat / 2
}
if (
typeof settings.measurements.naturalWaist !== 'undefined' &&
typeof settings.measurements.backWaist !== 'undefined'
) {
settings.measurements.backWaistArc = settings.measurements.backWaist / 2
settings.measurements.frontWaistArc =
(settings.measurements.naturalWaist - settings.measurements.backWaist) / 2
}
if (
typeof settings.measurements.crossSeam !== 'undefined' &&
typeof settings.measurements.frontCrossSeam !== 'undefined'
) {
settings.measurements.backCrossSeam =
settings.measurements.crossSeam - settings.measurements.frontCrossSeam
}
}
}
}
// Create design
const Pattern = new freesewing.Design(config, [plugins, pluginMeasurements])
// Attach draft methods to prototype
Pattern.prototype.draftBack = (part) => draftBack(part)
Pattern.prototype.draftFront = (part) => draftFront(part)
export default Pattern

View file

@ -0,0 +1,21 @@
// This file is auto-generated.
// Changes you make will be overwritten.
const expect = require('chai').expect
const models = require('@freesewing/models')
const patterns = require('@freesewing/pattern-info')
const Trayvon = require('../dist')
// Shared tests
const testPatternConfig = require('../../../tests/patterns/config')
const testPatternDrafting = require('../../../tests/patterns/drafting')
const testPatternSampling = require('../../../tests/patterns/sampling')
// Test config
testPatternConfig('trayvon', new Trayvon(), expect, models, patterns)
// Test drafting
testPatternDrafting('trayvon', Trayvon, expect, models, patterns)
// Test sampling
testPatternSampling('trayvon', Trayvon, expect, models, patterns)