|
|
| SVGDocument () |
| | Constructor to create an empty SVGDocument with default settings.
|
| | SVGDocument (Settings settings) |
| | Constructor to create an empty SVGDocument.
|
|
Registry & | registry () |
| | Get the underlying ECS Registry, which holds all data for the document, for advanced use.
|
|
const Registry & | registry () const |
| | Get the underlying ECS Registry, which holds all data for the document, for advanced use.
|
| SVGDocumentHandle | handle () const |
| | Get the internal shared document handle used by this value facade.
|
|
EntityHandle | rootEntityHandle () const |
| | Get the root ECS Entity of the document, for advanced use.
|
|
SVGSVGElement | svgElement () const |
| | Get the root "<svg>" element of the document.
|
| void | setCanvasSize (int width, int height) |
| | Set the canvas (output image) size to a fixed width and height, in pixels.
|
| void | useAutomaticCanvasSize () |
| | Automatically determine the canvas size from the root <svg> element's width and height attributes.
|
|
Vector2i | canvasSize () const |
| | Get the current canvas size, or the default size (512x512) if the canvas size has not been explicitly set.
|
| int | width () const |
| | Get the width of the SVG document, in pixels.
|
| int | height () const |
| | Get the height of the SVG document, in pixels.
|
| Transform2d | canvasFromDocumentTransform () const |
| | Returns the transform that maps points from the SVG document's viewBox coordinate space into the canvas-scaled output space.
|
|
bool | operator== (const SVGDocument &other) const |
| | Returns true if the two SVGDocument handles reference the same underlying document.
|
| std::optional< SVGElement > | querySelector (std::string_view selector) |
| | Find the first element in the tree that matches the given CSS selector.
|
Represents a parsed SVG document containing a tree of SVGElement nodes.
To create a document, parse SVG content with donner::svg::parser::SVGParser::ParseSVG, or construct an empty document and build the tree programmatically. Access the root <svg> element with svgElement(), find elements with querySelector(), and render with donner::svg::Renderer.
SVGDocument and SVGElement expose a familiar DOM API for traversal and manipulation (e.g., firstChild(), appendChild(), querySelector()). Elements are lightweight value types that can be copied and passed on the stack.
SVGDocument is not thread-safe — do not access the same document from multiple threads concurrently.
- Note
- Internally, data is stored using an Entity Component System (ECS) for cache-friendly access during rendering. The registry() and entityHandle() accessors expose this for advanced use cases, but most users can ignore the ECS layer entirely.
- See also
- SVGElement
| Transform2d donner::svg::SVGDocument::canvasFromDocumentTransform |
( |
| ) |
const |
Returns the transform that maps points from the SVG document's viewBox coordinate space into the canvas-scaled output space.
This bakes in the preserveAspectRatio fit (letterbox offset + uniform scale) between the viewBox and the current canvas size.
Naming: per the destFromSource convention, applying this transform to a viewBox-space point yields a canvas-space point — i.e. it is canvasFromDocument, despite an earlier misnomer. Callers that need the opposite direction (canvas pixel → document viewBox coordinate, e.g. click math in editors/viewers) should invert it.