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 int
colorAtOpacity
(int opaque, float opacity) static void
coloredRect
(DrawContext context, int left, int top, int width, int height, int color) Draws an untextured rectangle of the specified RGB color.static void
drawBeveledPanel
(DrawContext context, int x, int y) Draws a default-sized recessed itemslot panelstatic void
drawBeveledPanel
(DrawContext context, int x, int y, int width, int height) Draws a default-color recessed itemslot panel of variable sizestatic void
drawBeveledPanel
(DrawContext context, int x, int y, int width, int height, int topleft, int panel, int bottomright) Draws a generalized-case beveled panel.static void
drawGuiPanel
(DrawContext context, int x, int y, int width, int height) Draws a beveled, round rectangle that is substantially similar to default Minecraft UI panels.static void
drawGuiPanel
(DrawContext context, 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 void
drawGuiPanel
(DrawContext context, 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 void
drawString
(DrawContext context, String s, int x, int y, int color) Draws a left-aligned string.static void
drawString
(DrawContext context, String s, HorizontalAlignment align, int x, int y, int width, int color) Draws a string with a custom alignment.static void
drawString
(DrawContext context, OrderedText text, int x, int y, int color) Draws a left-aligned text component.static void
drawString
(DrawContext context, OrderedText text, HorizontalAlignment align, int x, int y, int width, int color) Draws a text component with a custom alignment.static void
drawStringWithShadow
(DrawContext context, String s, HorizontalAlignment align, int x, int y, int width, int color) Draws a shadowed string.static void
drawStringWithShadow
(DrawContext context, OrderedText text, HorizontalAlignment align, int x, int y, int width, int color) Draws a shadowed text component.static void
drawTextHover
(DrawContext context, @Nullable Style textStyle, int x, int y) Draws the text hover effects for a text style.static int
multiplyColor
(int color, float amount) static void
texturedGuiRect
(DrawContext context, int left, int top, int width, int height, Identifier texture, int color) Draws a textured rectangle with UV values based on the width and height.static void
texturedGuiRect
(DrawContext context, int x, int y, int width, int height, Identifier texture, int textureX, int textureY, int color) Draws a textured rectangle with UV values based on the width and height.static void
texturedRect
(DrawContext context, int x, int y, int width, int height, Texture texture, int color) Draws a textured rectangle.static void
texturedRect
(DrawContext context, int x, int y, int width, int height, Texture texture, int color, float opacity) Draws a textured rectangle.static void
texturedRect
(DrawContext context, int x, int y, int width, int height, Identifier texture, float u1, float v1, float u2, float v2, int color) Draws a textured rectangle.static void
texturedRect
(DrawContext context, int x, int y, int width, int height, Identifier texture, float u1, float v1, float u2, float v2, int color, float opacity) Draws a textured rectangle.static void
texturedRect
(DrawContext context, int x, int y, int width, int height, Identifier texture, int color) Draws a textured rectangle.static void
texturedRect
(DrawContext context, int x, int y, int width, int height, Identifier texture, int color, float opacity) Draws a textured rectangle.
-
Method Details
-
texturedRect
public static void texturedRect(DrawContext context, int x, int y, int width, int height, Identifier texture, int color) Draws a textured rectangle.- Parameters:
context
- the draw contextx
- 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(DrawContext context, int x, int y, int width, int height, Identifier texture, int color, float opacity) Draws a textured rectangle.- Parameters:
context
- the draw contextx
- 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(DrawContext context, int x, int y, int width, int height, Identifier texture, float u1, float v1, float u2, float v2, int color) Draws a textured rectangle.- Parameters:
context
- the draw contextx
- 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(DrawContext context, int x, int y, int width, int height, Texture texture, int color) Draws a textured rectangle.- Parameters:
context
- the draw contextx
- 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(DrawContext context, int x, int y, int width, int height, Texture texture, int color, float opacity) Draws a textured rectangle.- Parameters:
context
- the draw contextx
- 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(DrawContext context, int x, int y, int width, int height, Identifier texture, float u1, float v1, float u2, float v2, int color, float opacity) Draws a textured rectangle.- Parameters:
context
- the draw contextx
- 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(DrawContext context, int x, int y, int width, int height, 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:
context
- the draw contextx
- 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(DrawContext context, int left, int top, int width, int height, 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:
context
- the draw contextleft
- 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(DrawContext context, int left, int top, int width, int height, int color) Draws an untextured rectangle of the specified RGB color. -
drawGuiPanel
Draws a beveled, round rectangle that is substantially similar to default Minecraft UI panels.- Parameters:
context
- the draw contextx
- 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(DrawContext context, 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:
context
- the draw contextx
- 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(DrawContext context, 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:
context
- the draw contextx
- 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
Draws a default-sized recessed itemslot panel -
drawBeveledPanel
Draws a default-color recessed itemslot panel of variable size -
drawBeveledPanel
public static void drawBeveledPanel(DrawContext context, 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:
context
- the draw contextx
- 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(DrawContext context, String s, HorizontalAlignment align, int x, int y, int width, int color) Draws a string with a custom alignment.- Parameters:
context
- the draw contexts
- 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(DrawContext context, OrderedText text, HorizontalAlignment align, int x, int y, int width, int color) Draws a text component with a custom alignment.- Parameters:
context
- the draw contexttext
- 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(DrawContext context, String s, HorizontalAlignment align, int x, int y, int width, int color) Draws a shadowed string.- Parameters:
context
- the draw contexts
- 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(DrawContext context, OrderedText text, HorizontalAlignment align, int x, int y, int width, int color) Draws a shadowed text component.- Parameters:
context
- the draw contexttext
- 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
Draws a left-aligned string.- Parameters:
context
- the draw contexts
- the stringx
- the X positiony
- the Y positioncolor
- the text color
-
drawString
Draws a left-aligned text component.- Parameters:
context
- the draw contexttext
- the text componentx
- the X positiony
- the Y positioncolor
- the text color
-
drawTextHover
public static void drawTextHover(DrawContext context, @Nullable @Nullable 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:
context
- the draw contexttextStyle
- 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)
-