From 79d5419fcca462db0d40813c509922c0920bfffb Mon Sep 17 00:00:00 2001 From: Leo dev Date: Sat, 26 Apr 2025 00:23:39 +0200 Subject: [PATCH] Fixed crash when exit --- .../org/saturnclient/ui2/RenderScope.java | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/main/java/org/saturnclient/ui2/RenderScope.java b/src/main/java/org/saturnclient/ui2/RenderScope.java index 1a95bac..7e82d7b 100644 --- a/src/main/java/org/saturnclient/ui2/RenderScope.java +++ b/src/main/java/org/saturnclient/ui2/RenderScope.java @@ -174,21 +174,20 @@ public class RenderScope { } public void drawRoundedBorderCorner(int width, int height, int radius, int color) { - int h = height; int s = 3; - for (int y = 0; y < h; y+=s) { - int startX = 0; + // Step through the arc by angle + for (double angle = Math.PI; angle >= Math.PI / 2; angle -= Math.PI / 180) { + int x = (int) Math.round(radius * Math.cos(angle)); + int y = (int) Math.round(radius * Math.sin(angle)); - if (y < radius) { - double dy = radius - y - 0.5; - double dx = Math.sqrt(Math.max(0, radius * radius - dy * dy)); - startX = radius - (int) dx; - } + // Snap position to s-sized grid to avoid overlapping + int snappedX = (radius - x) / s * s; + int snappedY = (radius - y) / s * s; - this.drawRect(startX, y, s, s, color); + drawRect(snappedX, snappedY, s, s, color); } - } + } public void drawRoundedBorder(int x, int y, int width, int height, int borderSize, int radius, int color) {