SVG Renderer¶
SVG rendering engine for converting diagrams to SVG files.
render_svg ¶
SVG rendering for GPIO diagrams.
SVGRenderer ¶
Render GPIO wiring diagrams to SVG format.
Converts a Diagram object into a scalable SVG image showing the Raspberry Pi board, connected devices, wire connections, and optional GPIO reference diagram.
The renderer handles
- Board SVG asset embedding
- Device box rendering with labeled pins
- Wire routing with rounded corners
- Inline component symbols (resistors, capacitors, diodes)
- GPIO pin numbering and color coding
- Optional GPIO reference diagram
- Automatic layout via LayoutEngine
Examples:
>>> from pinviz import boards, devices, Connection, Diagram, SVGRenderer
>>>
>>> diagram = Diagram(
... title="LED Circuit",
... board=boards.raspberry_pi_5(),
... devices=[devices.led()],
... connections=[
... Connection(11, "LED", "Anode"),
... Connection(6, "LED", "Cathode")
... ]
... )
>>>
>>> renderer = SVGRenderer()
>>> renderer.render(diagram, "led_circuit.svg")
Initialize SVG renderer with optional layout configuration.
| PARAMETER | DESCRIPTION |
|---|---|
layout_config
|
Layout configuration for spacing and margins. If None, uses default LayoutConfig.
TYPE:
|
Source code in src/pinviz/render_svg.py
render ¶
Render a diagram to an SVG file.
| PARAMETER | DESCRIPTION |
|---|---|
diagram
|
The diagram to render
TYPE:
|
output_path
|
Output file path
TYPE:
|
Source code in src/pinviz/render_svg.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 | |
render_to_string ¶
Render a diagram to an SVG string.
| PARAMETER | DESCRIPTION |
|---|---|
diagram
|
The diagram to render
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
SVG content as string |