ferroui_base/media/geometry_path_data.rs
1use crate::media::FillRule;
2use crate::Point;
3
4/// An owned, backend-neutral Bezier path. Coordinates include the geometry's
5/// transform; no sampling or polygon approximation is performed by this API.
6#[derive(Clone, Debug, PartialEq)]
7pub struct GeometryPath {
8 pub fill_rule: FillRule,
9 pub segments: Vec<GeometryPathSegment>,
10}
11
12/// Curve commands in a [`GeometryPath`]. An open figure remains open.
13#[derive(Clone, Copy, Debug, PartialEq)]
14pub enum GeometryPathSegment {
15 MoveTo(Point),
16 LineTo(Point),
17 QuadraticTo {
18 control: Point,
19 point: Point,
20 },
21 CubicTo {
22 control1: Point,
23 control2: Point,
24 point: Point,
25 },
26 Close,
27}
28
29/// The independently rendered fill and stroke paths of a geometry.
30///
31/// Some geometries intentionally fill and stroke different paths (for example
32/// a figure whose closing edge is not stroked). An absent path is empty, while
33/// `IGeometryImpl::try_get_path_data` returning `None` means that the backend
34/// does not support extraction. Consumers must preserve this distinction.
35#[derive(Clone, Debug, PartialEq)]
36pub struct GeometryPathData {
37 pub fill: Option<GeometryPath>,
38 pub stroke: Option<GeometryPath>,
39}