diff options
-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/icon/TextureIcon.java | 44 |
2 files changed, 43 insertions, 5 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 df66c1d..07d4417 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 @@ -41,10 +41,6 @@ public class ScreenDrawing { * @param width the width of the box on-screen * @param height the height of the box on-screen * @param texture the Identifier for the texture - * @param u1 the left edge of the texture - * @param v1 the top edge of the texture - * @param u2 the right edge of the texture - * @param v2 the bottom edge of the texture * @param color a color to tint the texture. This can be transparent! Use 0xFF_FFFFFF if you don't want a color tint * @param opacity opacity of the drawn texture. (0f is fully opaque and 1f is fully visible) * @since 2.0.0 diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/icon/TextureIcon.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/icon/TextureIcon.java index 0fec0fa..0876cb5 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/widget/icon/TextureIcon.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/icon/TextureIcon.java @@ -13,6 +13,8 @@ import net.minecraft.util.Identifier; */ public class TextureIcon implements Icon { private final Identifier texture; + private float opacity = 1f; + private int color = 0xFF_FFFFFF; /** * Constructs a new texture icon. @@ -23,9 +25,49 @@ public class TextureIcon implements Icon { this.texture = texture; } + /** + * Gets the opacity of the texture. + * + * @return the opacity + */ + public float getOpacity() { + return opacity; + } + + /** + * Sets the opacity of the texture. + * + * @param opacity the new opacity between 0 (fully transparent) and 1 (fully opaque) + * @return this icon + */ + public TextureIcon setOpacity(float opacity) { + this.opacity = opacity; + return this; + } + + /** + * Gets the color tint of the texture. + * + * @return the color tint + */ + public int getColor() { + return color; + } + + /** + * Sets the color tint of the texture. + * + * @param color the new color tint + * @return this icon + */ + public TextureIcon setColor(int color) { + this.color = color; + return this; + } + @Environment(EnvType.CLIENT) @Override public void paint(MatrixStack matrices, int x, int y, int size) { - ScreenDrawing.texturedRect(x, y, size, size, texture, 0xFF_FFFFFF); + ScreenDrawing.texturedRect(x, y, size, size, texture, color, opacity); } } |