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

Clipping

The clipPath element in SVG allows you to cut a shape out of another shape. Clipping uses the geometry of the shape to define the area that's cut out. It doesn't take into account anything other than the shape, so attributes such as stroke and fill don't change the area being cut out.

The following code sample shows a very simple, but very useful, pattern for using the clipPath element. The basic effect is to cut out one half of a complicated element (the star we drew in Chapter 2, Getting Started with Authoring SVG) in order to lay it on top of another instance of that same star creating a bisected star design in red and black. While you could create two halves of the star and place them next to each other, mixing and matching instances ...

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