PlottingSVG::SVGGlyphRenderer
PlottingSVG::SVGGlyphRenderer
Stateless conversion from [CorePlotting::RenderableGlyphBatch]() to SVG element strings. More…
#include <SVGGlyphRenderer.hpp>
Public Functions
| Name | |
|---|---|
| std::vector< std::string > | render(CorePlotting::RenderableGlyphBatch const & batch, glm::mat4 const & view, glm::mat4 const & projection, int canvas_width, int canvas_height) Convert one glyph batch to SVG fragments in canvas pixel space. |
Detailed Description
class PlottingSVG::SVGGlyphRenderer;Stateless conversion from [CorePlotting::RenderableGlyphBatch]() to SVG element strings.
Applies projection * view * batch.model_matrix per batch, maps vertices with [PlottingSVG::transformVertexToSVG](/api_generated/Namespaces/namespacePlottingSVG.md#function-transformvertextosvg), and emits one or two fragments per glyph depending on GlyphType (cross uses two <line> elements).
Public Functions Documentation
function render
static std::vector< std::string > render(
CorePlotting::RenderableGlyphBatch const & batch,
glm::mat4 const & view,
glm::mat4 const & projection,
int canvas_width,
int canvas_height
)Convert one glyph batch to SVG fragments in canvas pixel space.
Parameters:
batch Glyph instances:
positionsin world space; optional parallelcolors(per-glyph RGBA whencolors.size() > i, otherwise white).batch.sizehas different coordinate-space semantics per glyph type:Tick / Square / Cross: world-space units. Corners/endpoints are computed at
pos ± size/2(in X and/or Y), then transformed through the MVP to canvas pixels.Circle: screen pixels. The radius
size / 2is emitted directly in the<circle r="...">attribute (no MVP transform on size).- 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.glyph_typemust beTick,Circle,Square, orCross. Other values are not handled by theswitchand produce an empty fragment for that glyph (enforcement: none) [IMPORTANT]canvas_width > 0andcanvas_height > 0if output should match the same NDC→pixel mapping as live OpenGL rendering (enforcement: none) [IMPORTANT]batch.positions[i]and the MVP should yield finite NDC after transform for on-canvas coordinates (enforcement: none) [LOW]- If
batch.colorsis non-empty, only indicesi < batch.colors.size()read per-glyph color; shortercolorsis allowed (remaining glyphs use opaque white) (enforcement: none) [LOW]
Postcondition:
- Returns an empty vector when
batch.positionsis empty. - Otherwise returns one
<line>,<circle>, or<rect>string per glyph forTick,Circle, andSquare, and two<line>strings per glyph forCross(so the vector length can exceedbatch.positions.size()). - Output strings use
[colorToSVGHex](/api_generated/Namespaces/namespacePlottingSVG.md#function-colortosvghex)for stroke/fill color and separate opacity attributes where applicable. - Does not throw under normal
std::string/ostringstreambehavior.
Updated on 2026-11-13 at 20:25:41 +0000