Hi,
if all your shapes are included in a g element, you can use the getBBox method
on this node to get the dimensions.
In your example :
document.getElementById('G2').getBBox()
Yannick
----- Mail original -----
De: "Alireza" <[email protected]>
À: [email protected]
Envoyé: Jeudi 5 Avril 2012 10:19:19
Objet: [svg-developers] showing full svg content whithout calculating extents
Hello
I need help for finding extents of an svg drawing. Please take a look at this
example:
<svg id="SVG1" width="5cm" height="5cm" viewBox="0 -100 200 200">
<g id="G2">
<line x1="0" y1="0" x2="100" y2="100" stroke="blue"/>
<line x1="0" y1="0" x2="0" y2="100" stroke="blue"/>
<line x1="0" y1="0" x2="100" y2="0" stroke="blue"/>
<line x1="0" y1="0" x2="100" y2="-100" stroke="blue"/>
</g>
</svg>
For this sample it was easy to understand that viewBox="0 -100 200 200" will
fit the whole drawing. But in my real world application this will not be so
easy to calculate this. And without this viewbox or with incorrect
calculations, at least a part of drawing will not be shown which is not
desirable.
I want to show the whole drawing in svg without getting involved in calculating
the extents. Something like zoom extents in aoutocad. could you please help?
Thanks
------------------------------------
-----
To unsubscribe send a message to: [email protected]
-or-
visit http://groups.yahoo.com/group/svg-developers and click "edit my
membership"
----Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/svg-developers/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/svg-developers/join
(Yahoo! ID required)
<*> To change settings via email:
[email protected]
[email protected]
<*> To unsubscribe from this group, send an email to:
[email protected]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/