Working example with <circle>
<svg viewBox="-20 -20 150 150" xmlns="http://www.w3.org/2000/svg"> <clipPath id="myClip" clipPathUnits="objectBoundingBox"> <circle cx=".5" cy=".5" r=".5" /> </clipPath> <rect x="0" width="100" height="100" rx="15" clip-path="url(#myClip)" /> </svg>
Same but using <line>
- does not work
<svg viewBox="-20 -20 150 150" xmlns="http://www.w3.org/2000/svg"> <clipPath id="myClip" clipPathUnits="objectBoundingBox"> <line x1="0" y1="0" x2="1" y2="1" /> </clipPath> <rect x="0" width="100" height="100" rx="15" clip-path="url(#myClip)" /> </svg>
I expected to see part of the square, but nothing is shown
It seems that
cannot be used in
An alternative to
clippath could be
<mask>
. The advantage is that any SVG element can be used for "drawing".