Skip to content

ui::PathGeometry

Header: winui/render/PathGeometry.hpp.

A set of figures and the fill rule between them: what a Path, a path icon or any other Shape draws.

A default-constructed PathGeometry is empty and draws nothing. Build one with the static builders or parse path markup, then hand it to a ui::PathControl, to ui::Path{.data = ...}, to IconSource::path(), or straight to Renderer::draw_geometry().

Example:

const auto arrow = ui::PathGeometry::parse("F1 M 20,20L 24,10L 24,24L 5,24"); // nullopt if malformed
const ui::PathGeometry pill   = ui::PathGeometry::rectangle(ui::Rect{0, 0, 40, 16}, 8.0f, 8.0f);
const ui::PathGeometry both[] = {*arrow, pill};
const ui::PathGeometry group  = ui::PathGeometry::group(both, ui::FillRule::Nonzero);

window.set_content(ui::Path{
    .data   = group,
    .fill   = ui::colors::Black,
    .stroke = ui::Color::from_rgba(0, 120, 215),
});

figures

std::vector<PathFigure> figures

The figures, drawn in order; all share fill_rule.

fill_rule

FillRule fill_rule = FillRule::EvenOdd

How overlapping figures decide what is inside (markup F0/F1).

line

static PathGeometry line(Point from, Point to)

A line: one open figure from from to to.

rectangle

static PathGeometry rectangle(const Rect& rect, float radius_x = 0.0f, float radius_y = 0.0f)

A rectangle, also a Rectangle shape's outline: a closed figure, its corners rounded by elliptical arcs of radius_x by radius_y when either is positive (each clamped to half the rect), sixteen points in all.

ellipse

static PathGeometry ellipse(Point center, float radius_x, float radius_y)

An ellipse: a closed figure of four quarter arcs.

polyline

static PathGeometry polyline(std::span<const Point> points, bool closed, FillRule rule = FillRule::EvenOdd)

A Polyline (closed false) or Polygon (closed true): straight segments through points. Fewer than two points is empty.

group

static PathGeometry group(std::span<const PathGeometry> members, FillRule rule = FillRule::EvenOdd)

A group: every member's figures under one fill rule.

parse

static std::optional<PathGeometry> parse(std::string_view markup)

Parses path markup such as F1 M 0,10 L 5,0 L 10,10 Z. Returns nullopt when the markup doesn't parse. An empty string is an empty geometry.

empty

bool empty() const

True when there are no figures (the geometry draws nothing).

bounds

Rect bounds() const

The tight bounding box of every figure (Bézier extrema, not control points). An empty geometry has an empty rect at the origin.

transformed

PathGeometry transformed(const Matrix& m) const

Every point run through m. Béziers stay Béziers: an affine transform of the control points is the transform of the curve.

fill_contains

bool fill_contains(Point p) const

Whether p is inside the filled area under the fill rule, with curves flattened finely enough for hit testing.