diff --git a/crates/engine/src/tests/toolsettings.rs b/crates/engine/src/tests/toolsettings.rs index 194f3ab26b..2ec7667bde 100644 --- a/crates/engine/src/tests/toolsettings.rs +++ b/crates/engine/src/tests/toolsettings.rs @@ -290,9 +290,11 @@ fn legacy_spiral_decay_preferences_report_the_ratio_drawn_after_reopening() { assert_eq!(anchors.len(), 5); assert!(!path.is_closed()); let center = Point::new(200.0, 200.0); + // The path runs from the centre end outwards, and decay is per full wind: four quarter-turn + // segments give the decay. for pair in anchors.windows(2) { let ratio = pair[0].p.distance(center) / pair[1].p.distance(center); - assert!((100.0 * ratio - decay).abs() < 1e-10); + assert!((100.0 * ratio.powi(4) - decay).abs() < 1e-9); } assert_eq!(s.prefs.tool_settings["spiral"]["decay"], json!(99.99)); s.execute("edit.undo", &json!({})).unwrap(); diff --git a/crates/tools/src/draw2/family.rs b/crates/tools/src/draw2/family.rs index 97193ec431..2e93888d02 100644 --- a/crates/tools/src/draw2/family.rs +++ b/crates/tools/src/draw2/family.rs @@ -545,12 +545,13 @@ mod tests { let (id, params) = t.command(Point::ZERO, Point::new(100.0, 0.0), Mods::default()); assert_eq!(id, "shape.spiral"); assert_eq!(params["decay"], json!(expected)); - // Inspect the actual adjacent radii, not a second copy of the tool's clamp. + // Inspect the actual adjacent radii, not a second copy of the tool's clamp. Decay is per full + // wind and a segment is a quarter turn, so four segments give the decay. let path = vectorcraft_geom::shapes::spiral(Point::ZERO, 100.0, params["decay"].as_f64().unwrap(), 2, true); let anchors = &path.subpaths[0].anchors; let outer = anchors[2].p.distance(Point::ZERO); let next = anchors[1].p.distance(Point::ZERO); - assert!((100.0 * next / outer - expected).abs() < 1e-10); + assert!((100.0 * (next / outer).powi(4) - expected).abs() < 1e-9); } for invalid in [Value::Null, json!("80"), json!(false), json!({})] { t.set_option("decay", &invalid);