Restoring syntax-highlight (I changed my mind)
This commit is contained in:
parent
d683ac7025
commit
940cb08b68
7 changed files with 44 additions and 18 deletions
|
@ -24,15 +24,21 @@ This property will be an Array (a list) holding all required measurements for th
|
|||
I am using [*the official name* of the measurement](/reference/measurements) here. For head
|
||||
circumference, that name is `head`.
|
||||
|
||||
```src/bib.mjs
|
||||
function draftBib({ part }) => {
|
||||
<Fixme>
|
||||
The `design/src/bib.mjs` "language" title is out of date. It is used in the tutorial from this point forward to maintain syntax-highlight not yet available for the `src/bib.mjs` title, but should be replaced with `src/bib.mjs`.
|
||||
</Fixme>
|
||||
|
||||
```design/src/bib.mjs
|
||||
function draftBib({ part }) {
|
||||
return part
|
||||
}
|
||||
|
||||
export const bib = {
|
||||
name: 'fromscratch.bib',
|
||||
draft: draftBib,
|
||||
// highlight-start
|
||||
measurements: [ 'head' ],
|
||||
// highlight-end
|
||||
}
|
||||
```
|
||||
|
||||
|
|
|
@ -23,8 +23,8 @@ and the head circumference. Let's call it `neckRatio`.
|
|||
|
||||
For this, I will add the `options` property to our `bib` object:
|
||||
|
||||
```src/bib.mjs
|
||||
function draftBib({ part }) => {
|
||||
```design/src/bib.mjs
|
||||
function draftBib({ part }) {
|
||||
return part
|
||||
}
|
||||
|
||||
|
@ -32,6 +32,7 @@ export const bib = {
|
|||
name: 'fromscratch.bib',
|
||||
draft: draftBib,
|
||||
measurements: [ 'head' ],
|
||||
// highlight-start
|
||||
options: {
|
||||
neckRatio: {
|
||||
pct: 80,
|
||||
|
@ -40,6 +41,7 @@ export const bib = {
|
|||
menu: 'fit'
|
||||
},
|
||||
},
|
||||
// highlight-end
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -73,7 +75,7 @@ This is covered in more detail in [Part 3](/tutorials/pattern-design/part3) of t
|
|||
|
||||
Let's do something similar for the width and length of our bib:
|
||||
|
||||
```src/bib.mjs
|
||||
```design/src/bib.mjs
|
||||
function draftBib({ part }) => {
|
||||
return part
|
||||
}
|
||||
|
@ -89,6 +91,8 @@ export const bib = {
|
|||
max: 90,
|
||||
menu: 'fit'
|
||||
},
|
||||
|
||||
// highlight-start
|
||||
widthRatio: {
|
||||
pct: 45,
|
||||
min: 35,
|
||||
|
@ -101,6 +105,7 @@ export const bib = {
|
|||
max: 85,
|
||||
menu: 'style'
|
||||
},
|
||||
// highlight-end
|
||||
},
|
||||
}
|
||||
```
|
||||
|
|
|
@ -14,7 +14,7 @@ as it is, and simply chose to not show it.
|
|||
To accomplish this, we'll call the `hide()` method on our path:
|
||||
|
||||
<Example tutorial caption="A hidden path is not shown">
|
||||
```src/bib.mjs
|
||||
```design/src/bib.mjs
|
||||
function draftBib({
|
||||
Path,
|
||||
Point,
|
||||
|
@ -57,7 +57,9 @@ function draftBib({
|
|||
points.bottomCp2,
|
||||
points.bottom
|
||||
)
|
||||
// highlight-start
|
||||
.hide()
|
||||
// highlight-end
|
||||
|
||||
delta = paths.quarterNeck.length() - target
|
||||
if (delta > 0) tweak = tweak * 0.99
|
||||
|
@ -84,7 +86,7 @@ Let's add some more points, and then construct the complete path for the neck
|
|||
opening.
|
||||
|
||||
<Example tutorial caption="Our completed neck opening">
|
||||
```src/bib.mjs
|
||||
```design/src/bib.mjs
|
||||
function draftBib({
|
||||
Path,
|
||||
Point,
|
||||
|
@ -134,6 +136,7 @@ function draftBib({
|
|||
else tweak = tweak * 1.02
|
||||
} while (Math.abs(delta) > 1)
|
||||
|
||||
// highlight-start
|
||||
/*
|
||||
* Construct the complete neck opening
|
||||
*/
|
||||
|
@ -154,7 +157,7 @@ function draftBib({
|
|||
.curve(points.rightCp2, points.topCp1, points.top)
|
||||
.close()
|
||||
.addClass('fabric')
|
||||
|
||||
// highlight-end
|
||||
return part
|
||||
}
|
||||
```
|
||||
|
|
|
@ -15,14 +15,16 @@ 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:
|
||||
|
||||
```src/bib.mjs
|
||||
```design/src/bib.mjs
|
||||
function draftBib({
|
||||
Path,
|
||||
Point,
|
||||
paths,
|
||||
points,
|
||||
// highlight-start
|
||||
measurements,
|
||||
options,
|
||||
// highlight-end
|
||||
part,
|
||||
}) {
|
||||
|
||||
|
@ -37,7 +39,7 @@ Great. Now let's get to work.
|
|||
Let's add some points, and use them to draw our first curve:
|
||||
|
||||
<Example tutorial caption="Our very first path forms a quarter of our neck opening">
|
||||
```src/bib.mjs
|
||||
```design/src/bib.mjs
|
||||
function draftBib({
|
||||
Path,
|
||||
Point,
|
||||
|
@ -48,6 +50,7 @@ function draftBib({
|
|||
part,
|
||||
}) {
|
||||
|
||||
// highlight-start
|
||||
/*
|
||||
* Construct the quarter neck opening
|
||||
*/
|
||||
|
@ -76,6 +79,7 @@ function draftBib({
|
|||
points.bottomCp2,
|
||||
points.bottom
|
||||
)
|
||||
// highlight-end
|
||||
|
||||
return part
|
||||
}
|
||||
|
|
|
@ -6,8 +6,8 @@ order: 50
|
|||
Time to turn our attention to the draft method of our part.
|
||||
Inside our `src/bib.mjs` file, this is what it currently looks like:
|
||||
|
||||
```src/bib.mjs
|
||||
function draftBib({ part }) => {
|
||||
```design/src/bib.mjs
|
||||
function draftBib({ part }) {
|
||||
return part
|
||||
}
|
||||
```
|
||||
|
@ -29,7 +29,7 @@ equivalent:
|
|||
|
||||
<Tabs tabs="Without destructuring, With destructuring">
|
||||
<Tab>
|
||||
```src/bib.mjs
|
||||
```design/src/bib.mjs
|
||||
function draftBib(props) {
|
||||
|
||||
return props.part
|
||||
|
@ -38,7 +38,7 @@ function draftBib(props) {
|
|||
```
|
||||
</Tab>
|
||||
<Tab>
|
||||
```src/bib.mjs
|
||||
```design/src/bib.mjs
|
||||
function draftBib({ part }) {
|
||||
|
||||
return part
|
||||
|
@ -61,7 +61,7 @@ If you're new to JavaScript, and don't intuitively _get this_, stick with it. It
|
|||
|
||||
Change the function to look like this:
|
||||
|
||||
```src/bib.mjs
|
||||
```design/src/bib.mjs
|
||||
function draftBib({
|
||||
Path,
|
||||
Point,
|
||||
|
|
|
@ -8,7 +8,7 @@ going to make sure it is. Here's how we'll make sure the neck opening is _just
|
|||
right_:
|
||||
|
||||
<Example tutorial caption="It might look the same as before, but now it's just right">
|
||||
```src/bib.mjs
|
||||
```design/src/bib.mjs
|
||||
function draftBib({
|
||||
Path,
|
||||
Point,
|
||||
|
@ -22,17 +22,23 @@ function draftBib({
|
|||
/*
|
||||
* Construct the quarter neck opening
|
||||
*/
|
||||
// highlight-start
|
||||
let tweak = 1
|
||||
let target = (measurements.head * options.neckRatio) /4
|
||||
let delta
|
||||
do {
|
||||
// highlight-end
|
||||
points.right = new Point(
|
||||
// highlight-start
|
||||
tweak * measurements.head / 10,
|
||||
// highlight-end
|
||||
0
|
||||
)
|
||||
points.bottom = new Point(
|
||||
0,
|
||||
// highlight-start
|
||||
tweak * measurements.head / 12
|
||||
// highlight-end
|
||||
)
|
||||
|
||||
points.rightCp1 = points.right.shift(
|
||||
|
@ -52,11 +58,13 @@ function draftBib({
|
|||
points.bottom
|
||||
)
|
||||
|
||||
|
||||
// highlight-start
|
||||
delta = paths.quarterNeck.length() - target
|
||||
if (delta > 0) tweak = tweak * 0.99
|
||||
else tweak = tweak * 1.02
|
||||
} while (Math.abs(delta) > 1)
|
||||
|
||||
// highlight-end
|
||||
return part
|
||||
}
|
||||
```
|
||||
|
|
|
@ -12,7 +12,7 @@ will live in `design/from-scratch/src/bib.mjs`.
|
|||
|
||||
This `bib.mjs` file is where will be doing most of the work here in part 2 of this
|
||||
tutorial. But let's start with the `index.mjs` file as an appetizer, because this
|
||||
is where a new FreeSewing design is brought to live. It looks like this:
|
||||
is where a new FreeSewing design is brought to life. It looks like this:
|
||||
|
||||
```src/index.mjs
|
||||
import { Design } from '@freesewing/core'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue