'How to get(Clipped)BoundingClientRect?

I'm making a tooltip lib. It uses a styled <div>. The red colored one. It was transformed 45 degree and clipped off.

enter image description here

I need a dynamic calculation of height for the clipped-red one above. In this case the height is exactly getBoundingClientRect().height / 2, the built in function is transformed aware but not clipped aware. The clip-path property is might be customized, so we cannot just simply dividing the height by 2.

I need a custom js function something like: getClippedBoundingClientRect()



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source