chore: Updating final Snippet docs for v3
This commit is contained in:
parent
9ddad408b0
commit
80a3dd1a2c
3 changed files with 83 additions and 35 deletions
|
@ -3,17 +3,21 @@ title: Snippet
|
|||
order: 35
|
||||
---
|
||||
|
||||
A snippet is a reuseable bit of markup for your pattern. They are added to the
|
||||
A Snippet is a reuseable bit of markup for your pattern. They are added to the
|
||||
SVG `defs` section, and rendered with the SVG `use` tag.
|
||||
|
||||
## Signature
|
||||
|
||||
```js
|
||||
Snippet new Snippet(def, Point);
|
||||
```
|
||||
|
||||
The snippet constructor takes two arguments:
|
||||
|
||||
- `def` : The `xlink:href` id that links to the relevant entry in the SVG `defs` section
|
||||
- `anchor` : A [`Point`](/reference/api/point) on which to anchor the snippet
|
||||
|
||||
```js
|
||||
Snippet new Snippet(def, Point);
|
||||
```
|
||||
## Attributes
|
||||
|
||||
A Snippet object comes with the following properties:
|
||||
|
||||
|
@ -21,6 +25,26 @@ A Snippet object comes with the following properties:
|
|||
- `anchor` : A [`Point`](/reference/api/point) on which to anchor the snippet
|
||||
- `attributes` : An [`Attributes`](/reference/api/attributes) instance holding the snippet's attributes
|
||||
|
||||
In addition, a Snippet object exposes the following methods:
|
||||
## Example
|
||||
|
||||
<Example caption="Example of the Snippet constructor">
|
||||
```js
|
||||
({ Point, Snippet, snippets, Path, paths, part }) => {
|
||||
|
||||
snippets.logo = new Snippet('logo', new Point(0,0))
|
||||
|
||||
// Prevent clipping
|
||||
paths.diag = new Path()
|
||||
.move(new Point(-25,-40))
|
||||
.move(new Point(25,15))
|
||||
|
||||
return part
|
||||
}
|
||||
```
|
||||
</Example>
|
||||
|
||||
## Methods
|
||||
|
||||
A Snippet object exposes the following methods:
|
||||
|
||||
<ReadMore list />
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue