mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-09 04:54:45 +00:00
fix(effects): a dash pattern whose period overflows draws solid
This commit is contained in:
committed by
bflatastic
parent
2264edd0c9
commit
4aea3cc95c
@@ -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)| {
|
||||
|
||||
@@ -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 }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user