From 63e06cd7cf48ec4a2067f995375bed184ee1cbb0 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 5 Dec 2026 10:53:38 -0800 Subject: [PATCH] Canvas: tessellate the anchor marks again when a built square is thin enough to draw as a line The move of the kept anchor marks mesh compared each requested square side with twice the feathering, but the tessellator tests the built rectangle's f32 width and height. A side just over 2 pixels gives a square exactly 2 pixels wide at x = 252.5, which the tessellator draws as a line. The check now tests both built squares, before and after the move. --- crates/ui-egui/src/canvas/selection.rs | 2 ++ crates/ui-egui/src/canvas/selection/tests.rs | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/crates/ui-egui/src/canvas/selection.rs b/crates/ui-egui/src/canvas/selection.rs index c38f85380d..d30921195d 100644 --- a/crates/ui-egui/src/canvas/selection.rs +++ b/crates/ui-egui/src/canvas/selection.rs @@ -742,7 +742,9 @@ impl KeptMesh { } for side in sides { let (a, b) = (Rect::from_center_size(from, egui::Vec2::splat(side)), Rect::from_center_size(to, egui::Vec2::splat(side))); + // The tessellator tests the built square's `f32` width and height, which can come out below `side`. if a.size() != b.size() + || [a, b].iter().any(|r| r.width() <= 2.0 * feathering || r.height() <= 2.0 * feathering) || !(lands(a.min.x, b.min.x, pixels[0]) && lands(a.max.x, b.max.x, pixels[0]) && lands(a.min.y, b.min.y, pixels[1]) diff --git a/crates/ui-egui/src/canvas/selection/tests.rs b/crates/ui-egui/src/canvas/selection/tests.rs index 765ccd98b3..fa63201eaf 100644 --- a/crates/ui-egui/src/canvas/selection/tests.rs +++ b/crates/ui-egui/src/canvas/selection/tests.rs @@ -1438,6 +1438,10 @@ fn a_move_tessellates_the_marks_again_when_a_square_is_drawn_as_a_line() { let mut options = PathOptionsSettings::default(); options.anchor_size = Some(2.0); assert!(!kept_at_one_pixel_per_point().translate(by, [Point::new(252.5, 10.0)], &options), "a 2 pt anchor at 1 pixel per point"); + // The `f32` just over 2 passes the check on the side, but the square built at x = 252.5 spans 251.5 to 253.5 in + // `f32`, 2 pixels wide, so the tessellator draws it as a line. + options.anchor_size = Some(f32::from_bits(2.0_f32.to_bits() + 1)); + assert!(!kept_at_one_pixel_per_point().translate(by, [Point::new(252.5, 10.0)], &options), "a square built 2 pixels wide"); options.anchor_size = Some(3.0); assert!(kept_at_one_pixel_per_point().translate(by, [Point::new(252.5, 10.0)], &options), "a 3 pt anchor"); }