2021-08-25 16:09:31 +02:00
|
|
|
---
|
|
|
|
title: Drawing the bib outline
|
|
|
|
order: 190
|
|
|
|
---
|
|
|
|
|
|
|
|
With our neck opening in place, let's draw the basic outline of our bib:
|
|
|
|
|
|
|
|
```js
|
2021-08-25 16:16:51 +02:00
|
|
|
let width = measurements.head * options.widthRatio
|
|
|
|
let length = measurements.head * options.lengthRatio
|
2021-08-25 16:09:31 +02:00
|
|
|
|
|
|
|
points.topLeft = new Point(
|
|
|
|
width / -2,
|
|
|
|
points.top.y - (width / 2 - points.right.x)
|
|
|
|
);
|
2021-08-25 16:16:51 +02:00
|
|
|
points.topRight = points.topLeft.shift(0, width)
|
|
|
|
points.bottomLeft = points.topLeft.shift(-90, length)
|
|
|
|
points.bottomRight = points.topRight.shift(-90, length)
|
2021-08-25 16:09:31 +02:00
|
|
|
|
|
|
|
paths.rect = new Path()
|
|
|
|
.move(points.topLeft)
|
|
|
|
.line(points.bottomLeft)
|
|
|
|
.line(points.bottomRight)
|
|
|
|
.line(points.topRight)
|
|
|
|
.line(points.topLeft)
|
2021-08-25 16:16:51 +02:00
|
|
|
.close()
|
2021-08-25 16:09:31 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
First thing we did was create the `width` and `length` variables to
|
|
|
|
save ourselves some typing:
|
|
|
|
|
|
|
|
```js
|
2021-08-25 16:16:51 +02:00
|
|
|
let width = measurements.head * options.widthRatio
|
|
|
|
let length = measurements.head * options.lengthRatio
|
2021-08-25 16:09:31 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
Both the length and width of your bib are a factor of the head circumference.
|
|
|
|
This way, your bib size will adapt to the size of the baby, and the user can tweak
|
|
|
|
the length and width by playing with the options you added to the pattern.
|
|
|
|
|
|
|
|
Once we have our variables, we're adding some new points, and a second path called `rect`.
|
|
|
|
|
|
|
|
```js
|
|
|
|
points.topLeft = new Point(
|
|
|
|
width / -2,
|
|
|
|
points.top.y - (width / 2 - points.right.x)
|
2021-08-25 16:16:51 +02:00
|
|
|
)
|
|
|
|
points.topRight = points.topLeft.shift(0, width)
|
|
|
|
points.bottomLeft = points.topLeft.shift(-90, length)
|
|
|
|
points.bottomRight = points.topRight.shift(-90, length)
|
2021-08-25 16:09:31 +02:00
|
|
|
|
|
|
|
paths.rect = new Path()
|
|
|
|
.move(points.topLeft)
|
|
|
|
.line(points.bottomLeft)
|
|
|
|
.line(points.bottomRight)
|
|
|
|
.line(points.topRight)
|
|
|
|
.line(points.topLeft)
|
2021-08-25 16:16:51 +02:00
|
|
|
.close()
|
2021-08-25 16:09:31 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
We're calculating the `topLeft` point so that the top edge of our bib
|
|
|
|
and the sides are equidistant from the neck neck opening.
|
|
|
|
|
|
|
|
You didn't have to do that. But it looks nicely balanced this way:
|
|
|
|
|
|
|
|
<Example pattern="tutorial" part="step5" caption="Note how the neck opening is the same distance from the left, right, and top edge" />
|
|
|
|
|