From 204318adc1b7e588af2b9d4fc7c4bad5306f609d Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Mon, 16 Dec 2024 16:10:32 +0100 Subject: [PATCH] Fix rounding --- crates/epaint/src/tessellator.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/crates/epaint/src/tessellator.rs b/crates/epaint/src/tessellator.rs index 01705f5f4b5..3599146455e 100644 --- a/crates/epaint/src/tessellator.rs +++ b/crates/epaint/src/tessellator.rs @@ -1277,6 +1277,11 @@ impl Tessellator { ((point * self.pixels_per_point - 0.5).round() + 0.5) / self.pixels_per_point } + #[inline(always)] + pub fn round_pos_to_pixel(&self, pos: Pos2) -> Pos2 { + pos2(self.round_to_pixel(pos.x), self.round_to_pixel(pos.y)) + } + #[inline(always)] pub fn round_pos_to_pixel_center(&self, pos: Pos2) -> Pos2 { pos2( @@ -1707,8 +1712,8 @@ impl Tessellator { // We can fix that by rounding the rectangle corners to pixel centers. // TODO(#5164): maybe do this for all shapes and stroke sizes Rect { - min: self.round_pos_to_pixel_center(rect.min), - max: self.round_pos_to_pixel_center(rect.max), + min: self.round_pos_to_pixel(rect.min), + max: self.round_pos_to_pixel(rect.max), } } else { rect