2021-10-17 18:26:00 +02:00
|
|
|
---
|
2022-09-27 18:24:35 +02:00
|
|
|
title: Path.intersectsX()
|
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.intersectsX()` method returns the Point object(s) where the path
|
|
|
|
intersects with a given X-value.
|
|
|
|
|
2023-04-04 22:04:53 -07:00
|
|
|
<Warning>
|
|
|
|
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.
|
|
|
|
</Warning>
|
|
|
|
|
2022-09-27 18:24:35 +02:00
|
|
|
## Signature
|
|
|
|
|
2021-08-25 16:09:31 +02:00
|
|
|
```js
|
|
|
|
array|false path.intersectsX(float x)
|
|
|
|
```
|
|
|
|
|
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.intersectsX() 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(95, 50)
|
|
|
|
points.B = new Point(10, 30)
|
|
|
|
points.BCp2 = new Point(40, 20)
|
|
|
|
points.C = new Point(90, 30)
|
|
|
|
points.CCp1 = new Point(50, -30)
|
|
|
|
points.D = new Point(50, 130)
|
|
|
|
points.DCp1 = new Point(150, 30)
|
2022-12-30 07:47:29 -08:00
|
|
|
|
2022-09-29 17:50:53 +02:00
|
|
|
points.top = new Point(60, -10)
|
|
|
|
points.bot = new Point(60, 140)
|
2022-12-30 07:47:29 -08:00
|
|
|
|
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-12-30 07:47:29 -08:00
|
|
|
|
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-12-30 07:47:29 -08:00
|
|
|
|
2022-09-27 18:24:35 +02:00
|
|
|
for (let p of paths.demo.intersectsX(60)) {
|
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>
|