W3C home > Mailing lists > Public > public-svg-wg@w3.org > April to June 2009

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]

From: SVG Working Group Issue Tracker <sysbot+tracker@w3.org>
Date: Fri, 19 Jun 2009 05:49:16 +0000 (GMT)
To: public-svg-wg@w3.org
Message-Id: <20090619054916.E60316B646@tibor.w3.org>

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 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 19 June 2009 05:49:26 GMT