Re: Automatic centering and positioning

Hello,

I think, there was already a similar discussion - maybe without a result, I 
did not search for it.

The main task, I can see, is to find the center of an arbitrary path or even
worse the center of a text string using a generic font-family, the author has
no detailled control about.
Already now one has the text-anchor for the local horizontal direction, but
the vertical one is missing. But if a text element has several positioned 
tspan elements or positioned glyphs, or textPath is used, one has to find 
the center anyway with another approach.
What can be expected, if the objects are animated, changing coordinate
system and shape?

To get in general a meaningful result, one might have to calculate the
balance points of the two objects, intended to be centered to each other.
This will require in general a numerical integration along the paths.
As for constrained transformations one might get in trouble with a naive 
implementation of transformations and the possibly not existing inverse
of them.

Using just the boundingBox can be simpler, but this does not necessarily
result in something, that can be called the center of an object.
But it can be a reasonable simplification for some use cases not the 
center the objects, but only the boundingBoxes of those objects.
However, not all objects have a boundingBox, but all have some kind
of center.

Once one has such a center or boundingBox center, it is mainly a 
specific translation one has to apply - but this requires careful 
considerations to be backwards compatible to current transform notations.
And if objects are animated, the results can be quite surprising and complex,
if this is used together with such a centering feature.


Olaf

Received on Friday, 8 November 2013 10:32:02 UTC