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

Problems with the ViewBox

From: Philip Mackie <Philip.Mackie@RCP.co.uk>
Date: Mon, 24 Mar 2003 14:42:14 -0000
Message-ID: <AEB073C179AC424CB102DF5EF17508A0019357DE@newlace.rcp.co.uk>
To: "'www-svg@w3.org'" <www-svg@w3.org>


I'm having some difficulty with SVG's viewbox. Take the following simple

<svg width="500px" height="500px" viewBox="0px 0px 500px 250px">
      <rect  x="0px" y="0px" width="500px" height="250px"/>

I would expect the rectangle to take up the entire 500x500 pixels viewport,
i.e. the rectangle had been stretched along the y-axis from 250 pixels to
500 pixels. 

However, what I see is a 500x250 pixel rectangle drawn, with the centre of
the rectangle at point 250,250, i.e. the image is symmetrical about the

What seems to be happening is that SVG, when presented with a rectangular
viewbox being put into a square viewport, takes the value of the longer
dimension of the viewbox defined (in this case 500 pixels), and adds an
equal number of pixels (in this case 125 pixels) above and below the
rectangle, to make the shorter dimension (250) of the viewport equal to the
longer dimension (500) i.e. make it square.

Is this correct? If so, is there a way to alter this behaviour?

Hope the above was clear - difficult to describe without diagrams!!

Any help greatly appreciated!

Received on Monday, 24 March 2003 09:49:27 UTC

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