Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting a "display" bounding box for a clipped object

Tags:

svg

I need to find the visible x and y bounds of an object which has been clipped, so that I can place other objects around it. However, the spec states that getBBox doesn't take into account clip paths, so I can't use the bounding box. Any idea how can I can find the display limits for a clipped object?

like image 349
EML Avatar asked May 03 '12 11:05

EML


1 Answers

Create a hidden <use> element that references the path in the clipPath and get the bounding box of that. Then you just want the intersection of the bounding box of your object and the use object.

<defs>
  <clipPath id="clipPath">
    <path id="path" ...>
  </clipPath>
</defs>

<use id="clipPathBounds" visibility="hidden" xlink:href="#path"/>
like image 184
Robert Longson Avatar answered Oct 03 '22 10:10

Robert Longson