removed borders

This commit is contained in:
2025-04-30 07:52:30 -05:00
parent f0e554d8bc
commit 5b6810a32f
4 changed files with 8 additions and 89 deletions
@@ -147,81 +147,6 @@ public class RenderScope {
this.matrices.pop();
}
public void drawRoundedBorderCornerTopLeft(int s, int radius, int color) {
for (double angle = Math.PI / 2; angle <= Math.PI; angle += Math.PI / 180) {
int x = (int) Math.round(radius * Math.cos(angle));
int y = (int) Math.round(radius * Math.sin(angle));
int snappedX = radius + x;
int snappedY = radius - y;
drawRect(snappedX, snappedY, s, s, color);
}
}
public void drawRoundedBorderCornerTopRight(int s, int radius, int color) {
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));
int snappedX = radius - x;
int snappedY = radius - y;
drawRect(snappedX, snappedY, s, s, color);
}
}
public void drawRoundedBorderCornerBottomLeft(int s, int radius, int color) {
for (double angle = Math.PI; angle <= Math.PI * 1.5; angle += Math.PI / 180) {
int x = (int) Math.round(radius * Math.cos(angle));
int y = (int) Math.round(radius * Math.sin(angle));
int snappedX = radius + x;
int snappedY = radius - y;
drawRect(snappedX, snappedY, s, s, color);
}
}
public void drawRoundedBorderCornerBottomRight(int s, int radius, int color) {
for (double angle = Math.PI * 1.5; 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));
int snappedX = radius + x;
int snappedY = radius - y;
drawRect(snappedX, snappedY, s, s, color);
}
}
public void drawRoundedBorder(int width, int height, int size, int radius, int color) {
radius = Math.min(radius, Math.min(width, height)) * 20;
size *= 10;
width *= 40;
height *= 40;
matrices.push();
matrices.scale(0.025f, 0.025f, 1.0f);
drawRoundedBorderCornerTopLeft(size, radius, color);
drawRect(radius, 0, width - (radius * 2), size, color);
drawRect(0, radius, size, height - (radius * 2), color);
drawRect(radius, height - size, width - (radius * 2), size, color);
drawRect(width - size, radius, size, height - (radius * 2), color);
matrices.translate(width - (radius * 2) - size, 0, 0);
drawRoundedBorderCornerTopRight(size, radius, color);
matrices.translate(0, height - (radius * 2) - size, 0);
drawRoundedBorderCornerBottomRight(size, radius, color);
matrices.translate(-(width - (radius * 2) - size), 0, 0);
drawRoundedBorderCornerBottomLeft(size, radius, color);
matrices.pop();
}
public int getScaledWindowWidth() {
return SaturnClient.client.getWindow().getScaledWidth();
}
@@ -3,18 +3,20 @@ package org.saturnclient.ui2.anim;
import org.saturnclient.ui2.Element;
public class Fade extends Animation {
float targetOpacity;
public Fade(int duration) {
super(duration);
}
@Override
public void tick(float progress, Element element) {
element.opacity = progress;
// element.opacity += 0.1f;
element.opacity = targetOpacity * progress;
}
@Override
public void init(Element element) {
targetOpacity = element.opacity;
element.opacity = 0;
}
}
@@ -13,14 +13,11 @@ public class Button extends Element {
private static ThemeManager theme = new ThemeManager("Button", "hovering");
private static Property<Integer> bgColor = theme.property("bg-color", new Property<Integer>(0xFF000000));
private static Property<Integer> fgColor = theme.property("fg-color", new Property<Integer>(0xFFFFFFFF));
private static Property<Integer> borderColor = theme.property("border-color", new Property<Integer>(0xFFFFFFFF));
private static Property<Integer> border = theme.property("border", new Property<Integer>(1));
private static Property<Integer> cornerRadius = theme.property("corner-radius", new Property<Integer>(10));
private static Property<Boolean> bold = theme.property("fg-bold", new Property<Boolean>(false));
static {
theme.propertyStateDefault("hovering", "fg-color", 0xFFFF0000);
theme.propertyStateDefault("hovering", "border-color", 0xFFFF0000);
}
private String text;
@@ -43,8 +40,6 @@ public class Button extends Element {
}
renderScope.drawRoundedRectangle(0, 0, width, height, cornerRadius.value, bgColor.value);
renderScope.drawRoundedBorder(width, height, border.value, cornerRadius.value, borderColor.value);
renderScope.drawText(text, (width - Fonts.getWidth(text, font)) / 2, (height - Fonts.getHeight()) / 2, bold.value, fgColor.value);
}
@@ -13,14 +13,12 @@ public class TextureButton extends Element {
private static ThemeManager theme = new ThemeManager("TextureButton", "hovering");
private static Property<Integer> bgColor = theme.property("bg-color", new Property<Integer>(0xFF000000));
private static Property<Integer> fgColor = theme.property("fg-color", new Property<Integer>(0xFFFFFFFF));
private static Property<Integer> borderColor = theme.property("border-color", new Property<Integer>(0xFFFFFFFF));
private static Property<Integer> border = theme.property("border", new Property<Integer>(1));
private static Property<Integer> padding = theme.property("padding", new Property<Integer>(14));
private static Property<Integer> cornerRadius = theme.property("corner-radius", new Property<Integer>(10));
static {
theme.propertyStateDefault("hovering", "fg-color", 0xFFFF0000);
theme.propertyStateDefault("hovering", "border-color", 0xFFFF0000);
}
Identifier sprite;
@@ -40,14 +38,13 @@ public class TextureButton extends Element {
}
renderScope.drawRoundedRectangle(0, 0, width, height, cornerRadius.value, bgColor.value);
renderScope.drawRoundedBorder(width, height, border.value, cornerRadius.value, borderColor.value);
renderScope.setRenderLayer(RenderLayer::getGuiTextured);
int texWidth = width - 4;
int texHeight = height - 4;
int texWidth = width - padding.value;
int texHeight = height - padding.value;
renderScope.drawTexture(sprite, 2, 2, 0, 0, texWidth, texHeight, fgColor.value);
renderScope.drawTexture(sprite, padding.value / 2, padding.value / 2, 0, 0, texWidth, texHeight, fgColor.value);
}
@Override