I am generating an SVG image in python. This part of the code works fine and uses a viewbox to position the main image in the right place.
My problem comes because I want to add a background colour. I am adding a rectangle after the main image creation and I want to position it to cover the whole image (I dont care about overflow). The obvious thing to do would be to position it at the origin but I can't work out why the x axis is at zero and the y axis is off by quite a long way. How can I position the rectangle at the origin regardless of what the viewbox might specify?
This code gives the image below:
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" height="2600px" version="1.1" viewBox="0 0 576 432" width="1600px">
<rect fill="#FF5B00" height="1184" stroke="#000000" width="768" x="0" y="0"/>
white box is the canvas, orange box is the background rectangle I am trying to add. I have removed the main image from this example as its not relevant to this problem
Figured it out. Its simply because the aspect ratio has changed and so the viewbox cant fill the full y axis. The following code fixed it
preserveAspectRatio = "xMinYMin meet"