Getting the bounding box "display" for the cropped object

I need to find the visible borders x and y of the object that was cropped so that I can place other objects around it. However, spec states that getBBox does not account for clip paths, so I cannot use a bounding box. Any idea how I can find the display limits for the cropped object?

+6
source share
1 answer

Create a hidden <use> element that refers to the path in the clip and gets a bounding box. Then you just need to intersect the bounding box of your object and the object of use.

 <defs> <clipPath id="clipPath"> <path id="path" ...> </clipPath> </defs> <use id="clipPathBounds" visibility="hidden" xlink:href="#path"/> 
+7
source

Source: https://habr.com/ru/post/914799/


All Articles