This project has moved and is read-only. For the latest updates, please go here.

Bounding Box computation

Topics: Animation and Interactivity, SVG
Jun 1, 2011 at 2:12 PM


 thank you for the quick eply converning dynamically updating the dom tree. We tried the idea to just modify it and then render it as a whoel - works like a charm. But now we tried to rotate some of the elements. Of course, for doing this we would need acces to information about the bounding box of the element so as to correctly compute the rotation center. Is it possible to get this kind of information?




Juergen Key

Jun 1, 2011 at 2:36 PM

>>Juergen: like a charm.

We will surely produce a better solution in later release.

>>Juergen: ...bounding box of the element so as to correctly compute the rotation center.

Naturally, due to the various transformations it might be subjected to, an element's bounding box cannot
be determine until it is rendered.
If this is required after a rendering, then assign ID to your elements and search for them in the rendered
DrawingGroup, and retrieve the bounding box.

Best regards,

Jun 8, 2011 at 10:09 AM

Hi paul - thanks for the quick reply. All my elements inside the SVG already have ids - i do my drawings with inkscape and this application provides ids for me. But could you nudge me one step further? i already had a faint suspicion that it might have something to do with the Drawing(Group) but i seem to be unable to figure out how to search inside it for any given Id.

Best regards,

Juergen Key

Jun 8, 2011 at 11:07 AM

Hello Juergen,

Please I will get back to you tomorrow. On Wednesdays, I do not use computers at home - sorry.

Best regards,

Jun 9, 2011 at 12:52 PM

Hello Juergen,

Sorry for the delay. Lets try...

You start from this method SvgDrawingCanvas.EnumerateDrawings.

It was used to enumerates the contents and identify the link, text object etc.
If you need to search the whole draw graph, that could be an example.
Also, if you are linking to the runtime library then you can search for a particular
SVG object type like image, text, polygon etc since that information is added to
the converted object, as also illustrated by that method.

Now, if you are using the converted DrawingGroup (ie the memory), then
the SVG object IDs are saved as x:Name property to the converted objects
so you can obtain them as

string id = aDrarwing.GetValue(FrameworkElement.NameProperty) as string

However, if you are using the converted file (ie you save to a file and load it later)
then that information will not be available to you since the framework does not load them.
In this case you will need to use the SvgImage, which is created for such cases.
Unfortunately, none of the current converters save to the SvgImage so you will have
to provide one - I could help if this is your requirement. 

Best regards,

Jun 29, 2011 at 1:55 PM

Thanks for your help. We were able to do exactly what we wanted. Now we have a native version of the code we first did in java.

Now we can use a SVG graphic as dynamic GUI. However, while testing - two isues popped up: some of the gradients did not seem to work and ther was an issue concerning whitespaces in attributes. i will file issues in the issetracker for them.


Regards,  Juergen Key

Jun 29, 2011 at 11:53 PM

>>JuergenHowever, while testing - two isues popped up:

Will be looking into that and others tonight, thanks for reporting it.

Best regard,