<defs> ... <g width="30" height="10" id="schottky"> <path style="fill:none;stroke:black;stroke-width:1" d="M0.5,5.5 h10 v-5 l10,5 l-10,5 v-5 m7,-4 v-2 h3 v12 h3 v-2 m-3,-4 h10" /> </g> ... </defs>
<defs> ... <g width="30" height="10" id="resistor"> <path transform="translate(1,0) rotate(90,15,5)" style="fill:none;stroke:black;stroke-width:1" d="M0.5,5.5 h3 l2,-3 l4,6 l4,-6 l4,6 l4,-6 l4,6 l2,-3 h3" /> </g> ... </defs>
translate
, rotate
, scale
, etc.).defs
tag, and therefore are not yet displayed. Each element definition must have a unique id
, which will be required in the next step.use
tag to draw an element and one or more text
tags for signatures. ... <g transform="translate(115,45)"><use xlink:href="#resistor"/><text x="20" font-size="10">R1</text><text x="20" y="10" font-size="8">470k</text></g> ...
path
tag, which makes it easy to draw horizontal and vertical lines.M10,5
- start drawing from point 10.5h10
- horizontal line, 10 pixels to the rightm30,0
- jump 30 pixels to the rightv15
- vertical line, 15 pixels downm0,30
- jump 30 pixels downl-5,-10
- oblique line, 5 pixels left and 10 pixels up <svg width="100" height="100" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <!-- --> <defs> <circle x="0.5" y="0.5" r="1.5" style="fill:blue;stroke:blue;" id="junction"/> <g width="30" height="10" id="connector"> <path style="fill:none;stroke:black;stroke-width:1" d="M10.5,5.5 a3,3,0,0,1,-6,0 a3,3,0,0,1,6,0 h20" /> </g> <g width="30" height="10" id="resistor"> <path transform="translate(1,0) rotate(90,15,5)" style="fill:none;stroke:black;stroke-width:1" d="M0.5,5.5 h3 l2,-3 l4,6 l4,-6 l4,6 l4,-6 l4,6 l2,-3 h3" /> </g> </defs> <!-- --> <g transform="translate(5, 10)"><use xlink:href="#connector"/><text x="20" font-size="10">+</text> </g> <g transform="translate(25,40)"><use xlink:href="#resistor"/> <text x="-5" y="10" font-size="10">R1</text></g> <g transform="translate(5, 70)"><use xlink:href="#connector"/><text x="20" font-size="10">-</text> </g> <!-- --> <path d="M35.5,15.5 h5 v15 m0,30 v15 h-5" stroke="red" fill="none"/> <path d="M40.5,15.5 h25 v60 h-25" stroke="red" fill="none"/> <!-- --> <use xlink:href="#junction" transform="translate(40,15)"/> <use xlink:href="#junction" transform="translate(40,75)"/> <!-- --> <text x="50" y="88" width="100" text-anchor="middle" font-family="cursive" font-size="10"></text> <text x="50" y="98" width="100" text-anchor="middle" font-family="monospace" font-size="10"></text> </svg>
<svg width="200" height="150" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <desc>Step-up DC-DC converter</desc> <defs> <circle x="0.5" y="0.5" r="1.5" style="fill:blue;stroke:blue;" id="junction"/> <g width="30" height="10" id="connector"> <path style="fill:none;stroke:black;stroke-width:1" d="M10.5,5.5 a3,3,0,0,1,-6,0 a3,3,0,0,1,6,0 h20" /> </g> <g width="30" height="10" id="connector180"> <path transform="translate(1,1) rotate(180,15,5)" style="fill:none;stroke:black;stroke-width:1" d="M10.5,5.5 a3,3,0,0,1,-6,0 a3,3,0,0,1,6,0 h20" /> </g> <g width="30" height="10" id="resistor"> <path transform="translate(1,0) rotate(90,15,5)" style="fill:none;stroke:black;stroke-width:1" d="M0.5,5.5 h3 l2,-3 l4,6 l4,-6 l4,6 l4,-6 l4,6 l2,-3 h3" /> </g> <g width="30" height="10" id="capacitor"> <path transform="translate(1,0) rotate(90,15,5)" style="fill:none;stroke:black;stroke-width:1" d="M0.5,5.5 h13 m0,-7 v14 m4,0 v-14 m0,7 h13" /> </g> <g width="30" height="10" id="inductance"> <path style="fill:none;stroke:black;stroke-width:1" d="M0.5,5.5 h0.7 a5,10,0,0,1,9.3,5 a5,10,0,0,1,10,0 a5,10,0,0,1,9.3,-5 h0.7" /> </g> <g width="30" height="10" id="schottky"> <path style="fill:none;stroke:black;stroke-width:1" d="M0.5,5.5 h10 v-5 l10,5 l-10,5 v-5 m7,-4 v-2 h3 v12 h3 v-2 m-3,-4 h10" /> </g> <g width="40" height="40" id="stepup"> <rect x="0.5" y="0.5" width="40" height="40" style="fill:none;stroke:black;stroke-width:1px;"/> <text x="2" y="10" font-size="8">VIN</text> <text x="2" y="37" font-size="8">GND</text> <text x="25" y="10" font-size="8">SW</text> <text x="27" y="37" font-size="8">FB</text> </g> </defs> <g transform="translate(0,15)"><use xlink:href="#connector"/><text x="5" y="-5" font-size="10">+Vin</text></g> <g transform="translate(0,135)"><use xlink:href="#connector"/><text x="5" y="-5" font-size="10">Gnd</text></g> <g transform="translate(160,15)"><use xlink:href="#connector180"/><text y="-5" font-size="10">+Vout</text></g> <g transform="translate(160,135)"><use xlink:href="#connector180"/><text y="-5" font-size="10">Gnd</text></g> <g transform="translate(65,50)"><use xlink:href="#stepup"/><text y="55" font-size="10">SX1308</text></g> <g transform="translate(115,45)"><use xlink:href="#resistor"/><text x="20" font-size="10">R1</text></g> <g transform="translate(115,110)"><use xlink:href="#resistor"/><text x="20" font-size="10">R2</text></g> <g transform="translate(20,75)"><use xlink:href="#capacitor"/><text x="20" font-size="10">C1</text></g> <g transform="translate(140,75)"><use xlink:href="#capacitor"/><text x="20" font-size="10">C2</text></g> <g transform="translate(50,15)"><use xlink:href="#inductance"/><text x="10" y="-5" font-size="10">L1</text></g> <g transform="translate(95,15)"><use xlink:href="#schottky"/><text x="10" y="-5" font-size="10">D1</text></g> <path d="M30.5,20.5 h20 m30,0 h15 m30,0 h35" stroke="red" fill="none"/> <path d="M35.5,20.5 v45 m0,30 v45" stroke="red" fill="none"/> <path d="M130.5,20.5 v15 m0,30 v35 m0,30 v10" stroke="red" fill="none"/> <path d="M155.5,20.5 v45 m0,30 v45" stroke="red" fill="none"/> <path d="M45.5,20.5 v35 h20" stroke="red" fill="none"/> <path d="M50.5,140.5 v-55 h15" stroke="red" fill="none"/> <path d="M90.5,20.5 v20 h25 v15 h-10" stroke="red" fill="none"/> <path d="M105.5,85.5 h25" stroke="red" fill="none"/> <path d="M30.5,140.5 h130" stroke="red" fill="none"/> <use xlink:href="#junction" transform="translate(35,20)"/> <use xlink:href="#junction" transform="translate(45,20)"/> <use xlink:href="#junction" transform="translate(90,20)"/> <use xlink:href="#junction" transform="translate(130,20)"/> <use xlink:href="#junction" transform="translate(155,20)"/> <use xlink:href="#junction" transform="translate(130,85)"/> <use xlink:href="#junction" transform="translate(35,140)"/> <use xlink:href="#junction" transform="translate(50,140)"/> <use xlink:href="#junction" transform="translate(130,140)"/> <use xlink:href="#junction" transform="translate(155,140)"/> </svg>
translate(0.5,0.5)
.circle
tag or with the a
command (from Arc - arc) of the path
tag. If there is a choice, use circle
.path
tag. This requires two successive arcs: ... a3,3,0,0,1,-6,0 a3,3,0,0,1,6,0 ...
, where 3
is the radius of the circle, and 6
is its diameter.<use xlink:href="#connector"/>
, <use xlink:href="library.svg#connector"/>
.object
tag <object data="image.svg" type="image/svg+xml"></object>
image
tag works no worse than the object
tag <img src="image.svg"/> <object data="image.svg" type="image/svg+xml"></object>
Source: https://habr.com/ru/post/320504/
All Articles