Chapter 28. SVG
28
SVG
(Scalable Vector Graphics)
In this chapter
Shapes in SVG
Clipping and masking
Filter effects
Interactivity and animation
SVG tools
Production tips
How to scale SVGs
SVGs have made several guest appearances in this book, but in this chapter, they finally get to be the star.
When rendered in a browser window, an SVG may look like an image in any other format, but it’s what’s happening behind the scenes that makes it truly unique and versatile. First, as the name says, this is a vector format, meaning shapes within SVGs are defined by coordinates and lines, not grids of pixels. That’s what makes them scalable—they can resize infinitely without loss of quality.
Figure 28-1 shows the same tiger image saved as an SVG and a PNG. The SVG can scale very large without any change in quality. The lines and text stay sharp, regardless of whether the image is viewed at 100 pixels or 10,000 pixels—try doing that with a bitmap image! Now that our web pages and interfaces must work on devices of all scales, from smartphones to high-density monitors and large-screen televisions, the ability to create a single image that looks great in all contexts is an epic win.

The vector nature of SVG makes it a good choice for icons, logos, charts, and other line drawings (Figure 28-2). And because these ...
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.
Read now
Unlock full access