|
I need to extend the paper or the "background" of the SVG. The only way I know how to do this is with the following command: svg_root.set('height', 150) If you do this, it also resizes all shapes inside of the SVG. I want it to resize without resizing the shapes it contains, so only the "background". Ps: I am not sure if this is the right way to ask a question. If it is not, please correct me. |
Replies: 1 comment 1 reply
|
I don't believe it's actually resizing all the shapes, just your view of them. As confirmation, I created a 1000×1000 canvas and centered a 500×500 rectangle within it. In the SVG file I see <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
width="1000"
height="1000"
id="svg2"
version="1.1"
inkscape:version="1.1.2 (0a00cf5339, 2022-02-04)"
sodipodi:docname="junk.svg"
viewBox="0 0 1000 1000"and later, <rect
style="fill:#5500d4;stroke:#000000;stroke-width:2;stop-color:#000000"
id="rect416"
width="500"
height="500"
x="250"
y="250" />After executing svg_root.set('height', 150)
svg_root.set('width', 150)with Simple Inkscape Scripting, the <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
viewBox="0 0 1000 1000"
sodipodi:docname="junk.svg"
inkscape:version="1.1.2 (0a00cf5339, 2022-02-04)"
version="1.1"
id="svg2"
height="150"
width="150"the rectangle remains the same size: <rect
style="fill:#5500d4;stroke:#000000;stroke-width:2;stop-color:#000000"
id="rect416"
width="500"
height="500"
x="250"
y="250" />This suggests that you need to alter the SVG view box in addition to the width and height. I believe that svg_root.set('height', 150)
svg_root.set('width', 150)
svg_root.set('viewBox', "0 0 150 150")will do what you want.
This is fine for now but suggests that I ought to enable GitHub Discussions to support future usage questions. |
I don't believe it's actually resizing all the shapes, just your view of them. As confirmation, I created a 1000×1000 canvas and centered a 500×500 rectangle within it. In the SVG file I see
and later,
After executing
with Simple…