W3C home > Mailing lists > Public > www-svg@w3.org > May 2014

Re: Bounding box of a group with a transformed child

From: Gavin Kistner <phrogz@me.com>
Date: Tue, 27 May 2014 07:36:18 -0600
Cc: www-svg@w3.org
Message-id: <97F1DFB2-9298-4F94-A9B3-2B7D7B51BFC0@me.com>
To: "Dr. Olaf Hoffmann" <Dr.O.Hoffmann@gmx.de>
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

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 22:54:53 UTC