From 239a7d61d0fa337f1023e8640fe651d4dbf7dfe4 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 21 Nov 2026 00:15:55 -0800 Subject: [PATCH] Smooth: the dashed band shows the radius its release sends at the lowest zooms The band a smoothing drag shows took the Smooth radius in points without the 1,000 pt bound the release applies, so below 1.2% zoom it drew wider than the region path.smoothRegion smooths. It now uses the same bound. --- crates/tools/src/draw2/gesture.rs | 2 +- crates/tools/src/draw2/gesture/tests.rs | 32 +++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/crates/tools/src/draw2/gesture.rs b/crates/tools/src/draw2/gesture.rs index ab88d16436..a34c819761 100644 --- a/crates/tools/src/draw2/gesture.rs +++ b/crates/tools/src/draw2/gesture.rs @@ -1920,7 +1920,7 @@ impl Tool for GestureTool { // release smooths. if (self.id == "smooth" || self.smoothing) && has_selected_smooth_path(cx) - && let Some(path) = self.smooth_band(cx.tol(SMOOTH_RADIUS)) + && let Some(path) = self.smooth_band(reach(cx, SMOOTH_RADIUS)) { o.push(Overlay::SharedPath { path, color: FEEDBACK, width: 1.0, dash: Some(0.0) }); } diff --git a/crates/tools/src/draw2/gesture/tests.rs b/crates/tools/src/draw2/gesture/tests.rs index dbbbb53a78..00f0ebc93e 100644 --- a/crates/tools/src/draw2/gesture/tests.rs +++ b/crates/tools/src/draw2/gesture/tests.rs @@ -1641,6 +1641,38 @@ fn smoothing_band_shows_no_seam_where_it_turns_across_a_square_side() { } } +/// Zoomed out far enough that the Smooth tool's radius in points passes the top of +/// [`crate::draw2::REACH_RANGE`], the band a smoothing drag shows has the radius its release sends. +#[test] +fn smoothing_band_at_the_lowest_zoom_has_the_radius_the_release_sends() { + let (d, id) = doc_with_rect(); + let mut s = Selection::default(); + s.set([id]); + let p = paint(); + let mut cx = cx(&d, &s, &p); + cx.smart_guides = false; + cx.zoom = 0.005; + let r = crate::draw2::REACH_RANGE.1; + assert!(cx.tol(SMOOTH_RADIUS) > r, "the radius on screen is past the range at {}x", cx.zoom); + let ends = [Point::new(1000.0, 1000.0), Point::new(5000.0, 1000.0)]; + let mut t = GestureTool::new("smooth"); + t.pointer(&cx, &PointerEvent::new(PointerKind::Down, ends[0].x, ends[0].y)); + for i in 1..=20 { + let q = ends[0].lerp(ends[1], f64::from(i) / 20.0); + t.pointer(&cx, &PointerEvent::new(PointerKind::Drag, q.x, q.y)); + } + let mut frames = 0; + while t.overlays_pending() { + assert!(frames < 10_000, "the band reaches the whole drag"); + bands(&t, &cx); + frames += 1; + } + check_band(&t, &cx, r); + let acts = t.pointer(&cx, &PointerEvent::new(PointerKind::Up, ends[1].x, ends[1].y)); + let Some(Action::Exec(c, v)) = acts.first() else { panic!("expected a command, got {acts:?}") }; + assert_eq!((c.as_str(), v["radius"].as_f64()), ("path.smoothRegion", Some(r)), "{v}"); +} + /// One straight piece of a square's outline along a side, where the band goes on across only part /// of it, shows only the part with nothing across. #[test]