Skip to main content

dash_cycle_is_normalizable

Function dash_cycle_is_normalizable 

Source
pub fn dash_cycle_is_normalizable(dash: &DashPattern) -> bool
Expand description

Whether a dash pattern’s derived cycle survives kurbo’s own normalization arithmetic, so kurbo::dash terminates instead of spinning forever.

DashPattern::is_effective already screens out a non-positive or sub-epsilon pattern in favour of a solid stroke, but its own period check — on + off >= DASH_PERIOD_EPSILON — can itself be fooled: two individually finite lengths can sum past f64::MAX into +inf, and +inf >= DASH_PERIOD_EPSILON still reads as effective. kurbo doubles this crate’s on/off pair into its own length-2 dash array, so the period it derives is always on + off; once that overflows, phase.rem_euclid(period) overflows with it, and the catch-up loop kurbo::dash runs before it ever pulls a PathEl adds an infinite step to a value that never converges — on = off = f64::MAX, phase = -1.0 hangs this way. Refusing here, where on, off and phase already passed their own finiteness checks, is what keeps that unbounded loop out of the frame path.

Public for the same reason dash_path and well_formed are: the CPU oracle carries an identical copy, and a cross-crate test pins the two against each other so they cannot drift apart silently.