feat: Added package documentation (wip)
This commit is contained in:
parent
f734707163
commit
02da928f04
82 changed files with 2248 additions and 466 deletions
18
sites/dev/docs/reference/api/utils/cbqc/readme.mdx
Normal file
18
sites/dev/docs/reference/api/utils/cbqc/readme.mdx
Normal file
|
@ -0,0 +1,18 @@
|
|||
---
|
||||
title: utils.cbqc
|
||||
---
|
||||
|
||||
The `utils.cbqc` value holds `0.55191502449351`.
|
||||
This is the value to best approximate a (quarter) circle with cubic Bézier curves,
|
||||
as explained in the [Approximate a circle with cubic Bézier curves
|
||||
](https://spencermortensen.com/articles/bezier-circle/) article by Spencer Mortensen.
|
||||
|
||||
:::tip
|
||||
cbqc stands for Cubic Bezier Quarter Circle
|
||||
:::
|
||||
|
||||
## Signature
|
||||
|
||||
```js
|
||||
Number utils.cbqc
|
||||
```
|
|
@ -5,15 +5,6 @@ title: utils.curveIntersectsX()
|
|||
The `utils.curveIntersectsX()` function finds the point(s) where a curve
|
||||
intersects a given X-value.
|
||||
|
||||
:::warning
|
||||
|
||||
This function can sometimes fail to find intersections in some curves
|
||||
due to a limitation in an underlying Bézier library.
|
||||
Please see [Bug #3367](https://github.com/freesewing/freesewing/issues/3367)
|
||||
for more information.
|
||||
|
||||
:::
|
||||
|
||||
## Signature
|
||||
|
||||
```js
|
||||
|
@ -37,40 +28,41 @@ multiple intersections are found.
|
|||
```js
|
||||
({ Point, points, Path, paths, Snippet, snippets, utils, part }) => {
|
||||
|
||||
points.start = new Point(10, 15)
|
||||
points.cp1 = new Point(80, 10)
|
||||
points.cp2 = new Point(-50, 80)
|
||||
points.end = new Point(110, 70)
|
||||
points.start = new Point(10, 15)
|
||||
points.cp1 = new Point(80, 10)
|
||||
points.cp2 = new Point(-50, 80)
|
||||
points.end = new Point(110, 70)
|
||||
|
||||
paths.curve = new Path()
|
||||
.move(points.start)
|
||||
.curve(points.cp1, points.cp2, points.end)
|
||||
paths.curve = new Path()
|
||||
.move(points.start)
|
||||
.curve(points.cp1, points.cp2, points.end)
|
||||
|
||||
for (let x of [30, 40]) {
|
||||
points["from" + x] = new Point(x, 10)
|
||||
points["to" + x] = new Point(x, 80)
|
||||
paths["line" + x] = new Path()
|
||||
.move(points["from" + x])
|
||||
.line(points["to" + x])
|
||||
.addClass("lining dashed")
|
||||
}
|
||||
|
||||
snippets.i40 = new Snippet(
|
||||
"notch",
|
||||
utils.curveIntersectsX(points.start, points.cp1, points.cp2, points.end, 40)
|
||||
)
|
||||
|
||||
for (let p of utils.curveIntersectsX(
|
||||
points.start,
|
||||
points.cp1,
|
||||
points.cp2,
|
||||
points.end,
|
||||
30
|
||||
))
|
||||
snippets[p.y] = new Snippet("notch", p)
|
||||
|
||||
return part
|
||||
for (let x of [30, 40]) {
|
||||
points["from" + x] = new Point(x, 10)
|
||||
points["to" + x] = new Point(x, 80)
|
||||
paths["line" + x] = new Path()
|
||||
.move(points["from" + x])
|
||||
.line(points["to" + x])
|
||||
.addClass("lining dashed")
|
||||
}
|
||||
|
||||
snippets.i40 = new Snippet(
|
||||
"notch",
|
||||
utils.curveIntersectsX(points.start, points.cp1, points.cp2, points.end, 40)
|
||||
)
|
||||
|
||||
for (let p of utils.curveIntersectsX(
|
||||
points.start,
|
||||
points.cp1,
|
||||
points.cp2,
|
||||
points.end,
|
||||
30
|
||||
))
|
||||
snippets[p.y] = new Snippet("notch", p)
|
||||
|
||||
return part
|
||||
}
|
||||
|
||||
```
|
||||
</Example>
|
||||
|
||||
|
@ -81,3 +73,4 @@ This is a low-level (and faster) variant
|
|||
of [`Path.intersectsX()`](/reference/api/path/intersectsx).
|
||||
Instead of a path, you describe a single curve by passing the four
|
||||
points that describes it.
|
||||
```
|
||||
|
|
|
@ -5,15 +5,6 @@ title: utils.curveIntersectsY()
|
|||
The `utils.curveIntersectsY()` function finds the point(s) where a curve
|
||||
intersects a given Y-value.
|
||||
|
||||
:::warning
|
||||
|
||||
This function can sometimes fail to find intersections in some curves
|
||||
due to a limitation in an underlying Bézier library.
|
||||
Please see [Bug #3367](https://github.com/freesewing/freesewing/issues/3367)
|
||||
for more information.
|
||||
|
||||
:::
|
||||
|
||||
## Signature
|
||||
|
||||
```js
|
||||
|
@ -31,46 +22,47 @@ a single intersection is found, and an array
|
|||
of [Point](/reference/api/point/) objects if
|
||||
multiple intersections are found.
|
||||
|
||||
|
||||
## Example
|
||||
|
||||
<Example caption="A Utils.curveIntersectY() example">
|
||||
```js
|
||||
({ Point, points, Path, paths, Snippet, snippets, utils, part }) => {
|
||||
|
||||
points.start = new Point(10, 45)
|
||||
points.cp1 = new Point(50, 10)
|
||||
points.cp2 = new Point(0, 80)
|
||||
points.end = new Point(110, 70)
|
||||
points.start = new Point(10, 45)
|
||||
points.cp1 = new Point(50, 10)
|
||||
points.cp2 = new Point(0, 80)
|
||||
points.end = new Point(110, 70)
|
||||
|
||||
paths.curve = new Path()
|
||||
.move(points.start)
|
||||
.curve(points.cp1, points.cp2, points.end)
|
||||
paths.curve = new Path()
|
||||
.move(points.start)
|
||||
.curve(points.cp1, points.cp2, points.end)
|
||||
|
||||
for (let y of [40, 50]) {
|
||||
points["from" + y] = new Point(10, y)
|
||||
points["to" + y] = new Point(110, y)
|
||||
paths["line" + y] = new Path()
|
||||
.move(points["from" + y])
|
||||
.line(points["to" + y])
|
||||
.addClass("lining dashed")
|
||||
}
|
||||
|
||||
snippets.i50 = new Snippet(
|
||||
"notch",
|
||||
utils.curveIntersectsY(points.start, points.cp1, points.cp2, points.end, 50)
|
||||
)
|
||||
|
||||
for (let p of utils.curveIntersectsY(
|
||||
points.start,
|
||||
points.cp1,
|
||||
points.cp2,
|
||||
points.end,
|
||||
40
|
||||
))
|
||||
snippets[p.x] = new Snippet("notch", p)
|
||||
|
||||
return part
|
||||
for (let y of [40, 50]) {
|
||||
points["from" + y] = new Point(10, y)
|
||||
points["to" + y] = new Point(110, y)
|
||||
paths["line" + y] = new Path()
|
||||
.move(points["from" + y])
|
||||
.line(points["to" + y])
|
||||
.addClass("lining dashed")
|
||||
}
|
||||
|
||||
snippets.i50 = new Snippet(
|
||||
"notch",
|
||||
utils.curveIntersectsY(points.start, points.cp1, points.cp2, points.end, 50)
|
||||
)
|
||||
|
||||
for (let p of utils.curveIntersectsY(
|
||||
points.start,
|
||||
points.cp1,
|
||||
points.cp2,
|
||||
points.end,
|
||||
40
|
||||
))
|
||||
snippets[p.x] = new Snippet("notch", p)
|
||||
|
||||
return part
|
||||
}
|
||||
|
||||
```
|
||||
</Example>
|
||||
|
||||
|
@ -80,3 +72,4 @@ This is a low-level (and faster) variant
|
|||
of [`Path.intersectsY()`](/reference/api/path/intersectsy).
|
||||
Instead of a path, you describe a single curve by passing the four
|
||||
points that describes it.
|
||||
```
|
||||
|
|
|
@ -5,15 +5,6 @@ title: utils.curvesIntersect()
|
|||
The `utils.curvesIntersect()` function finds the intersections between two curves
|
||||
described by 4 points each.
|
||||
|
||||
:::warning
|
||||
|
||||
This function can sometimes fail to find intersections in some curves
|
||||
due to a limitation in an underlying Bézier library.
|
||||
Please see [Bug #3367](https://github.com/freesewing/freesewing/issues/3367)
|
||||
for more information.
|
||||
|
||||
:::
|
||||
|
||||
## Signature
|
||||
|
||||
```js
|
||||
|
@ -40,43 +31,45 @@ multiple intersections are found.
|
|||
```js
|
||||
({ Point, points, Path, paths, Snippet, snippets, utils, getId, part }) => {
|
||||
|
||||
points.A = new Point(10, 10)
|
||||
points.Acp = new Point(310, 40)
|
||||
points.B = new Point(110, 70)
|
||||
points.Bcp = new Point(-210, 40)
|
||||
points.A = new Point(10, 10)
|
||||
points.Acp = new Point(310, 40)
|
||||
points.B = new Point(110, 70)
|
||||
points.Bcp = new Point(-210, 40)
|
||||
|
||||
points.C = new Point(20, -5)
|
||||
points.Ccp = new Point(60, 300)
|
||||
points.D = new Point(100, 85)
|
||||
points.Dcp = new Point(70, -220)
|
||||
paths.curveA = new Path()
|
||||
.move(points.A)
|
||||
.curve(points.Acp, points.Bcp, points.B)
|
||||
paths.curveB = new Path()
|
||||
.move(points.C)
|
||||
.curve(points.Ccp, points.Dcp, points.D)
|
||||
points.C = new Point(20, -5)
|
||||
points.Ccp = new Point(60, 300)
|
||||
points.D = new Point(100, 85)
|
||||
points.Dcp = new Point(70, -220)
|
||||
paths.curveA = new Path()
|
||||
.move(points.A)
|
||||
.curve(points.Acp, points.Bcp, points.B)
|
||||
paths.curveB = new Path()
|
||||
.move(points.C)
|
||||
.curve(points.Ccp, points.Dcp, points.D)
|
||||
|
||||
const intersections = utils.curvesIntersect(
|
||||
points.A,
|
||||
points.Acp,
|
||||
points.Bcp,
|
||||
points.B,
|
||||
points.C,
|
||||
points.Ccp,
|
||||
points.Dcp,
|
||||
points.D
|
||||
)
|
||||
const intersections = utils.curvesIntersect(
|
||||
points.A,
|
||||
points.Acp,
|
||||
points.Bcp,
|
||||
points.B,
|
||||
points.C,
|
||||
points.Ccp,
|
||||
points.Dcp,
|
||||
points.D
|
||||
)
|
||||
|
||||
if (intersections) {
|
||||
if (intersections instanceof Array) {
|
||||
for (const p of intersections)
|
||||
snippets[getId()] = new Snippet('notch', p)
|
||||
} else {
|
||||
snippets[getId()] = new Snippet('notch', intersections)
|
||||
}
|
||||
}
|
||||
|
||||
return part
|
||||
if (intersections) {
|
||||
if (intersections instanceof Array) {
|
||||
for (const p of intersections)
|
||||
snippets[getId()] = new Snippet('notch', p)
|
||||
} else {
|
||||
snippets[getId()] = new Snippet('notch', intersections)
|
||||
}
|
||||
}
|
||||
|
||||
return part
|
||||
}
|
||||
|
||||
```
|
||||
</Example>
|
||||
```
|
||||
|
|
13
sites/dev/docs/reference/api/utils/goldenratio/readme.mdx
Normal file
13
sites/dev/docs/reference/api/utils/goldenratio/readme.mdx
Normal file
|
@ -0,0 +1,13 @@
|
|||
---
|
||||
title: utils.goldenRatio
|
||||
---
|
||||
|
||||
The `utils.goldenRatio` value holds `1.618034`.
|
||||
This value approximates **φ** which is also known
|
||||
as [the golden ratio](https://en.wikipedia.org/wiki/Golden_ratio).
|
||||
|
||||
## Signature
|
||||
|
||||
```js
|
||||
Number utils.goldenRatio
|
||||
```
|
17
sites/dev/docs/reference/api/utils/hidepresets/readme.mdx
Normal file
17
sites/dev/docs/reference/api/utils/hidepresets/readme.mdx
Normal file
|
@ -0,0 +1,17 @@
|
|||
---
|
||||
title: utils.hidePresets
|
||||
---
|
||||
|
||||
import { hidePresets } from '@freesewing/core'
|
||||
|
||||
The `utils.hidePresets` value holds presets to hiding parts in a FreeSewing design.
|
||||
|
||||
:::tip
|
||||
See [Hiding parts](/reference/api/part/config/hide/#presets) for an example of how to use this.
|
||||
:::
|
||||
|
||||
## Signature
|
||||
|
||||
```js
|
||||
Object utils.hideParts
|
||||
```
|
Loading…
Add table
Add a link
Reference in a new issue