PlottingSVG::SVGPolyLineRenderer
PlottingSVG::SVGPolyLineRenderer
Stateless conversion from [CorePlotting::RenderablePolyLineBatch]() to SVG <polyline> strings. More…
#include <SVGPolyLineRenderer.hpp>
Public Functions
| Name | |
|---|---|
| std::vector< std::string > | render(CorePlotting::RenderablePolyLineBatch const & batch, glm::mat4 const & view, glm::mat4 const & projection, int canvas_width, int canvas_height) Convert one polyline batch to SVG fragments in canvas pixel space. |
Detailed Description
class PlottingSVG::SVGPolyLineRenderer;Stateless conversion from [CorePlotting::RenderablePolyLineBatch]() to SVG <polyline> strings.
Applies projection * view * batch.model_matrix, maps each vertex with [transformVertexToSVG](/api_generated/Namespaces/namespacePlottingSVG.md#function-transformvertextosvg), and emits one fragment per logical line (subject to vertex_count and buffer bounds). Stroke color uses [colorToSVGHex](/api_generated/Namespaces/namespacePlottingSVG.md#function-colortosvghex) (RGB only; alpha is not written to SVG attributes).
Public Functions Documentation
function render
static std::vector< std::string > render(
CorePlotting::RenderablePolyLineBatch const & batch,
glm::mat4 const & view,
glm::mat4 const & projection,
int canvas_width,
int canvas_height
)Convert one polyline batch to SVG fragments in canvas pixel space.
Parameters:
- batch Flat
verticesasx,ypairs in world space;line_start_indicesandline_vertex_countsdescribe each polyline within that buffer. - view Shared view matrix (same convention as OpenGL rendering).
- projection Shared projection matrix.
- canvas_width Target SVG width in pixels.
- canvas_height Target SVG height in pixels.
Precondition:
batch.line_start_indices.size()must equalbatch.line_vertex_counts.size(). The implementation indexes both byline_idxwithout a length guard (enforcement: none) [CRITICAL]- For each line
i,batch.line_start_indices[i] >= 0, and the vertex pairs[start_index + k]fork in [0, vertex_count)must lie withinbatch.verticeswhenvertex_count >= 2(each vertex uses two floats). If the buffer is too short, the inner loop stops early and a<polyline>may be emitted with fewer thanvertex_countpoints, or with an emptypointsattribute (enforcement: none) [IMPORTANT] canvas_width > 0andcanvas_height > 0if output should match the same NDC→pixel mapping as live OpenGL rendering (enforcement: none) [IMPORTANT]- If
batch.colorsis non-empty, only indicesline_idx < batch.colors.size()read a per-line color; otherwisebatch.global_coloris used (enforcement: none) [LOW]
Postcondition:
- Returns an empty vector when
batch.verticesis empty orbatch.line_start_indicesis empty. - Otherwise emits at most one
<polyline fill="none" stroke="…" …/>string per line index; lines withline_vertex_counts[line_idx] < 2are skipped (no string for that line). - Stroke uses
batch.thickness,stroke-linejoin="round", andstroke-linecap="round". - Does not throw under normal
std::string/ostringstreambehavior.
Updated on 2026-11-13 at 20:25:41 +0000