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
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 |