Snippet
A Snippet is a reusable bit of markup for your pattern. Snippets are added to the
SVG defs section, and rendered with the SVG use tag.
Signature
Snippet new Snippet(String def, Point anchor);
The snippet constructor takes two arguments:
def: Thexlink:hrefid that links to the relevant entry in the SVGdefssection. This is also the common name of the snippet (logo,notch,button, etc.)anchor: APointon which to anchor the snippet
Properties
A Snippet object comes with the following properties:
def: Thexlink:hrefid that links to the relevant entry in the SVGdefssectionanchor: APointon which to anchor the snippetattributes: AnAttributesinstance holding the snippet's attributes
RELATED
See Using Attributes for information about custom Attributes that can be used with Snippets.
Example
- Preview
- Code
- X-Ray
({ 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 of the Snippet constructor
Methods
A Snippet object exposes the following methods: