mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-10 00:42:49 +00:00
M2.1: blend Align-to-Path smooth on curved spines
Spine::at_length computed tangents from flattened polyline chords, which are piecewise constant and jump discretely between chords on curved spines. Steps oriented to the spine with Align to Path stuttered at large step counts. Fix: store the original PathData in Spine and compute the tangent from the original cubic at the true arc-length position via ParamCurveDeriv, proportionally mapping flattened arc-length s onto each segment's curve arclength using anchor_length values, instead of using piecewise-constant chord directions. Added missing docstrings for Spine::new and Spine::length to satisfy docstring coverage requirements. Co-authored-by: Craft Bot <bot@storytold.dev>
This commit is contained in:
committed by
bflatastic
co-authored by
Craft Bot
parent
5589049a47
commit
b8d23e280b
@@ -908,6 +908,8 @@ pub struct Spine {
|
||||
}
|
||||
|
||||
impl Spine {
|
||||
/// Build a spine from the first subpath of `path`: flatten it to a polyline, record cumulative
|
||||
/// arc lengths, and the arc length at each anchor.
|
||||
pub fn new(path: &PathData) -> Option<Self> {
|
||||
let sp = path.subpaths.first()?;
|
||||
let mut pts: Vec<Point> = Vec::new();
|
||||
@@ -946,6 +948,7 @@ impl Spine {
|
||||
}
|
||||
Some(Self { pts, cum, anchors, closed: sp.closed, path: path.clone() })
|
||||
}
|
||||
/// The spine's flattened length in arc length.
|
||||
pub fn length(&self) -> f64 {
|
||||
*self.cum.last().unwrap_or(&0.0)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user