ISSUE-2283 (bbox-coord-system): Make it possible to get the bounding box of an element in a particular coordinate system [SVG Core 2.0]

ISSUE-2283 (bbox-coord-system): Make it possible to get the bounding box of an element in a particular coordinate system [SVG Core 2.0]

http://www.w3.org/Graphics/SVG/WG/track/issues/2283

Raised by: Cameron McCormack
On product: SVG Core 2.0

Sometimes you want to get the bounding box of an element in one of its ancestors' coordinate system.  For example:

  <g id="A" transform="...">
    <g transform="...">
      <path id="P" d="..."/>
    </g>
  </g>

Say if you want to click on the <path> and create a <rect> as a child of g#A that is shows the bounding box of the <path>.  You need to:

  * do bbox = P.getBBox()
  * Construct SVGPoint objects for each of the four corners of bbox
  * do m = P.getTransformToElement(A)
  * Transform each of the four SVGPoints with m
  * Compute the bounding box of these four points (a bunch of Math.min() and
    Math.max() calls)
  * Create the <rect> and set its x/y/width/height based on this computed bbox

It might be handy to be able to get the bounding box of an element in a particular element's coordinate system (possibly only an ancestor element?), possibly by supplying an SVGLocatable argument to getBBox().

Received on Friday, 19 June 2009 05:49:24 UTC