diff options
author | Juuz <6596629+Juuxel@users.noreply.github.com> | 2023-09-27 16:15:21 +0300 |
---|---|---|
committer | Juuz <6596629+Juuxel@users.noreply.github.com> | 2023-09-27 16:16:17 +0300 |
commit | 60de29e360c1d35fc0f3006fa131e03353e44a10 (patch) | |
tree | 681e9398166bb3dd1ad358c80c4d9f9bfb4d54b1 | |
parent | c8ef7825fbfbee6682b722bcac80046f2943b34a (diff) | |
download | LibGui-60de29e360c1d35fc0f3006fa131e03353e44a10.tar.gz LibGui-60de29e360c1d35fc0f3006fa131e03353e44a10.tar.bz2 LibGui-60de29e360c1d35fc0f3006fa131e03353e44a10.zip |
ScreenDrawing+Texture: Improve GUI sprite rendering
- Fix choppiness from using int coordinates
- UV order is normalised and flipping is explicitly not supported
-rw-r--r-- | src/main/java/io/github/cottonmc/cotton/gui/client/ScreenDrawing.java | 4 | ||||
-rw-r--r-- | src/main/java/io/github/cottonmc/cotton/gui/widget/data/Texture.java | 2 |
2 files changed, 4 insertions, 2 deletions
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/client/ScreenDrawing.java b/src/main/java/io/github/cottonmc/cotton/gui/client/ScreenDrawing.java index 6ddc9c0..9332bef 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/client/ScreenDrawing.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/client/ScreenDrawing.java @@ -132,8 +132,8 @@ public class ScreenDrawing { if (Float.isInfinite(fullWidth) || Float.isInfinite(fullHeight)) break outer; // Calculate the offset left/top coordinates. - int xo = x - (int) (fullWidth * texture.u1()); - int yo = y - (int) (fullHeight * texture.v1()); + float xo = x - fullWidth * Math.min(texture.u1(), texture.u2()); + float yo = y - fullHeight * Math.min(texture.v1(), texture.v2()); MatrixStack matrices = context.getMatrices(); matrices.push(); diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/data/Texture.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/data/Texture.java index 5418c70..47b296f 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/widget/data/Texture.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/data/Texture.java @@ -45,6 +45,8 @@ import java.util.Objects; * and they need to be drawn with specific {@code Texture}-accepting methods * or {@link net.minecraft.client.gui.DrawContext}. * + * <p>GUI sprite textures don't currently support flipping the texture by flipping UV coordinates. + * * @param image the image of this texture * @param type the type of this texture * @param u1 the start U-coordinate, between 0 and 1 |