2021-10-17 18:26:00 +02:00
|
|
|
---
|
2022-09-27 18:24:35 +02:00
|
|
|
title: Path.intersectsY()
|
2021-10-17 18:26:00 +02:00
|
|
|
---
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-09-27 18:24:35 +02:00
|
|
|
The `Path.intersectsY()` method returns the Point object(s) where the path
|
|
|
|
intersects with a given Y-value.
|
|
|
|
|
2024-09-28 13:13:48 +02:00
|
|
|
:::warning
|
2023-04-05 15:02:57 -07:00
|
|
|
|
2023-04-04 22:04:53 -07:00
|
|
|
This method 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.
|
2023-04-05 15:02:57 -07:00
|
|
|
|
2024-09-28 13:13:48 +02:00
|
|
|
:::
|
2023-04-04 22:04:53 -07:00
|
|
|
|
2022-09-27 18:24:35 +02:00
|
|
|
## Signature
|
|
|
|
|
2021-08-25 16:09:31 +02:00
|
|
|
```js
|
2024-09-25 14:06:17 +02:00
|
|
|
array path.intersectsY(float y)
|
2021-08-25 16:09:31 +02:00
|
|
|
```
|
|
|
|
|
2022-09-27 18:24:35 +02:00
|
|
|
## Example
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-09-27 18:24:35 +02:00
|
|
|
<Example caption="Example of the Path.intersectsY() method">
|
2021-08-25 16:09:31 +02:00
|
|
|
```js
|
2022-09-27 18:24:35 +02:00
|
|
|
({ Point, points, Path, paths, snippets, Snippet, getId, part }) => {
|
|
|
|
|
2022-09-29 17:50:53 +02:00
|
|
|
points.A = new Point(55, 40)
|
|
|
|
points.B = new Point(10, 70)
|
|
|
|
points.BCp2 = new Point(40, 20)
|
|
|
|
points.C = new Point(90, 60)
|
|
|
|
points.CCp1 = new Point(50, -30)
|
|
|
|
points.D = new Point(50, 80)
|
|
|
|
points.DCp1 = new Point(140, 50)
|
2022-09-27 18:24:35 +02:00
|
|
|
|
2022-09-29 17:50:53 +02:00
|
|
|
points.top = new Point(10, 58)
|
|
|
|
points.bot = new Point(130, 58)
|
2022-09-27 18:24:35 +02:00
|
|
|
|
|
|
|
paths.line = new Path()
|
|
|
|
.move(points.top)
|
|
|
|
.line(points.bot)
|
2022-09-29 17:50:53 +02:00
|
|
|
.attr("class", "lining dashed")
|
2022-09-27 18:24:35 +02:00
|
|
|
|
|
|
|
paths.demo = new Path()
|
|
|
|
.move(points.A)
|
|
|
|
.line(points.B)
|
|
|
|
.curve(points.BCp2, points.CCp1, points.C)
|
2022-09-29 17:50:53 +02:00
|
|
|
.curve(points.DCp1, points.DCp1, points.D)
|
2022-09-27 18:24:35 +02:00
|
|
|
|
|
|
|
for (let p of paths.demo.intersectsY(58)) {
|
2022-09-29 17:50:53 +02:00
|
|
|
snippets[getId()] = new Snippet("notch", p)
|
2022-09-27 18:24:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return part
|
2021-08-25 16:09:31 +02:00
|
|
|
}
|
|
|
|
```
|
2022-09-27 18:24:35 +02:00
|
|
|
</Example>
|