Skip to main content

euv_chart/geom/base/
enum.rs

1/// A single drawing command inside a [`Path`].
2///
3/// The command set is deliberately minimal and flat: every curve is
4/// expressed in its own primitive form, and flattening to line segments
5/// happens later, in [`tess`]. Keeping curves symbolic in the command
6/// buffer means a stroke can be expanded with a different flattening
7/// tolerance than a fill without rebuilding the path.
8///
9/// Every variant carries data, and `#[derive(Default)]` needs one
10/// without any, so this enum has no default.
11#[derive(Clone, Copy, Debug, PartialEq)]
12pub enum PathCommand {
13    /// Starts a new sub-path at the given point.
14    ///
15    /// A `MoveTo` implicitly closes any sub-path that is still open, which
16    /// matches the SVG filling rule: every sub-path is treated as closed
17    /// when it is filled, whether or not it was explicitly closed.
18    MoveTo(f32, f32),
19    /// Appends a straight line segment to the current point.
20    LineTo(f32, f32),
21    /// Appends a quadratic Bézier segment.
22    ///
23    /// The first pair is the control point, the second pair is the
24    /// endpoint.
25    QuadTo(f32, f32, f32, f32),
26    /// Appends a cubic Bézier segment.
27    ///
28    /// The first two pairs are the control points, the third pair is the
29    /// endpoint.
30    CubicTo(f32, f32, f32, f32, f32, f32),
31    /// Closes the current sub-path with a straight line back to its start.
32    Close,
33}
34
35/// How the interior of a self-intersecting path is determined.
36///
37/// Only the fill operation consults this; strokes are unaffected.
38#[derive(Clone, Copy, Debug, Default, Eq, Hash, PartialEq)]
39pub enum FillRule {
40    /// Counts winding direction: a point inside an odd number of
41    /// same-direction contours is filled.
42    ///
43    /// This is the default and matches what chart geometry expects — a
44    /// donut hole winds the opposite way from the outer ring, so it is
45    /// punched out.
46    #[default]
47    NonZero,
48    /// Counts crossings: a point inside an odd number of contours is
49    /// filled, regardless of direction.
50    EvenOdd,
51}
52
53/// How the ends of an open stroked line are drawn.
54#[derive(Clone, Copy, Debug, Default, Eq, Hash, PartialEq)]
55pub enum LineCap {
56    /// The line stops exactly at the endpoint.
57    #[default]
58    Butt,
59    /// The line is extended by half the stroke width, forming a square cap.
60    Square,
61    /// The line is extended by half the stroke width, forming a round cap.
62    Round,
63}
64
65/// How the corners between two stroked segments are drawn.
66#[derive(Clone, Copy, Debug, Default, Eq, Hash, PartialEq)]
67pub enum LineJoin {
68    /// The corner is a single point; the outer edges are mitred.
69    #[default]
70    Miter,
71    /// The corner is rounded.
72    Round,
73    /// The outer edges are bevelled off.
74    Bevel,
75}