1
0
Fork 0

chore: Updating final Snippet docs for v3

This commit is contained in:
Joost De Cock 2022-09-29 18:08:09 +02:00
parent 9ddad408b0
commit 80a3dd1a2c
3 changed files with 83 additions and 35 deletions

View file

@ -1,25 +1,36 @@
---
title: clone()
title: Snippet.clone()
---
The `Snippet.clone()` method returns a new Snippets object that is a deep copy
of this one.
## Signature
```js
Snippet snippet.clone()
```
Returns a new Snippets object that is a deep copy of this one.
## Example
<Example part="snippet_clone">
An example of the Snippet.clone() method
<Example caption="An example of the Snippet.clone() method">
```js
({ Point, Path, paths, Snippet, snippets, part }) => {
snippets.demo = new Snippet("logo", new Point(0,0))
.attr("style", "color: #f006")
snippets.clone = snippets.demo
.clone()
.attr("data-scale", 0.5)
// Prevent clipping
paths.diag = new Path()
.move(new Point(-25,-30))
.move(new Point(25,15))
return part
}
```
</Example>
```js
let { Point, points, Snippet, snippets } = part.shorthand();
points.anchor = new Point(35, 35);
snippets.demo = new Snippet("logo", points.anchor)
.attr("style", "color: #f006");
snippets.clone = snippets.demo
.clone()
.attr("data-scale", 0.5);
```