Class ScreenDrawing

java.lang.Object
io.github.cottonmc.cotton.gui.client.ScreenDrawing

public class ScreenDrawing extends Object
ScreenDrawing contains utility methods for drawing contents on a screen.
  • 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 context
      x - the x coordinate of the box on-screen
      y - the y coordinate of the box on-screen
      width - the width of the box on-screen
      height - the height of the box on-screen
      texture - the Identifier for the texture
      color - 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 context
      x - the x coordinate of the box on-screen
      y - the y coordinate of the box on-screen
      width - the width of the box on-screen
      height - the height of the box on-screen
      texture - the Identifier for the texture
      color - a color to tint the texture. This can be transparent! Use 0xFF_FFFFFF if you don't want a color tint
      opacity - 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 context
      x - the x coordinate of the box on-screen
      y - the y coordinate of the box on-screen
      width - the width of the box on-screen
      height - the height of the box on-screen
      texture - the Identifier for the texture
      u1 - the left edge of the texture
      v1 - the top edge of the texture
      u2 - the right edge of the texture
      v2 - the bottom edge of the texture
      color - 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 context
      x - the x coordinate of the box on-screen
      y - the y coordinate of the box on-screen
      width - the width of the box on-screen
      height - the height of the box on-screen
      texture - the texture
      color - 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 context
      x - the x coordinate of the box on-screen
      y - the y coordinate of the box on-screen
      width - the width of the box on-screen
      height - the height of the box on-screen
      texture - the texture
      color - a color to tint the texture. This can be transparent! Use 0xFF_FFFFFF if you don't want a color tint
      opacity - 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 context
      x - the x coordinate of the box on-screen
      y - the y coordinate of the box on-screen
      width - the width of the box on-screen
      height - the height of the box on-screen
      texture - the Identifier for the texture
      u1 - the left edge of the texture
      v1 - the top edge of the texture
      u2 - the right edge of the texture
      v2 - the bottom edge of the texture
      color - a color to tint the texture. This can be transparent! Use 0xFF_FFFFFF if you don't want a color tint
      opacity - 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 context
      x - the x coordinate of the box on-screen
      y - the y coordinate of the box on-screen
      width - the width of the box on-screen
      height - the height of the box on-screen
      texture - the Identifier for the texture
      textureX - the x offset into the texture
      textureY - the y offset into the texture
      color - 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 context
      left - the x coordinate of the box on-screen
      top - the y coordinate of the box on-screen
      width - the width of the box on-screen
      height - the height of the box on-screen
      texture - the Identifier for the texture
      color - 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

      public 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.
      Parameters:
      context - the draw context
      x - the X position of the panel
      y - the Y position of the panel
      width - the width of the panel
      height - 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 context
      x - the X position of the panel
      y - the Y position of the panel
      width - the width of the panel
      height - the height of the panel
      panelColor - 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 context
      x - the X position of the panel
      y - the Y position of the panel
      width - the width of the panel
      height - the height of the panel
      shadow - the bottom/right shadow ARGB color
      panel - the center ARGB color
      hilight - the top/left hilight ARGB color
      outline - the outline ARGB color
    • drawBeveledPanel

      public static void drawBeveledPanel(DrawContext context, int x, int y)
      Draws a default-sized recessed itemslot panel
    • drawBeveledPanel

      public static void drawBeveledPanel(DrawContext context, int x, int y, int width, int height)
      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 context
      x - x coordinate of the topleft corner
      y - y coordinate of the topleft corner
      width - width of the panel
      height - height of the panel
      topleft - color of the top/left bevel
      panel - color of the panel area
      bottomright - 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 context
      s - the string
      align - the alignment of the string
      x - the X position
      y - the Y position
      width - the width of the string, used for aligning
      color - 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 context
      text - the text
      align - the alignment of the string
      x - the X position
      y - the Y position
      width - the width of the string, used for aligning
      color - 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 context
      s - the string
      align - the alignment of the string
      x - the X position
      y - the Y position
      width - the width of the string, used for aligning
      color - 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 context
      text - the text component
      align - the alignment of the string
      x - the X position
      y - the Y position
      width - the width of the string, used for aligning
      color - the text color
    • drawString

      public static void drawString(DrawContext context, String s, int x, int y, int color)
      Draws a left-aligned string.
      Parameters:
      context - the draw context
      s - the string
      x - the X position
      y - the Y position
      color - the text color
    • drawString

      public static void drawString(DrawContext context, OrderedText text, int x, int y, int color)
      Draws a left-aligned text component.
      Parameters:
      context - the draw context
      text - the text component
      x - the X position
      y - the Y position
      color - 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 context
      textStyle - the text style
      x - the X position
      y - 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)