From 82fef614ce6c6f2161cb9a67c136a60a809f5381 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E9=9D=92=E5=B1=B1?= Date: Sat, 11 May 2024 00:09:10 +0800 Subject: [PATCH] Round the icon's drawing rect when drawing the button Each component of the icon's drawing rect needs to be snapped to an integer. --- scene/gui/button.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scene/gui/button.cpp b/scene/gui/button.cpp index ad3f6076618..15b7f620362 100644 --- a/scene/gui/button.cpp +++ b/scene/gui/button.cpp @@ -298,6 +298,7 @@ void Button::_notification(int p_what) { icon_size = Size2(icon_width, icon_height); } icon_size = _fit_icon_size(icon_size); + icon_size = icon_size.round(); } if (icon_size.width > 0.0f) { @@ -336,6 +337,7 @@ void Button::_notification(int p_what) { icon_ofs.y = size.y - style_margin_bottom - icon_size.height; } break; } + icon_ofs = icon_ofs.floor(); Rect2 icon_region = Rect2(icon_ofs, icon_size); draw_texture_rect(_icon, icon_region, false, icon_modulate_color);