almost there

This commit is contained in:
2025-04-21 17:10:28 +02:00
parent 3b44ead173
commit 4794e12bed
2 changed files with 23 additions and 46 deletions
@@ -71,8 +71,8 @@ public class RenderScope {
} }
public void drawRoundedCorner(int width, int height, int radius, int color) { public void drawRoundedCorner(int width, int height, int radius, int color) {
int w = width * 10; int w = width * 20;
int h = height * 10; int h = height * 20;
for (int y = 0; y < h; y++) { for (int y = 0; y < h; y++) {
int startX; int startX;
@@ -89,26 +89,17 @@ public class RenderScope {
} }
} }
public void drawRoundedRectangle(int x, int y, int width, int height, int radius, int color) { private void drawRoundedSide(int cornerWidth, int cornerHeight, int radius, int color) {
int cornerWidth = width / 2; // Top
int cornerHeight = height / 2;
this.matrices.push(); this.matrices.push();
this.matrices.translate(x, y, 0); this.matrices.scale(0.05f, 0.05f, 1.0f);
// Top left this.drawRoundedCorner(cornerWidth, cornerHeight, radius * 3, color);
this.matrices.push();
this.matrices.scale(0.1f, 0.1f, 1.0f);
this.drawRoundedCorner(cornerWidth, cornerHeight, radius, color);
this.matrices.pop(); this.matrices.pop();
// Bottom left // Bottom
this.matrices.push(); this.matrices.push();
this.matrices.translate(cornerWidth, cornerHeight * 2, 0); this.matrices.translate(cornerWidth, cornerHeight * 2, 0);
@@ -119,41 +110,28 @@ public class RenderScope {
this.matrices.scale(0.1f, 0.1f, 1.0f); this.matrices.scale(0.1f, 0.1f, 1.0f);
this.drawRoundedCorner(cornerHeight, cornerWidth, radius, color); this.drawRoundedCorner(cornerHeight, cornerWidth, radius * 3, color);
this.matrices.pop(); this.matrices.pop();
}
// Bottom right public void drawRoundedRectangle(int x, int y, int width, int height, int radius, int color) {
int cornerWidth = width / 2;
int cornerHeight = height / 2;
this.matrices.push(); this.matrices.push();
this.matrices.translate(cornerWidth * 2, cornerWidth > cornerHeight ? 0 : cornerHeight, 0); this.matrices.translate(x, y, 0);
this.drawRoundedSide(cornerWidth, cornerHeight, radius, color);
this.matrices.translate(cornerWidth * 2, cornerHeight * 2, 0);
this.matrices.multiply(RotationAxis.NEGATIVE_Z.rotationDegrees(180)); this.matrices.multiply(RotationAxis.NEGATIVE_Z.rotationDegrees(180));
this.matrices.translate(0, -cornerWidth, 0); this.matrices.translate(0, 0, 0);
this.matrices.scale(0.1f, 0.1f, 1.0f); this.drawRoundedSide(cornerWidth, cornerHeight, radius, color);
this.drawRoundedCorner(cornerWidth, cornerHeight, radius, color);
this.matrices.pop();
// top right
this.matrices.push();
this.matrices.translate(cornerWidth, 0, 0);
this.matrices.multiply(RotationAxis.NEGATIVE_Z.rotationDegrees(270));
this.matrices.translate(0, -cornerWidth, 0);
this.matrices.scale(0.1f, 0.1f, 1.0f);
this.drawRoundedCorner(cornerHeight, cornerWidth, radius, 0xFFFFFFFF);
this.matrices.pop();
this.matrices.pop(); this.matrices.pop();
} }
@@ -19,12 +19,11 @@ public class Button extends Element {
@Override @Override
public void render(RenderScope renderScope) { public void render(RenderScope renderScope) {
int w = 100; int w = 300;
int h = 200; 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); renderScope.drawRoundedRectangle(0, 0, w, h, 80, 0xFF000000);
// renderScope.drawRect(0, h, w, h, color);
// renderScope.drawRect(w, 0, w, h, color);
// renderScope.drawText(this.text, this.x, this.y, false, this.color);
} }
} }