1
0
Fork 0

chore(markdown): Updated utils docs for v3

This commit is contained in:
Joost De Cock 2022-10-01 22:20:43 +02:00
parent acf1b72c4c
commit bc3b0cd770
23 changed files with 782 additions and 622 deletions

View file

@ -1,7 +1,13 @@
---
title: lineIntersectsCurve()
title: utils.lineIntersectsCurve()
---
The `utils.lineIntersectsCurve()` function finds the intersection between a line
segment from point `from` to point `to` and a curve described by points
`start`, `cp1`, `cp2, and `end\`.
## Signature
```js
array | false utils.lineIntersectsCurve(
Point from,
@ -13,43 +19,36 @@ array | false utils.lineIntersectsCurve(
)
```
Finds the intersection between a line segment from point `from` to point `to`
and a curve described by points `start`, `cp1`, `cp2, and `end\`.
<Example part="utils_lineintersectscurve">
A Utils.lineIntersectsCurve() example
</Example>
## Example
<Example caption="A Utils.lineIntersectsCurve() example">
```js
let {
Point,
points,
Path,
paths,
Snippet,
snippets,
utils
} = part.shorthand();
({ Point, points, Path, paths, Snippet, snippets, getId, utils, 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.E = new Point(20, -5);
points.D = new Point(100, 85);
paths.curve = new Path()
.move(points.A)
.curve(points.Acp, points.Bcp, points.B);
paths.line = new Path().move(points.E).line(points.D);
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.E = new Point(20, -5)
points.D = new Point(100, 85)
paths.curve = new Path()
.move(points.A)
.curve(points.Acp, points.Bcp, points.B)
paths.line = new Path().move(points.E).line(points.D)
for (let p of utils.lineIntersectsCurve(
points.D,
points.E,
points.A,
points.Acp,
points.Bcp,
points.B
)) {
snippets[getId()] = new Snippet("notch", p)
}
for (let p of utils.lineIntersectsCurve(
points.D,
points.E,
points.A,
points.Acp,
points.Bcp,
points.B
)) {
snippets[part.getId()] = new Snippet("notch", p);
return part
}
```
</Example>