Overview
SvgBackend renders a Scene to an SVG string. This backend is always available and has no feature flag requirements. It produces vector output that can be scaled without quality loss.
Usage
Methods
render_scene
Renders a Scene to an SVG string.
The scene to render
String - Complete SVG document with XML declaration
Example:
Output Format
The SVG output includes:- XML namespace declaration
- Width and height attributes from scene dimensions
- Optional background rectangle if
scene.background_coloris set - SVG defs for gradients (used by Sankey plots)
- All scene primitives converted to SVG elements
Performance
SVG generation pre-allocates string capacity (~80 bytes per primitive) to minimize reallocations during rendering.Source
src/backend/svg.rs