Skip to Content
Mastering SVG
book

Mastering SVG

by Rob Larsen
September 2018
Beginner to intermediate
312 pages
7h 22m
English
Packt Publishing
Content preview from Mastering SVG

Snap.svg utilities

This example will illustrate a couple of useful Snap utilities available for working with SVG. The whole purpose of working with a general-purpose library like Snap is to use utility methods such as the following. This example shows just two such utilities, but this should be enough to show you the sort of things that are available.  

The beginning of the example is standard Snap.svg development. You start by getting a reference to the #target element. We create a Snap variable, S, and then append it to the #target element. 

Once it's in the document, we can use the first of two utilities. It's a single line assignment to the variable bbox, which returns the bounding box of an SVG element, in this case, a circle.

A bounding ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Modern SVG

Modern SVG

Amelia Bellamy-Royds, Kurt Cagle
Using SVG with CSS3 and HTML5

Using SVG with CSS3 and HTML5

Amelia Bellamy-Royds, Kurt Cagle, Dudley Storey
SVG Text Layout

SVG Text Layout

Amelia Bellamy-Royds, Kurt Cagle

Publisher Resources

ISBN: 9781788626743Supplemental Content