tesing new ui scope

This commit is contained in:
2025-04-21 00:15:52 +02:00
parent 9f0d5ef78b
commit 1741e8c0b9
2 changed files with 42 additions and 6 deletions
@@ -5,6 +5,7 @@ import org.joml.Matrix4f;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.font.TextRenderer.TextLayerType;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.VertexConsumerProvider;
@@ -12,9 +13,8 @@ import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.Identifier;
public class RenderScope {
private MatrixStack matrices;
private VertexConsumerProvider.Immediate vertexConsumers;
private RenderLayer renderLayer;
public MatrixStack matrices;
public VertexConsumerProvider.Immediate vertexConsumers;
public RenderScope(MatrixStack matrices, VertexConsumerProvider.Immediate vertexConsumers) {
this.matrices = matrices;
@@ -42,7 +42,7 @@ public class RenderScope {
y2 = i;
}
VertexConsumer vertexConsumer = this.vertexConsumers.getBuffer(renderLayer);
VertexConsumer vertexConsumer = this.vertexConsumers.getBuffer(RenderLayer.getGui());
vertexConsumer.vertex(matrix4f, (float) x1, (float) y1, 0).color(color);
vertexConsumer.vertex(matrix4f, (float) x1, (float) y2, 0).color(color);
vertexConsumer.vertex(matrix4f, (float) x2, (float) y2, 0).color(color);
@@ -70,7 +70,7 @@ public class RenderScope {
y2 = i;
}
VertexConsumer vertexConsumer = this.vertexConsumers.getBuffer(renderLayer);
VertexConsumer vertexConsumer = this.vertexConsumers.getBuffer(RenderLayer.getGui());
vertexConsumer.vertex(matrix4f, (float) x1, (float) y1, 0).color(color);
vertexConsumer.vertex(matrix4f, (float) x1, (float) y2, 0).color(color);
vertexConsumer.vertex(matrix4f, (float) x2, (float) y2, 0).color(color);
@@ -1,17 +1,53 @@
package org.saturnclient.ui2.elements;
import org.joml.Quaternionf;
import org.saturnclient.ui2.Element;
import org.saturnclient.ui2.RenderScope;
public class Text extends Element {
private String text;
private boolean logged = false;
public Text(String text) {
this.text = text;
this.color = 0xFFFFFFFF;
}
@Override
public void render(RenderScope renderScope) {
renderScope.drawText(this.text, this.x, this.y, this.color);
// renderScope.drawText(this.text, this.x, this.y, this.color);
int rectWidth = 300;
int rectHeight = 300;
renderScope.matrices.push();
renderScope.matrices.multiply(net.minecraft.util.math.RotationAxis.POSITIVE_Z.rotationDegrees(90.0f));
renderScope.matrices.translate(300, 300, 0);
renderScope.matrices.scale(0.1f, 0.1f, 1.0f);
int r = 90; // Radius of the corner
int h = (rectHeight / 2) * 10; // Height of the box
int w = (rectWidth / 2) * 10; // Width of the box
for (int y = 0; y < h; y++) {
int startX;
if (y < r) {
double dy = y - r;
double dx = r - Math.sqrt(r * r - dy * dy);
startX = (int) Math.ceil(dx);
} else {
startX = 0;
}
renderScope.drawRect(startX, y, w - startX, 1, this.color);
}
renderScope.matrices.pop();
}
}