tags:

views:

346

answers:

1

I'm developing a program that generates svg files based on choices the user makes. One of these choises is to include another svg file centered on a specific point in the first one. The second file has an unknown aspect ratio and size, but it should be scaled to a specific max size either as height or width, and should be centered on one specific point. The method I use now is to have a G tag that contains the SVG tag of the included image, and perform a transform on the G tag to scale and translate. Is there any way to perform the scale to get a specific size without knowning the size of the image? And is there any way to have the translated coordinates to apply to the center of the image instead of the upper left corner? I am very new to SVG, so it might be that I'm going about this the wrong way. Is there perhaps a better way to get the same results?

A: 

I guess you want to first have the other SVG file hidden, call getBBox in JavaScript ( see svg_SVGLocatable_getBBox">http://www.w3.org/TR/SVG/types.html#_svg_SVGLocatable_getBBox ) do some simple calculations, set the appropriate parameters, unhide it

stelt