fixed rounded rectangle

This commit is contained in:
2025-04-21 17:18:23 +02:00
parent 4794e12bed
commit 404838b70d
2 changed files with 12 additions and 19 deletions
@@ -75,14 +75,12 @@ public class RenderScope {
int h = height * 20; int h = height * 20;
for (int y = 0; y < h; y++) { for (int y = 0; y < h; y++) {
int startX; int startX = 0;
if (y < radius) { if (y < radius) {
double dy = y - radius; double dy = radius - y - 0.5;
double dx = radius - Math.sqrt(radius * radius - dy * dy); double dx = Math.sqrt(Math.max(0, radius * radius - dy * dy));
startX = (int) Math.ceil(dx); startX = radius - (int) dx;
} else {
startX = 0;
} }
this.drawRect(startX, y, w - startX, 1, color); this.drawRect(startX, y, w - startX, 1, color);
@@ -95,7 +93,7 @@ public class RenderScope {
this.matrices.scale(0.05f, 0.05f, 1.0f); this.matrices.scale(0.05f, 0.05f, 1.0f);
this.drawRoundedCorner(cornerWidth, cornerHeight, radius * 3, color); this.drawRoundedCorner(cornerWidth, cornerHeight, radius * 10, color);
this.matrices.pop(); this.matrices.pop();
@@ -108,9 +106,9 @@ public class RenderScope {
this.matrices.translate(0, -cornerWidth, 0); this.matrices.translate(0, -cornerWidth, 0);
this.matrices.scale(0.1f, 0.1f, 1.0f); this.matrices.scale(0.05f, 0.05f, 1.0f);
this.drawRoundedCorner(cornerHeight, cornerWidth, radius * 3, color); this.drawRoundedCorner(cornerHeight, cornerWidth, radius * 10, color);
this.matrices.pop(); this.matrices.pop();
} }
@@ -19,11 +19,6 @@ public class Button extends Element {
@Override @Override
public void render(RenderScope renderScope) { public void render(RenderScope renderScope) {
int w = 300; renderScope.drawRoundedRectangle(0, 0, width, height, 10, color);
int h = 100;
renderScope.drawRect(0, h, w, h, color);
renderScope.drawRect(w, 0, w, h, color);
renderScope.drawRoundedRectangle(0, 0, w, h, 80, 0xFF000000);
} }
} }