Reputation: 10280
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?
Upvotes: 9
Views: 1647
Reputation: 124199
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"/>
Upvotes: 8