Skip to main content

PlottingSVG::SVGRectangleRenderer

PlottingSVG::SVGRectangleRenderer

Stateless conversion from [CorePlotting::RenderableRectangleBatch]() to SVG <rect> strings. More…

#include <SVGRectangleRenderer.hpp>

Public Functions

Name
std::vector< std::string > render(CorePlotting::RenderableRectangleBatch const & batch, glm::mat4 const & view, glm::mat4 const & projection, int canvas_width, int canvas_height)
Convert one rectangle batch to SVG fragments in canvas pixel space.

Detailed Description

class PlottingSVG::SVGRectangleRenderer;

Stateless conversion from [CorePlotting::RenderableRectangleBatch]() to SVG <rect> strings.

Each bounds[i] is (x, y, width, height) in world space (same packing as the GL path). Corners are transformed with [transformVertexToSVG](/api_generated/Namespaces/namespacePlottingSVG.md#function-transformvertextosvg); SVG x/y/width/height use min and abs so negative width or height still yield a non-negative axis-aligned box. entity_ids and selection_flags on the batch are not consulted here (no stroke or highlight pass in SVG).

Public Functions Documentation

function render

static std::vector< std::string > render(
    CorePlotting::RenderableRectangleBatch const & batch,
    glm::mat4 const & view,
    glm::mat4 const & projection,
    int canvas_width,
    int canvas_height
)

Convert one rectangle batch to SVG fragments in canvas pixel space.

Parameters:

  • batch Per-instance bounds as glm::vec4(x, y, width, height) in world space; optional parallel colors (RGBA per rectangle when colors.size() > i).
  • 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:

  • canvas_width > 0 and canvas_height > 0 if output should match the same NDC→pixel mapping as live OpenGL rendering (enforcement: none) [IMPORTANT]
  • batch.bounds[i] components should be finite for meaningful pixel geometry (enforcement: none) [LOW]
  • If batch.colors is non-empty, only indices i < batch.colors.size() read a per-rect color; otherwise each rectangle uses RGB white with fill-opacity``0.5f as the implementation default (enforcement: none) [LOW]

Postcondition:

  • Returns an empty vector when batch.bounds is empty.
  • Otherwise returns exactly one <rect fill="…" fill-opacity="…" stroke="none"/> string per bounds entry, in order.
  • Fill RGB comes from [colorToSVGHex](/api_generated/Namespaces/namespacePlottingSVG.md#function-colortosvghex); alpha is written as fill-opacity (unlike stroke-only paths that sometimes omit alpha).
  • Does not throw under normal std::string/ostringstream behavior.

Updated on 2026-11-13 at 20:25:41 +0000