From 53dfa37b642b4b8770b1e47c68d28e0f54abd782 Mon Sep 17 00:00:00 2001 From: Klesti Selimaj Date: Wed, 25 Mar 2026 23:26:19 +0100 Subject: [PATCH] Improved rounded rectangles --- src/main/java/org/saturnclient/ui/RenderScope.java | 9 ++++++--- .../org/saturnclient/ui/components/inputs/Toggle.java | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/saturnclient/ui/RenderScope.java b/src/main/java/org/saturnclient/ui/RenderScope.java index 3ef5544..ed4513f 100644 --- a/src/main/java/org/saturnclient/ui/RenderScope.java +++ b/src/main/java/org/saturnclient/ui/RenderScope.java @@ -32,7 +32,9 @@ public interface RenderScope { default void drawRoundedRectangle(int x, int y, int width, int height, int radius, int color) { if (color == 0) return; - radius = Math.min(radius, Math.min(width, height)); + + radius = Math.min(radius, width / 2); + radius = Math.min(radius, height / 2); String svg = String.format( "" + @@ -45,8 +47,9 @@ public interface RenderScope { InputStream svgStream = new ByteArrayInputStream(svg.getBytes(StandardCharsets.UTF_8)); drawTexture(SvgTexture.getSvg(svgStream, - IdentifierRef.ofSaturn("textures/gui/tmp_rect/rounded_" + width + "_" + height + "_" + radius), - width * 3, height * 3), x, y, 0, 0, width, height, color); + IdentifierRef.ofSaturn( + "textures/gui/tmp_rect/rounded_" + width + "_" + height + "_" + radius), + width * 4, height * 4), x, y, 0, 0, width, height, color); } void drawBorder(int x, int y, int width, int height, int color); diff --git a/src/main/java/org/saturnclient/ui/components/inputs/Toggle.java b/src/main/java/org/saturnclient/ui/components/inputs/Toggle.java index d2b30e4..c55f940 100644 --- a/src/main/java/org/saturnclient/ui/components/inputs/Toggle.java +++ b/src/main/java/org/saturnclient/ui/components/inputs/Toggle.java @@ -17,9 +17,9 @@ public class Toggle extends Element { @Override public void render(RenderScope renderScope, ElementContext ctx) { - renderScope.drawRoundedRectangle(0, 0, width, height, height, + renderScope.drawRoundedRectangle(0, 0, 60, 30, Theme.WIDGET_RADIUS.value, Theme.withAlpha(0.5f, prop.value ? Theme.ACCENT.value : Theme.PRIMARY.value)); - renderScope.drawRoundedRectangle(prop.value ? 30 : 0, 0, 30, 30, 30, + renderScope.drawRoundedRectangle(prop.value ? 30 : 0, 0, 30, 30, Theme.WIDGET_RADIUS.value, prop.value ? Theme.ACCENT.value : Theme.PRIMARY.value); }