pub struct Path {
pub pts: Vec<PathPoint>,
pub flags: Vec<PathFlags>,
pub hints: Vec<StrokeAdjustHint>,
pub cur_subpath: usize,
}Expand description
A PDF graphics path: an ordered sequence of subpaths built from lines and cubic Bezier curves.
§Invariants
These match SplashPath.cc:
pts.len() == flags.len()at all times.cur_subpathis the index of the first point of the currently open subpath, or equalspts.len()when there is no current point.- Control points (flag
PathFlags::CURVE) always appear in groups of three between two on-curve points.
Fields§
§pts: Vec<PathPoint>Ordered sequence of path points.
flags: Vec<PathFlags>Per-point flags, parallel to Self::pts.
hints: Vec<StrokeAdjustHint>Optional stroke-adjust hints.
cur_subpath: usizeIndex of the first point of the currently open subpath.
Equals pts.len() when there is no current point (fresh path or
immediately after a close).
Implementations§
Source§impl Path
impl Path
Sourcepub const fn no_current_point(&self) -> bool
pub const fn no_current_point(&self) -> bool
Returns true when there is no current point.
This is the case for a freshly created path and immediately after
PathBuilder::close completes.
Sourcepub const fn one_point_subpath(&self) -> bool
pub const fn one_point_subpath(&self) -> bool
Returns true after exactly one PathBuilder::move_to with no
subsequent PathBuilder::line_to or PathBuilder::curve_to.
§Underflow safety
The !self.pts.is_empty() guard ensures pts.len() - 1 is evaluated
only when pts has at least one element, so no wrapping subtraction
can occur.
Sourcepub const fn open_subpath(&self) -> bool
pub const fn open_subpath(&self) -> bool
Returns true when the current subpath has at least two points.
Sourcepub fn current_point(&self) -> Option<PathPoint>
pub fn current_point(&self) -> Option<PathPoint>
Returns the current point (last appended endpoint), if any.
Returns None when Self::no_current_point is true — i.e. on a
fresh path and immediately after a close (because close sets
cur_subpath to pts.len()).
Sourcepub fn append(&mut self, other: &Self)
pub fn append(&mut self, other: &Self)
Append all points and hints from other into self.
cur_subpath is set to self.pts.len() + other.cur_subpath before
appending, matching SplashPath::append.
§Edge cases
If other is empty (other.pts.is_empty()), then
other.cur_subpath == 0 (the default) and
self.cur_subpath is set to self.pts.len() — the “no current point”
sentinel — which is correct: appending an empty path does not create a
current point.