Problems with the ViewBox

Hi, 

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

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

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
x-axis. 

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!

Phil

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