Re: Bounding box of a group with a transformed child

On May 27, 2014, at 7:33 AM, Gavin Kistner <phrogz@me.com> wrote:
> On May 27, 2014, at 6:37 AM, Dr. Olaf Hoffmann <Dr.O.Hoffmann@gmx.de> wrote:
>> Paul LeBeau:
>> If one has a good algorithm to determine the boundingBox of an object
>> without transformation, the extension to get it right for transformed objects
>> should be a solvable problem (because one only has to transform all points 
>> and control points of the equivalent paths of the objects and analyse this 
>> instead).
> 
> You can bake the transforms into the path commands, and then calculate the BBox of those.
> I got this mostly working ~3 years ago:
> http://stackoverflow.com/questions/5149301/baking-transforms-into-svg-path-element-commands
> 
> You could then transform all path commands to absolute to make the bbox calc simpler:
> http://phrogz.net/convert-svg-path-to-all-absolute-commands
> 
> 
>> Obviously this is more difficult for the stroke of an object.
> 
> Correct. Nothing I’ve said above helps with the stroke.


Perhaps far simpler, if less precise, would be to simply rasterize the path (with or without stroke) to an offscreen buffer and then calculate the bounding box based on the pixels affected.

http://stackoverflow.com/questions/9852159/calculate-bounding-box-of-arbitrary-pixel-based-drawing

Received on Tuesday, 27 May 2014 13:37:13 UTC