2021-10-17 18:26:00 +02:00
|
|
|
---
|
2022-09-27 18:24:35 +02:00
|
|
|
title: Path.reverse()
|
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.reverse()` returns a path that is the reversed version of this path.
|
|
|
|
As in, start becomes end, and end becomes start.
|
|
|
|
|
|
|
|
## Signature
|
|
|
|
|
2021-08-25 16:09:31 +02:00
|
|
|
```js
|
2022-09-27 18:24:35 +02:00
|
|
|
Path path.reverse(bool cloneAttributes=false)
|
2021-08-25 16:09:31 +02:00
|
|
|
```
|
|
|
|
|
2022-09-27 18:24:35 +02:00
|
|
|
If you pass a truthy value to this method, it will return a deep clone of the
|
|
|
|
path, including its attributes. By default, it will return a shallow
|
2022-12-14 12:52:37 -08:00
|
|
|
copy, without the attributes.
|
2022-09-27 18:24:35 +02:00
|
|
|
|
|
|
|
## Example
|
|
|
|
|
|
|
|
|
|
|
|
<Example caption="Example of the Path.reverse() method">
|
|
|
|
```js
|
|
|
|
({ Point, points, Path, paths, part }) => {
|
|
|
|
|
2022-09-29 17:50:53 +02:00
|
|
|
points.B = new Point(10, 30)
|
|
|
|
points.BCp2 = new Point(40, 20)
|
|
|
|
points.C = new Point(90, 30)
|
|
|
|
points.CCp1 = new Point(50, -30)
|
2022-09-27 18:24:35 +02:00
|
|
|
|
|
|
|
paths.example = new Path()
|
|
|
|
.move(points.B)
|
|
|
|
.curve(points.BCp2, points.CCp1, points.C)
|
|
|
|
.setText("FreeSewing rocks", "text-xs fill-note center")
|
|
|
|
|
|
|
|
paths.reverse = paths.example.reverse(true)
|
|
|
|
|
|
|
|
return part
|
|
|
|
}
|
|
|
|
```
|
|
|
|
</Example>
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-09-27 18:24:35 +02:00
|
|
|
## Notes
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-02-19 08:04:25 +01:00
|
|
|
The reversed path is a shallow copy.
|
2021-08-25 16:09:31 +02:00
|
|
|
It will in other words not inherit the attributes of the original path.
|
|
|
|
|
2022-09-27 18:24:35 +02:00
|
|
|
If you want a deep copy, including the attributes, use `Path.reverse(true)`.
|
2021-08-25 16:09:31 +02:00
|
|
|
|
|
|
|
|