
This PR reverts the incorrect lint/prettier changes applied to <Example> code in the reference Core API docs l by the husky pre-commit hook, the problem mentioned in Issue #333. (These are just the changes for the Core API docs. Additional PRs will be filed for changes in the other reference, howtos, and guides documentation.) Co-authored-by: Benjamin Fan <ben-git@swinglonga.com> Reviewed-on: https://codeberg.org/freesewing/freesewing/pulls/367 Reviewed-by: Joost De Cock <joostdecock@noreply.codeberg.org> Co-authored-by: Benjamin Fan <benjamesben@noreply.codeberg.org> Co-committed-by: Benjamin Fan <benjamesben@noreply.codeberg.org>
45 lines
1 KiB
Text
45 lines
1 KiB
Text
---
|
|
title: utils.beamIntersectsLine()
|
|
---
|
|
|
|
The `utils.beamIntersectsLine()` function finds the intersection between an endless
|
|
line (beam) and a (limited) line segment. Returns a [Point](/reference/api/point) object for the
|
|
intersection, or `false` if the beam doesn't intersect the line.
|
|
|
|
The first two points in the parameter list form the beam, the last two points form the line.
|
|
|
|
## Signature
|
|
|
|
```js
|
|
Point | false utils.beamIntersectsLine(
|
|
Point beamA,
|
|
Point beamB,
|
|
Point lineA,
|
|
Point lineB
|
|
)
|
|
```
|
|
|
|
## Example
|
|
|
|
<Example caption="A Utils.beamIntersectsLine() example">
|
|
|
|
```js
|
|
({ Point, points, Path, paths, Snippet, snippets, utils, part }) => {
|
|
points.A = new Point(45, 20)
|
|
points.B = new Point(60, 15)
|
|
points.C = new Point(10, 10)
|
|
points.D = new Point(50, 40)
|
|
|
|
paths.AB = new Path().move(points.A).line(points.B).addClass('dotted')
|
|
paths.CD = new Path().move(points.C).line(points.D)
|
|
|
|
snippets.x = new Snippet(
|
|
'notch',
|
|
utils.beamIntersectsLine(points.A, points.B, points.C, points.D)
|
|
)
|
|
|
|
return part
|
|
}
|
|
```
|
|
|
|
</Example>
|