2021-10-17 18:26:00 +02:00
|
|
|
---
|
2021-10-16 15:42:30 +02:00
|
|
|
title: Point.clone()
|
2021-10-17 18:26:00 +02:00
|
|
|
---
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2021-11-06 18:20:45 +01:00
|
|
|
Returns a new `Point` with the same coordinates and attributes as the original point.
|
2021-10-16 15:42:30 +02:00
|
|
|
|
2021-11-06 19:03:54 +01:00
|
|
|
## Point.clone() signature
|
|
|
|
|
2021-10-16 15:42:30 +02:00
|
|
|
```js
|
2021-10-17 18:26:00 +02:00
|
|
|
Point point.clone()
|
|
|
|
```
|
2021-08-25 16:09:31 +02:00
|
|
|
|
|
|
|
<Note>
|
|
|
|
|
|
|
|
###### Copy vs clone
|
|
|
|
|
2022-08-20 18:07:26 -04:00
|
|
|
The [`Point.copy()`](/reference/api/point/copy/) method will only copy the point's coordinates, whereas this
|
2021-08-25 16:09:31 +02:00
|
|
|
`Point.clone()` method will also copy its attributes.
|
|
|
|
|
|
|
|
</Note>
|
|
|
|
|
2021-11-06 19:03:54 +01:00
|
|
|
## Point.clone() example
|
|
|
|
|
2022-01-19 11:31:39 +01:00
|
|
|
<Example part="point_clone">
|
|
|
|
An example of the Point.clone() method
|
|
|
|
</Example>
|
2021-08-25 16:09:31 +02:00
|
|
|
|
|
|
|
```js
|
|
|
|
let { Point, points, Snippet, snippets } = part.shorthand();
|
|
|
|
|
|
|
|
points.A = new Point(25, 25)
|
|
|
|
.attr("data-text", "Point A")
|
|
|
|
.attr("data-text-class", "text-xl")
|
|
|
|
.attr("data-text-fill-opacity", "0.5");
|
|
|
|
points.B = points.A.clone().attr("data-text", "Point B");
|
|
|
|
|
|
|
|
snippets.x = new Snippet("notch", points.A);
|
|
|
|
```
|