Reputation: 3607
I have some svg elements and I want their height and width in terms of pixels. how to do this?
<rect height="200" width="400" fill="red" stroke="1">
Upvotes: 3
Views: 2259
Reputation: 1740
Measurements in vector formats are generally relative to the size that the 'window' or 'viewer' that they are going to eventually be rendered in. Without knowing the viewports size in pixels, they are infinitely large or small. If you do have the viweports size and the element isnt being transformed by anything, then you'd need to see where the element is in relation to the viewport, ensure its fully displayed, and then you could calculate its rendered size. However, beware if its being clipped out of the diplay by being partially or fully 'off screen'.
Upvotes: 1