2021-10-17 18:26:00 +02:00
|
|
|
---
|
2021-08-25 16:09:31 +02:00
|
|
|
title: Constructing the neck opening
|
2024-11-18 11:05:16 +01:00
|
|
|
sidebar_position: 60
|
2021-10-17 18:26:00 +02:00
|
|
|
---
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-10-10 04:50:43 +02:00
|
|
|
Our goal is to construct an oval neck opening that has a circumference
|
|
|
|
that is the `head` measurements multiplied by the `neckRatio` option.
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-12-03 16:34:38 +01:00
|
|
|
That might involve some trial and error. But since the neck opening will be symmetric
|
2022-10-10 04:50:43 +02:00
|
|
|
both horizontal and vertical, we only need to construct one quadrant.
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-12-29 06:25:01 -08:00
|
|
|
## Destructuring measurements and options
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-10-10 04:50:43 +02:00
|
|
|
We'll be adding some points to our pattern to do just that. But we want to have
|
|
|
|
access to our measurements and options to do so. For this, we first destructure
|
|
|
|
`measurements` and `options` so we can access them:
|
|
|
|
|
2024-03-14 02:13:56 +00:00
|
|
|
```design/src/bib.mjs
|
2023-01-06 19:29:29 -08:00
|
|
|
function draftBib({
|
|
|
|
Path,
|
|
|
|
Point,
|
|
|
|
paths,
|
|
|
|
points,
|
2024-03-14 02:13:56 +00:00
|
|
|
// highlight-start
|
2021-08-25 16:09:31 +02:00
|
|
|
measurements,
|
2023-03-21 22:30:17 -07:00
|
|
|
options,
|
2024-03-14 02:13:56 +00:00
|
|
|
// highlight-end
|
2022-10-10 04:50:43 +02:00
|
|
|
part,
|
|
|
|
}) {
|
|
|
|
|
|
|
|
return part
|
|
|
|
}
|
2021-08-25 16:09:31 +02:00
|
|
|
```
|
|
|
|
|
2022-10-10 04:50:43 +02:00
|
|
|
Great. Now let's get to work.
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-10-10 04:50:43 +02:00
|
|
|
## Drawing our first path
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-10-10 04:50:43 +02:00
|
|
|
Let's add some points, and use them to draw our first curve:
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-10-10 04:50:43 +02:00
|
|
|
<Example tutorial caption="Our very first path forms a quarter of our neck opening">
|
2024-03-14 02:13:56 +00:00
|
|
|
```design/src/bib.mjs
|
2023-01-06 19:29:29 -08:00
|
|
|
function draftBib({
|
|
|
|
Path,
|
|
|
|
Point,
|
|
|
|
paths,
|
|
|
|
points,
|
2022-10-10 04:50:43 +02:00
|
|
|
measurements,
|
|
|
|
options,
|
|
|
|
part,
|
|
|
|
}) {
|
|
|
|
|
2024-03-14 02:13:56 +00:00
|
|
|
// highlight-start
|
2024-11-18 11:05:16 +01:00
|
|
|
/\*
|
|
|
|
|
|
|
|
- Construct the quarter neck opening
|
|
|
|
\*/
|
2023-09-30 14:04:18 +02:00
|
|
|
points.right = new Point(
|
2024-11-18 11:05:16 +01:00
|
|
|
measurements.head / 10,
|
|
|
|
0
|
2023-09-30 14:04:18 +02:00
|
|
|
)
|
|
|
|
points.bottom = new Point(
|
2024-11-18 11:05:16 +01:00
|
|
|
0,
|
|
|
|
measurements.head / 12
|
2023-09-30 14:04:18 +02:00
|
|
|
)
|
|
|
|
|
2024-11-18 11:05:16 +01:00
|
|
|
points.rightCp1 = points.right.shift(
|
|
|
|
90,
|
|
|
|
points.bottom.dy(points.right) / 2
|
|
|
|
)
|
|
|
|
points.bottomCp2 = points.bottom.shift(
|
|
|
|
0,
|
|
|
|
points.bottom.dx(points.right) / 2
|
|
|
|
)
|
2023-01-06 19:29:29 -08:00
|
|
|
|
2024-11-18 11:05:16 +01:00
|
|
|
paths.quarterNeck = new Path()
|
|
|
|
.move(points.right)
|
|
|
|
.curve(
|
|
|
|
points.rightCp1,
|
|
|
|
points.bottomCp2,
|
|
|
|
points.bottom
|
|
|
|
)
|
2024-03-14 02:13:56 +00:00
|
|
|
// highlight-end
|
2022-10-10 04:50:43 +02:00
|
|
|
|
2024-11-18 11:05:16 +01:00
|
|
|
return part
|
2022-10-10 04:50:43 +02:00
|
|
|
}
|
2024-11-18 11:05:16 +01:00
|
|
|
|
|
|
|
````
|
2022-10-10 04:50:43 +02:00
|
|
|
</Example>
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2023-01-06 19:29:29 -08:00
|
|
|
We've added some points to our part, and drawn our first path.
|
2022-10-10 04:50:43 +02:00
|
|
|
Let's look at each line in detail.
|
|
|
|
|
|
|
|
## Adding points
|
2021-08-25 16:09:31 +02:00
|
|
|
|
|
|
|
```js
|
2023-09-30 14:04:18 +02:00
|
|
|
points.right = new Point(
|
2024-11-18 11:05:16 +01:00
|
|
|
measurements.head / 10,
|
2023-09-30 14:04:18 +02:00
|
|
|
0
|
|
|
|
)
|
2024-11-18 11:05:16 +01:00
|
|
|
````
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-10-10 04:50:43 +02:00
|
|
|
- We're adding a point named `right` to the `points` object which holds our
|
|
|
|
part's points
|
|
|
|
- We're using the Point constructor, which takes two arguments: The point's X
|
2023-09-30 14:04:18 +02:00
|
|
|
and Y coordinates in the 2-dimensional space
|
2022-02-20 14:44:38 +01:00
|
|
|
- The X value is `measurements.head / 10`
|
|
|
|
- The Y value is `0`
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-10-10 04:50:43 +02:00
|
|
|
The creation of `points.bottom` is very similar, so let's skip to the next line:
|
2021-08-25 16:09:31 +02:00
|
|
|
|
|
|
|
```js
|
2024-11-18 11:05:16 +01:00
|
|
|
points.rightCp1 = points.right.shift(90, points.bottom.dy(points.right) / 2)
|
2021-08-25 16:09:31 +02:00
|
|
|
```
|
|
|
|
|
2022-10-10 04:50:43 +02:00
|
|
|
- We're adding a point named `rightCp1`, which will become the _control point_
|
|
|
|
of the right part
|
|
|
|
- Instead of using the Point constructor, we're calling the `Point.shift()`
|
|
|
|
method on an existing point
|
2022-02-20 14:44:38 +01:00
|
|
|
- It takes two arguments: The angle to shift towards, and the distance
|
2023-01-06 19:29:29 -08:00
|
|
|
- We can see that we're shifting 90 degrees (that means up) but the distance
|
2022-10-10 04:50:43 +02:00
|
|
|
uses another method
|
|
|
|
- The `Point.dy()` method returns the delta along the Y axis between the point
|
2023-01-06 19:29:29 -08:00
|
|
|
we call it on and the point we pass it
|
2022-02-20 14:44:38 +01:00
|
|
|
- We shift half of the Y-delta
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-10-10 04:50:43 +02:00
|
|
|
The next point is very similar again, except that this time we're shifting to
|
|
|
|
the right (0 degrees) for half of the X-delta between points `bottom` and
|
|
|
|
`right`.
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2024-09-28 13:13:48 +02:00
|
|
|
:::tip
|
2024-11-18 11:05:16 +01:00
|
|
|
|
2022-10-10 04:50:43 +02:00
|
|
|
##### Further reading
|
2024-11-18 11:05:16 +01:00
|
|
|
|
2022-10-10 04:50:43 +02:00
|
|
|
The `Point.shift()` and `Point.dy()` are just the tip of the iceberg.
|
2022-02-19 08:04:25 +01:00
|
|
|
Points come with a bunch of these methods.
|
2021-08-25 16:09:31 +02:00
|
|
|
You can find them all in [the Point API docs](/reference/api/point/).
|
2024-09-28 13:13:48 +02:00
|
|
|
:::
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-10-10 04:50:43 +02:00
|
|
|
## Adding paths
|
|
|
|
|
|
|
|
Adding points is typically merely a means to an end. And that end gets
|
|
|
|
introduced on the next line: Paths.
|
2021-08-25 16:09:31 +02:00
|
|
|
|
|
|
|
```js
|
2021-09-04 14:31:21 +02:00
|
|
|
paths.quarterNeck = new Path()
|
2021-08-25 16:09:31 +02:00
|
|
|
.move(points.right)
|
2024-11-18 11:05:16 +01:00
|
|
|
.curve(points.rightCp1, points.bottomCp2, points.bottom)
|
2021-08-25 16:09:31 +02:00
|
|
|
```
|
|
|
|
|
2022-10-10 04:50:43 +02:00
|
|
|
- We're adding a path named `quarterNeck` to the `paths` object which holds our
|
|
|
|
part's paths
|
2022-02-20 14:44:38 +01:00
|
|
|
- We're using the Path constructor, which takes no arguments
|
|
|
|
- We're following up with a `Path.move()` call that takes one Point as argument
|
|
|
|
- Then, there's a `Path.curve()` call that takes 3 points as arguments
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2024-06-29 22:40:10 +03:00
|
|
|
If you've read through the high-level [Design guide](/guides/designs) you
|
2022-10-10 04:50:43 +02:00
|
|
|
will have learned that paths always start with a `move()` operation. In this
|
|
|
|
case, we moved to our `right` points.
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-12-23 21:56:40 -08:00
|
|
|
From there, we drew a cubic Bézier curve to our `bottom` point by using
|
2022-10-10 04:50:43 +02:00
|
|
|
`rightCp1` and `bottomCp2` as control points.
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2024-09-28 13:13:48 +02:00
|
|
|
:::tip
|
2023-09-30 14:04:18 +02:00
|
|
|
|
2024-11-18 11:05:16 +01:00
|
|
|
Many of the methods in the FreeSewing API are _chainable_ allowing you
|
2023-09-30 14:04:18 +02:00
|
|
|
to string them together like in this example.
|
2024-09-28 13:13:48 +02:00
|
|
|
:::
|
2023-09-30 14:04:18 +02:00
|
|
|
|
2022-10-10 04:50:43 +02:00
|
|
|
When all is said and done, we now have a quarter of our neck opening.
|
2021-08-25 16:09:31 +02:00
|
|
|
The only problem is, we have no guarantee whatsoever that this opening is the correct size.
|
|
|
|
|
2022-10-10 04:50:43 +02:00
|
|
|
Rather than hope it is the correct size, we'll make sure it is next.
|