Donner 0.5.1
Embeddable browser-grade SVG2 engine
Loading...
Searching...
No Matches
donner::svg::DonnerController Class Reference

Provides hit-testing and spatial queries for an SVG document. More...

#include "donner/svg/DonnerController.h"

Public Member Functions

 DonnerController (SVGDocument document)
 Create a controller for the given document.
std::optional< SVGGeometryElementfindIntersecting (const Vector2d &point)
 Finds the topmost geometry element whose rendered area contains the given point.

Detailed Description

Provides hit-testing and spatial queries for an SVG document.

Use DonnerController when you need to determine which element is at a given point (e.g., for mouse interaction in a viewer). This supplements the DOM traversal API on SVGElement with geometry-aware queries.

DonnerController controller(document);
if (auto element = controller.findIntersecting(Vector2d(100, 50))) {
std::cout << "Hit: " << element->tagName() << "\n";
}
DonnerController(SVGDocument document)
Create a controller for the given document.
Vector2< double > Vector2d
Shorthand for Vector2<double>.
Definition Vector2.h:394

Constructor & Destructor Documentation

◆ DonnerController()

donner::svg::DonnerController::DonnerController ( SVGDocument document)
explicit

Create a controller for the given document.

Parameters
documentThe SVG document to query.

Member Function Documentation

◆ findIntersecting()

std::optional< SVGGeometryElement > donner::svg::DonnerController::findIntersecting ( const Vector2d & point)

Finds the topmost geometry element whose rendered area contains the given point.

The point is in SVG canvas coordinates (the same coordinate space as the root <svg> element's viewBox). Returns the deepest matching element in paint order (last painted = topmost).

Parameters
pointPosition in canvas coordinates.
Returns
The topmost intersecting geometry element, or std::nullopt if no element is hit.

The documentation for this class was generated from the following file: