At Wed, 22 Feb 2023 15:24:42 -0500 saitology9 <
[email protected]> wrote:
On 2/22/2023 11:27 AM, Robert Heller wrote:
SVG files are just XML (text) files. Load one of the XML libraries and read/parse the XML (I have a nifty SNIT class for that in my ModelRRSystem: https://github.com/RobertPHeller/ModelRRSystem/blob/master/trunk/Scripts/Common/ParseXML.tcl).
In the <svg> tag are attributes for image size and coordinate space in use --
width, height, and viewBox.
Thank you. The width/height seem to be optional as some svg files don't
have them. I am not sure about the viewbox property.
The width/height propertiesare sometimes used to specific a *physical* size
(in inches or millimeters, etc.). The viewBox property can be used to specific the coordinate bounding box, and thus the mapping of the coordinates in the body of the file to "screen" (or paper or whatever) coordinates.
For example this Fritzing breadboard image:
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: FritzingPartsSVGEditor 0.0.2 on x86_64-unknown-linux-gnu (BreadboardEditor) -->
<svg viewBox="0.000000 0.000000 47.565543 33.295880" width="4.756554mm" x="0mm" height="3.329588mm" y="0mm" version="1.1" xml:space="preserve">
<g id="breadboard">
<circle fpe:gid="1" cx="17.266292134831453" cy="16.647940074906355" r="16.0" fill="none" stroke="black" stroke-width="2.0"/>
<circle fpe:gid="2" id="connector1pin" cx="17.266292134831453" cy="16.64794007490637" r="4.999999999999999" fill="black"/>
<circle fpe:gid="3" id="connector2pin" cx="42.66629213483144" cy="16.64794007490637" r="4.9999999999999964" fill="black"/>
</g>
</svg>
defines a part that is "physically" 4.756554mm by 3.329588mm, with the coordinates in tenths of a mm.
Wouldn't a regexp be a better solution here?
--
Robert Heller -- Cell: 413-658-7953 GV: 978-633-5364
Deepwoods Software -- Custom Software Services
http://www.deepsoft.com/ -- Linux Administration Services
[email protected] -- Webhosting Services
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)