Class ScreenDrawing
java.lang.Object
io.github.cottonmc.cotton.gui.client.ScreenDrawing
ScreenDrawing contains utility methods for drawing contents on a screen.-
Method Summary
Modifier and TypeMethodDescriptionstatic intcolorAtOpacity(int opaque, float opacity) static voidcoloredRect(net.minecraft.client.util.math.MatrixStack matrices, int left, int top, int width, int height, int color) Draws an untextured rectangle of the specified RGB color.static voiddrawBeveledPanel(net.minecraft.client.util.math.MatrixStack matrices, int x, int y) Draws a default-sized recessed itemslot panelstatic voiddrawBeveledPanel(net.minecraft.client.util.math.MatrixStack matrices, int x, int y, int width, int height) Draws a default-color recessed itemslot panel of variable sizestatic voiddrawBeveledPanel(net.minecraft.client.util.math.MatrixStack matrices, int x, int y, int width, int height, int topleft, int panel, int bottomright) Draws a generalized-case beveled panel.static voiddrawGuiPanel(net.minecraft.client.util.math.MatrixStack matrices, int x, int y, int width, int height) Draws a beveled, round rectangle that is substantially similar to default Minecraft UI panels.static voiddrawGuiPanel(net.minecraft.client.util.math.MatrixStack matrices, int x, int y, int width, int height, int panelColor) Draws a beveled, round, and colored rectangle that is substantially similar to default Minecraft UI panels.static voiddrawGuiPanel(net.minecraft.client.util.math.MatrixStack matrices, int x, int y, int width, int height, int shadow, int panel, int hilight, int outline) Draws a beveled, round rectangle with custom edge colors that is substantially similar to default Minecraft UI panels.static voiddrawString(net.minecraft.client.util.math.MatrixStack matrices, String s, int x, int y, int color) Draws a left-aligned string.static voiddrawString(net.minecraft.client.util.math.MatrixStack matrices, String s, HorizontalAlignment align, int x, int y, int width, int color) Draws a string with a custom alignment.static voiddrawString(net.minecraft.client.util.math.MatrixStack matrices, net.minecraft.text.OrderedText text, int x, int y, int color) Draws a left-aligned text component.static voiddrawString(net.minecraft.client.util.math.MatrixStack matrices, net.minecraft.text.OrderedText text, HorizontalAlignment align, int x, int y, int width, int color) Draws a text component with a custom alignment.static voiddrawStringWithShadow(net.minecraft.client.util.math.MatrixStack matrices, String s, HorizontalAlignment align, int x, int y, int width, int color) Draws a shadowed string.static voiddrawStringWithShadow(net.minecraft.client.util.math.MatrixStack matrices, net.minecraft.text.OrderedText text, HorizontalAlignment align, int x, int y, int width, int color) Draws a shadowed text component.static voiddrawTextHover(net.minecraft.client.util.math.MatrixStack matrices, @Nullable net.minecraft.text.Style textStyle, int x, int y) Draws the text hover effects for a text style.static intmultiplyColor(int color, float amount) static voidtexturedGuiRect(net.minecraft.client.util.math.MatrixStack matrices, int left, int top, int width, int height, net.minecraft.util.Identifier texture, int color) Draws a textured rectangle with UV values based on the width and height.static voidtexturedGuiRect(net.minecraft.client.util.math.MatrixStack matrices, int x, int y, int width, int height, net.minecraft.util.Identifier texture, int textureX, int textureY, int color) Draws a textured rectangle with UV values based on the width and height.static voidtexturedRect(net.minecraft.client.util.math.MatrixStack matrices, int x, int y, int width, int height, Texture texture, int color) Draws a textured rectangle.static voidtexturedRect(net.minecraft.client.util.math.MatrixStack matrices, int x, int y, int width, int height, Texture texture, int color, float opacity) Draws a textured rectangle.static voidtexturedRect(net.minecraft.client.util.math.MatrixStack matrices, int x, int y, int width, int height, net.minecraft.util.Identifier texture, float u1, float v1, float u2, float v2, int color) Draws a textured rectangle.static voidtexturedRect(net.minecraft.client.util.math.MatrixStack matrices, int x, int y, int width, int height, net.minecraft.util.Identifier texture, float u1, float v1, float u2, float v2, int color, float opacity) Draws a textured rectangle.static voidtexturedRect(net.minecraft.client.util.math.MatrixStack matrices, int x, int y, int width, int height, net.minecraft.util.Identifier texture, int color) Draws a textured rectangle.static voidtexturedRect(net.minecraft.client.util.math.MatrixStack matrices, int x, int y, int width, int height, net.minecraft.util.Identifier texture, int color, float opacity) Draws a textured rectangle.
-
Method Details
-
texturedRect
public static void texturedRect(net.minecraft.client.util.math.MatrixStack matrices, int x, int y, int width, int height, net.minecraft.util.Identifier texture, int color) Draws a textured rectangle.- Parameters:
matrices- the rendering matrix stackx- the x coordinate of the box on-screeny- the y coordinate of the box on-screenwidth- the width of the box on-screenheight- the height of the box on-screentexture- the Identifier for the texturecolor- a color to tint the texture. This can be transparent! Use 0xFF_FFFFFF if you don't want a color tint
-
texturedRect
public static void texturedRect(net.minecraft.client.util.math.MatrixStack matrices, int x, int y, int width, int height, net.minecraft.util.Identifier texture, int color, float opacity) Draws a textured rectangle.- Parameters:
matrices- the rendering matrix stackx- the x coordinate of the box on-screeny- the y coordinate of the box on-screenwidth- the width of the box on-screenheight- the height of the box on-screentexture- the Identifier for the texturecolor- a color to tint the texture. This can be transparent! Use 0xFF_FFFFFF if you don't want a color tintopacity- opacity of the drawn texture. (0f is fully opaque and 1f is fully visible)- Since:
- 2.0.0
-
texturedRect
public static void texturedRect(net.minecraft.client.util.math.MatrixStack matrices, int x, int y, int width, int height, net.minecraft.util.Identifier texture, float u1, float v1, float u2, float v2, int color) Draws a textured rectangle.- Parameters:
matrices- the rendering matrix stackx- the x coordinate of the box on-screeny- the y coordinate of the box on-screenwidth- the width of the box on-screenheight- the height of the box on-screentexture- the Identifier for the textureu1- the left edge of the texturev1- the top edge of the textureu2- the right edge of the texturev2- the bottom edge of the texturecolor- a color to tint the texture. This can be transparent! Use 0xFF_FFFFFF if you don't want a color tint
-
texturedRect
public static void texturedRect(net.minecraft.client.util.math.MatrixStack matrices, int x, int y, int width, int height, Texture texture, int color) Draws a textured rectangle.- Parameters:
matrices- the rendering matrix stackx- the x coordinate of the box on-screeny- the y coordinate of the box on-screenwidth- the width of the box on-screenheight- the height of the box on-screentexture- the texturecolor- a color to tint the texture. This can be transparent! Use 0xFF_FFFFFF if you don't want a color tint- Since:
- 3.0.0
-
texturedRect
public static void texturedRect(net.minecraft.client.util.math.MatrixStack matrices, int x, int y, int width, int height, Texture texture, int color, float opacity) Draws a textured rectangle.- Parameters:
matrices- the rendering matrix stackx- the x coordinate of the box on-screeny- the y coordinate of the box on-screenwidth- the width of the box on-screenheight- the height of the box on-screentexture- the texturecolor- a color to tint the texture. This can be transparent! Use 0xFF_FFFFFF if you don't want a color tintopacity- opacity of the drawn texture. (0f is fully opaque and 1f is fully visible)- Since:
- 3.0.0
-
texturedRect
public static void texturedRect(net.minecraft.client.util.math.MatrixStack matrices, int x, int y, int width, int height, net.minecraft.util.Identifier texture, float u1, float v1, float u2, float v2, int color, float opacity) Draws a textured rectangle.- Parameters:
matrices- the rendering matrix stackx- the x coordinate of the box on-screeny- the y coordinate of the box on-screenwidth- the width of the box on-screenheight- the height of the box on-screentexture- the Identifier for the textureu1- the left edge of the texturev1- the top edge of the textureu2- the right edge of the texturev2- the bottom edge of the texturecolor- a color to tint the texture. This can be transparent! Use 0xFF_FFFFFF if you don't want a color tintopacity- opacity of the drawn texture. (0f is fully opaque and 1f is fully visible)- Since:
- 2.0.0
-
texturedGuiRect
public static void texturedGuiRect(net.minecraft.client.util.math.MatrixStack matrices, int x, int y, int width, int height, net.minecraft.util.Identifier texture, int textureX, int textureY, int color) Draws a textured rectangle with UV values based on the width and height.If the texture is 256x256, this draws the texture at one pixel per texel.
- Parameters:
matrices- the rendering matrix stackx- the x coordinate of the box on-screeny- the y coordinate of the box on-screenwidth- the width of the box on-screenheight- the height of the box on-screentexture- the Identifier for the texturetextureX- the x offset into the texturetextureY- the y offset into the texturecolor- a color to tint the texture. This can be transparent! Use 0xFF_FFFFFF if you don't want a color tint
-
texturedGuiRect
public static void texturedGuiRect(net.minecraft.client.util.math.MatrixStack matrices, int left, int top, int width, int height, net.minecraft.util.Identifier texture, int color) Draws a textured rectangle with UV values based on the width and height.If the texture is 256x256, this draws the texture at one pixel per texel.
- Parameters:
matrices- the rendering matrix stackleft- the x coordinate of the box on-screentop- the y coordinate of the box on-screenwidth- the width of the box on-screenheight- the height of the box on-screentexture- the Identifier for the texturecolor- a color to tint the texture. This can be transparent! Use 0xFF_FFFFFF if you don't want a color tint
-
coloredRect
public static void coloredRect(net.minecraft.client.util.math.MatrixStack matrices, int left, int top, int width, int height, int color) Draws an untextured rectangle of the specified RGB color. -
drawGuiPanel
public static void drawGuiPanel(net.minecraft.client.util.math.MatrixStack matrices, int x, int y, int width, int height) Draws a beveled, round rectangle that is substantially similar to default Minecraft UI panels.- Parameters:
matrices- the rendering matrix stackx- the X position of the panely- the Y position of the panelwidth- the width of the panelheight- the height of the panel
-
drawGuiPanel
public static void drawGuiPanel(net.minecraft.client.util.math.MatrixStack matrices, int x, int y, int width, int height, int panelColor) Draws a beveled, round, and colored rectangle that is substantially similar to default Minecraft UI panels.- Parameters:
matrices- the rendering matrix stackx- the X position of the panely- the Y position of the panelwidth- the width of the panelheight- the height of the panelpanelColor- the panel ARGB color
-
drawGuiPanel
public static void drawGuiPanel(net.minecraft.client.util.math.MatrixStack matrices, int x, int y, int width, int height, int shadow, int panel, int hilight, int outline) Draws a beveled, round rectangle with custom edge colors that is substantially similar to default Minecraft UI panels.- Parameters:
matrices- the rendering matrix stackx- the X position of the panely- the Y position of the panelwidth- the width of the panelheight- the height of the panelshadow- the bottom/right shadow ARGB colorpanel- the center ARGB colorhilight- the top/left hilight ARGB coloroutline- the outline ARGB color
-
drawBeveledPanel
public static void drawBeveledPanel(net.minecraft.client.util.math.MatrixStack matrices, int x, int y) Draws a default-sized recessed itemslot panel -
drawBeveledPanel
public static void drawBeveledPanel(net.minecraft.client.util.math.MatrixStack matrices, int x, int y, int width, int height) Draws a default-color recessed itemslot panel of variable size -
drawBeveledPanel
public static void drawBeveledPanel(net.minecraft.client.util.math.MatrixStack matrices, int x, int y, int width, int height, int topleft, int panel, int bottomright) Draws a generalized-case beveled panel. Can be inset or outset depending on arguments.- Parameters:
matrices- the rendering matrix stackx- x coordinate of the topleft cornery- y coordinate of the topleft cornerwidth- width of the panelheight- height of the paneltopleft- color of the top/left bevelpanel- color of the panel areabottomright- color of the bottom/right bevel
-
drawString
public static void drawString(net.minecraft.client.util.math.MatrixStack matrices, String s, HorizontalAlignment align, int x, int y, int width, int color) Draws a string with a custom alignment.- Parameters:
matrices- the rendering matrix stacks- the stringalign- the alignment of the stringx- the X positiony- the Y positionwidth- the width of the string, used for aligningcolor- the text color
-
drawString
public static void drawString(net.minecraft.client.util.math.MatrixStack matrices, net.minecraft.text.OrderedText text, HorizontalAlignment align, int x, int y, int width, int color) Draws a text component with a custom alignment.- Parameters:
matrices- the rendering matrix stacktext- the textalign- the alignment of the stringx- the X positiony- the Y positionwidth- the width of the string, used for aligningcolor- the text color- Since:
- 1.9.0
-
drawStringWithShadow
public static void drawStringWithShadow(net.minecraft.client.util.math.MatrixStack matrices, String s, HorizontalAlignment align, int x, int y, int width, int color) Draws a shadowed string.- Parameters:
matrices- the rendering matrix stacks- the stringalign- the alignment of the stringx- the X positiony- the Y positionwidth- the width of the string, used for aligningcolor- the text color
-
drawStringWithShadow
public static void drawStringWithShadow(net.minecraft.client.util.math.MatrixStack matrices, net.minecraft.text.OrderedText text, HorizontalAlignment align, int x, int y, int width, int color) Draws a shadowed text component.- Parameters:
matrices- the rendering matrix stacktext- the text componentalign- the alignment of the stringx- the X positiony- the Y positionwidth- the width of the string, used for aligningcolor- the text color
-
drawString
public static void drawString(net.minecraft.client.util.math.MatrixStack matrices, String s, int x, int y, int color) Draws a left-aligned string.- Parameters:
matrices- the rendering matrix stacks- the stringx- the X positiony- the Y positioncolor- the text color
-
drawString
public static void drawString(net.minecraft.client.util.math.MatrixStack matrices, net.minecraft.text.OrderedText text, int x, int y, int color) Draws a left-aligned text component.- Parameters:
matrices- the rendering matrix stacktext- the text componentx- the X positiony- the Y positioncolor- the text color
-
drawTextHover
public static void drawTextHover(net.minecraft.client.util.math.MatrixStack matrices, @Nullable @Nullable net.minecraft.text.Style textStyle, int x, int y) Draws the text hover effects for a text style.This method has no effect when the caller is not in a LibGui screen. For example, there will be nothing drawn in HUDs.
- Parameters:
matrices- the rendering matrix stacktextStyle- the text stylex- the X positiony- the Y position- Since:
- 4.0.0
-
colorAtOpacity
public static int colorAtOpacity(int opaque, float opacity) -
multiplyColor
public static int multiplyColor(int color, float amount)
-