W3C home > Mailing lists > Public > www-svg@w3.org > September 2003

Bounding Box Calculation

From: Gavin Kistner <gavin@refinery.com>
Date: Tue, 30 Sep 2003 09:05:37 -0600
Cc: svg-developers@yahoogroups.com
To: www-svg@w3.org
Message-Id: <8C49B67B-F357-11D7-B4C3-0003937E984E@refinery.com>

Using ASV3, I noticed that:
	<svg
		width="800" height="600"
		viewBox="0 0 800 600"
		style="overflow:hidden"
		onresize="alert(document.documentElement.getBBox().width)">
			<rect x="-100" y="-100" width="1200" height="1200">
	</svg>
results in '1200' and not '800' being alerted.

The SVG 1.1 specs don't seem to explicitly cover how to compute the 
bounding box depending on the value of the overflow style, but they 
generally indicate a simple calculation method which could be 
interpreted to exclude this property.

	"The bounding box is computed exclusive of any values for clipping, 
masking,
	filter effects, opacity and stroke-width."
	- http://www.w3.org/TR/SVG11/coords.html#ObjectBoundingBox

It is my (rather strong) opinion that such a calculation technique, 
while convenient for the UA developers, makes the bounding box rather 
pointless. Using:
	overflow:visible
should include child elements who stray outside the viewBox in the 
bounding box calculations, but
	overflow:hidden
should not. Similarly, if I have
	<g><circle ... r="10" style="stroke-width:200"/></g>
then the bounding box width is '220' IMO. Handing me '20' is of little 
use.



The SVG 1.2 draft mentions the possibility of such an improvement:

	"In order to provide greater flexibility and expressive power, it 
might make sense
	to simultaneously add new utility methods in the SVG DOM, such as 
improvements
	in area of geometry queries (e.g., bounding box queries that take into 
account things
	such as stroke widths and filter effects)."
	- http://www.w3.org/TR/SVG12/#rcc-uiwidgets

and I would heartily encourage the changing of the word 'might' to 
'definitely'. :)

If you don't want to break existing 1.1 scripts, then perhaps the 
addition of
	SVGLocatable.getExtendedBBox()
might be in order.
--
Gavin Kistner @ Refinery, Inc.
gavin@refinery.com
work: +1.303.444.1777
cell: +1.303.641.1521
Received on Tuesday, 30 September 2003 11:13:35 GMT

This archive was generated by hypermail 2.3.1 : Friday, 8 March 2013 15:54:25 GMT