2021-10-17 18:26:00 +02:00
|
|
|
---
|
|
|
|
title: reverse()
|
|
|
|
---
|
2021-08-25 16:09:31 +02:00
|
|
|
|
|
|
|
```js
|
|
|
|
Path path.reverse()
|
|
|
|
```
|
|
|
|
|
|
|
|
Returns a path that is the reversed version of this path. As in, start becomes end, and end becomes start.
|
|
|
|
|
|
|
|
<Note>
|
|
|
|
|
2021-10-17 18:26:00 +02: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.
|
|
|
|
|
|
|
|
If you want a deep copy, including the attributes, use `Path.clone().reverse()`.
|
|
|
|
|
|
|
|
</Note>
|
|
|
|
|
2022-01-19 11:31:39 +01:00
|
|
|
<Example part="path_reverse">
|
|
|
|
Example of the Path.reverse() method
|
|
|
|
</Example>
|
2021-08-25 16:09:31 +02:00
|
|
|
|
|
|
|
```js
|
|
|
|
let { Point, points, Path, paths } = part.shorthand();
|
|
|
|
|
|
|
|
points.B = new Point(10, 30);
|
|
|
|
points.BCp2 = new Point(40, 20);
|
|
|
|
points.C = new Point(90, 30);
|
|
|
|
points.CCp1 = new Point(50, -30);
|
|
|
|
|
|
|
|
paths.example = new Path()
|
|
|
|
.move(points.B)
|
|
|
|
.curve(points.BCp2, points.CCp1, points.C)
|
|
|
|
.attr("data-text", "freesewingIsMadeByJoostDeCockAndContributors")
|
|
|
|
.attr("data-text-class", "text-xs fill-note");
|
|
|
|
|
|
|
|
paths.reverse = paths.example
|
|
|
|
.reverse()
|
|
|
|
.attr("data-text", "freesewingIsMadeByJoostDeCockAndContributors")
|
|
|
|
.attr("data-text-class", "text-xs fill-lining");
|
|
|
|
```
|