Donner 0.5.1
Embeddable browser-grade SVG2 engine
Loading...
Searching...
No Matches
donner::svg::components::ComputedPathComponent Struct Reference

Stores a Path used for rendering a shape, which may be generated from the parameters of shapes such as circle, rect, line, poly, and path. More...

#include "donner/svg/components/shape/ComputedPathComponent.h"

Collaboration diagram for donner::svg::components::ComputedPathComponent:
[legend]

Public Member Functions

Box2d localBounds () const
 Returns the tight fill bounds of the path in local (pre-transform) space.
Box2d transformedBounds (const Transform2d &pathFromTarget)
 Returns the tight bounds of the shape, transformed to the target coordinate system.

Public Attributes

Path spline
 Path used for rendering the shape.
std::optional< Box2dcachedLocalBounds
 Lazily-populated cache for localBounds(). Left as a public data member (rather than hidden behind a private: section) so the component stays an aggregate — entt's emplace_or_replace<T>(args...) path initializes components via aggregate initialization on older compilers and breaks once a non-public section is added.

Detailed Description

Stores a Path used for rendering a shape, which may be generated from the parameters of shapes such as circle, rect, line, poly, and path.

All shapes create computed paths, and these paths can be rendered using a unified rendering pipeline.

Member Function Documentation

◆ localBounds()

Box2d donner::svg::components::ComputedPathComponent::localBounds ( ) const
inline

Returns the tight fill bounds of the path in local (pre-transform) space.

Memoized — Path::bounds() walks every command (O(N) in path size), so hot-path callers (culling, hit-testing, filter-region computation) should prefer this accessor. The cache is tied to the ComputedPathComponent's lifetime; ShapeSystem rebuilds the component whenever the underlying geometry changes, which invalidates the cache. Style-only changes (fill color, opacity, stroke-width) leave the component — and the cached bounds — intact.

◆ transformedBounds()

Box2d donner::svg::components::ComputedPathComponent::transformedBounds ( const Transform2d & pathFromTarget)
inline

Returns the tight bounds of the shape, transformed to the target coordinate system.

Parameters
pathFromTargetTransform to transform the path to the target coordinate system.

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