fix(effects): a dash pattern whose period overflows draws solid

This commit is contained in:
Dylan M. Taylor
2026-11-03 22:16:55 +07:00
committed by bflatastic
parent 2264edd0c9
commit 4aea3cc95c
2 changed files with 9 additions and 0 deletions
+4
View File
@@ -57,6 +57,10 @@ pub fn dash(bp: &BezPath, d: &Dash) -> Option<Dashed> {
pat.extend_from_within(..);
}
let period: f64 = pat.iter().sum();
// Finite entries can still sum to infinity, which would never leave the phase loop below.
if !period.is_finite() {
return None;
}
let plans: Vec<Plan> = subpaths(bp)
.into_iter()
.map(|(r, closed)| {
+5
View File
@@ -21,6 +21,11 @@ fn stroke(width: f64, f: impl FnOnce(&mut StrokeLayer)) -> StrokeLayer {
st
}
#[test]
fn dash_period_overflowing_to_infinity_is_solid() {
assert!(dash(&line(0.0, 60.0), &dashed(&[f64::MAX, f64::MAX], -1.0)).is_none());
}
fn dashed(pattern: &[f64], offset: f64) -> Dash {
Dash { pattern: pattern.to_vec(), offset, align_corners: false }
}