mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-10 03:01:33 +00:00
Merge pull request #5373 from storytold/fix/sec-dash-period-overflow
Dashes: a pattern whose period overflows to infinity draws solid
This commit is contained in:
@@ -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