Interface GuiPainter


public interface GuiPainter
Draws one frame of the GUI in GUI-scaled pixels.
Later calls draw over earlier ones wherever they overlap. Drawing is batched behind the scenes, and clips, opacity, transforms, fonts and text sizes can change between any two calls without making it slower.
  • Method Summary

    Modifier and Type
    Method
    Description
    float
     
    void
    backdropBlur(double x, double y, double width, double height, double radius, int corners, int strength)
    Blurs what is already on screen inside a rounded rectangle, like frosted glass behind a panel.
     
    void
    circle(double x, double y, double diameter, GuiPaint paint)
    A filled circle whose bounding square starts at (x, y).
    void
    Draws an outline around everything added to outlineMask() since the last call, then clears the mask.
     
    void
    gradient(double x, double y, double width, double height, GuiPaint topLeft, GuiPaint topRight, GuiPaint bottomRight, GuiPaint bottomLeft)
    A rectangle with a color per corner, for gradients in two directions such as a color picker's square.
    void
    icon(GuiIcon icon, double x, double y, double scale, GuiPaint paint, boolean shadow)
     
    double
    iconHeight(double scale, boolean shadow)
     
    double
    iconWidth(GuiIcon icon, double scale)
     
    default void
    image(GuiImage image, double x, double y, double size)
    Draws an image in a square of size.
    default void
    image(GuiImage image, double x, double y, double width, double height)
    Draws an image in a rectangle.
    default void
    image(GuiImage image, double x, double y, double width, double height, GuiPaint paint)
    Draws an image in a rectangle, as image(GuiImage, double, double, double, double).
    void
    image(GuiImage image, double x, double y, double width, double height, GuiPaint paint, boolean shadow)
    Draws an image in a rectangle, as image(GuiImage, double, double, double, double).
    void
    image(GuiImage image, double x, double y, double width, double height, GuiPaint paint, boolean shadow, double degrees)
    Draws an image in a rectangle, as image(GuiImage, double, double, double, double, GuiPaint, boolean), turned around the rectangle's center.
    void
    line(double x1, double y1, double x2, double y2, GuiPaint paint)
    A one pixel line.
     
    void
     
    void
     
    void
     
    void
     
    void
     
    void
     
    void
    pushAlpha(float alpha)
    Multiplies the opacity of later drawing.
    void
    pushBackdrop(int strength)
    Blurs what is already on screen once, and shows it until the matching popBackdrop() inside the shapes added to backdropMask(), under everything drawn in between.
    void
    pushBackdrop(int strength, boolean soft)
    void
    pushClip(double x, double y, double width, double height)
    Clips later drawing, outline masks included, to a rectangle intersected with the current clip.
    void
    pushLayer(float alpha)
    Draws everything until the matching popLayer() as one image, blended in at alpha, so shapes that overlap inside the layer fade together instead of showing through each other.
    void
    pushTextGlow(int spread, float strength)
    Makes text and icons drawn until the matching popTextGlow() glow in their own colors.
    void
    pushTransform(double translateX, double translateY, double scale)
    Moves and scales later drawing: a point (x, y) lands at (translateX + x * scale, translateY + y * scale) in the current transform.
    void
    rect(double x, double y, double width, double height, int argb)
     
    void
    rect(double x, double y, double width, double height, GuiPaint paint)
     
    void
    roundRect(double x, double y, double width, double height, double radius, int corners, int argb)
     
    void
    roundRect(double x, double y, double width, double height, double radius, int corners, GuiPaint paint)
     
    void
    Sets the font later text uses.
    void
    shadow(double x, double y, double width, double height, double radius, double reach, GuiPaint paint)
    A soft glow or shadow around a rounded rectangle, strongest at its edge and fading out reach past it.
    void
    strokeCircle(double x, double y, double diameter, double thickness, GuiPaint paint)
    A circle's outline, drawn inside the circle whose bounding square starts at (x, y).
    void
    strokeRect(double x, double y, double width, double height, double thickness, GuiPaint paint)
    A rectangle's outline, drawn inside its bounds.
    void
    strokeRoundRect(double x, double y, double width, double height, double radius, int corners, double thickness, GuiPaint paint)
    A rounded rectangle's outline, drawn inside its bounds.
    double
    text(String text, double x, double y, double scale, int argb, boolean shadow)
     
    double
    text(String text, double x, double y, double scale, GuiPaint paint, boolean shadow)
    Draws text with its top-left at (x, y) in the current font.
    double
    text(net.minecraft.network.chat.Component text, double x, double y, double scale, GuiPaint paint, boolean shadow)
    Draws formatted text.
    double
    textBaseline(double scale)
     
    double
    textCapHeight(double scale)
     
    double
    textHeight(double scale, boolean shadow)
     
    double
    textWidth(String text, double scale, boolean shadow)
     
  • Method Details

    • rect

      void rect(double x, double y, double width, double height, GuiPaint paint)
    • rect

      void rect(double x, double y, double width, double height, int argb)
    • roundRect

      void roundRect(double x, double y, double width, double height, double radius, int corners, GuiPaint paint)
      Parameters:
      radius - Corner radius, clamped to half the shorter side
      corners - Which corners are rounded, see Corners
    • roundRect

      void roundRect(double x, double y, double width, double height, double radius, int corners, int argb)
    • gradient

      void gradient(double x, double y, double width, double height, GuiPaint topLeft, GuiPaint topRight, GuiPaint bottomRight, GuiPaint bottomLeft)
      A rectangle with a color per corner, for gradients in two directions such as a color picker's square. For a gradient between two colors on any shape, fill it with GuiPaint.horizontal(GuiPaint, GuiPaint) or GuiPaint.vertical(GuiPaint, GuiPaint). Gradient client colors cannot be used here.
    • circle

      void circle(double x, double y, double diameter, GuiPaint paint)
      A filled circle whose bounding square starts at (x, y).
    • strokeRect

      void strokeRect(double x, double y, double width, double height, double thickness, GuiPaint paint)
      A rectangle's outline, drawn inside its bounds.
      Parameters:
      thickness - Outline width; half the shorter side or more fills the rectangle
    • strokeRoundRect

      void strokeRoundRect(double x, double y, double width, double height, double radius, int corners, double thickness, GuiPaint paint)
      A rounded rectangle's outline, drawn inside its bounds. Rounded corners get arcs that follow the outer edge.
      Parameters:
      radius - Corner radius, clamped to half the shorter side
      corners - Which corners are rounded, see Corners
      thickness - Outline width; half the shorter side or more fills the shape
    • strokeCircle

      void strokeCircle(double x, double y, double diameter, double thickness, GuiPaint paint)
      A circle's outline, drawn inside the circle whose bounding square starts at (x, y).
    • shadow

      void shadow(double x, double y, double width, double height, double radius, double reach, GuiPaint paint)
      A soft glow or shadow around a rounded rectangle, strongest at its edge and fading out reach past it. Nothing is drawn inside the rectangle, so it suits see-through panels. It is drawn in order like any shape, with smooth edges and no extra passes, so for a glow around one panel it is cheaper and smoother than drawOutline(OutlineStyle), which follows any shapes in the outline mask.
      Parameters:
      radius - Corner radius, clamped to half the shorter side
      reach - How far it reaches past the edge
    • line

      void line(double x1, double y1, double x2, double y2, GuiPaint paint)
      A one pixel line.
    • text

      double text(String text, double x, double y, double scale, GuiPaint paint, boolean shadow)
      Draws text with its top-left at (x, y) in the current font.
      Returns:
      The drawn width
    • text

      double text(String text, double x, double y, double scale, int argb, boolean shadow)
    • text

      double text(net.minecraft.network.chat.Component text, double x, double y, double scale, GuiPaint paint, boolean shadow)
      Draws formatted text. Styles with their own color override paint.
      Returns:
      The drawn width
    • textWidth

      double textWidth(String text, double scale, boolean shadow)
    • textHeight

      double textHeight(double scale, boolean shadow)
    • textBaseline

      double textBaseline(double scale)
      Returns:
      How far below the top of a line of text its baseline is, in the current font
      See Also:
    • textCapHeight

      double textCapHeight(double scale)
      Returns:
      How far above the baseline capitals reach, in the current font
      See Also:
    • icon

      void icon(GuiIcon icon, double x, double y, double scale, GuiPaint paint, boolean shadow)
    • iconWidth

      double iconWidth(GuiIcon icon, double scale)
    • iconHeight

      double iconHeight(double scale, boolean shadow)
    • image

      default void image(GuiImage image, double x, double y, double size)
      Draws an image in a square of size. See GuiImage.deferred().
    • image

      default void image(GuiImage image, double x, double y, double width, double height)
      Draws an image in a rectangle. Textures stretch to fill it; items, sprites and vector images keep their shape, as large as fits, centered in it. Vector images are white.
    • image

      default void image(GuiImage image, double x, double y, double width, double height, GuiPaint paint)
      Draws an image in a rectangle, as image(GuiImage, double, double, double, double).
      Parameters:
      paint - What a vector image is filled with, or null for white. Other images ignore it.
    • image

      void image(GuiImage image, double x, double y, double width, double height, GuiPaint paint, boolean shadow)
      Draws an image in a rectangle, as image(GuiImage, double, double, double, double).
      Parameters:
      paint - What a vector image is filled with, or null for white. Other images ignore it.
      shadow - Whether a vector image casts the shadow text does. Other images ignore it.
    • image

      void image(GuiImage image, double x, double y, double width, double height, GuiPaint paint, boolean shadow, double degrees)
      Draws an image in a rectangle, as image(GuiImage, double, double, double, double, GuiPaint, boolean), turned around the rectangle's center.
      Parameters:
      degrees - How far the image is turned, clockwise
    • pushClip

      void pushClip(double x, double y, double width, double height)
      Clips later drawing, outline masks included, to a rectangle intersected with the current clip.
    • popClip

      void popClip()
    • pushAlpha

      void pushAlpha(float alpha)
      Multiplies the opacity of later drawing.
    • popAlpha

      void popAlpha()
    • alpha

      float alpha()
      Returns:
      The current opacity multiplier
    • pushTransform

      void pushTransform(double translateX, double translateY, double scale)
      Moves and scales later drawing: a point (x, y) lands at (translateX + x * scale, translateY + y * scale) in the current transform.
    • popTransform

      void popTransform()
    • pushLayer

      void pushLayer(float alpha)
      Draws everything until the matching popLayer() as one image, blended in at alpha, so shapes that overlap inside the layer fade together instead of showing through each other. A layer costs a copy of the screen; where nothing overlaps, pushAlpha(float) looks the same. Items and sprites (GuiImage.deferred()) are not part of a layer. Layers nest.
      Parameters:
      alpha - Opacity of the layer, 0 to 1
    • popLayer

      void popLayer()
    • backdropBlur

      void backdropBlur(double x, double y, double width, double height, double radius, int corners, int strength)
      Blurs what is already on screen inside a rounded rectangle, like frosted glass behind a panel. Later drawing goes on top, so draw the panel's fill after this, partly see-through, for the blur to show. Each call costs a few full-screen passes: blur a handful of panels, not every row.
      Parameters:
      radius - Corner radius, clamped to half the shorter side
      corners - Which corners are rounded, see Corners
      strength - How blurry, 1 to 8
    • pushBackdrop

      void pushBackdrop(int strength)
      Blurs what is already on screen once, and shows it until the matching popBackdrop() inside the shapes added to backdropMask(), under everything drawn in between. For several panels this costs one backdropBlur(double, double, double, double, double, int, int), where a call per panel blurs the screen once each. Panels inside see the screen as it was at the push, not each other.
      Shapes can be added at any point before the pop, except that a layer, an outline or a backdropBlur(double, double, double, double, double, int, int) inside draws everything queued so far: add the shapes under that drawing before it. Backdrops do not nest; an inner push and pop do nothing.
      Parameters:
      strength - How blurry, 1 to 8
    • pushBackdrop

      void pushBackdrop(int strength, boolean soft)
      As pushBackdrop(int). With soft, the blur fades out past the edges of the shapes as far as it spreads, instead of stopping at them, the way blurring the shapes themselves looks. Use it to blur something already drawn, such as panels behind a popup: push it after drawing them, add their shapes and pop it with nothing drawn in between. Soft costs a second blur, of the mask.
      Parameters:
      strength - How blurry, 1 to 8
    • backdropMask

      GuiMask backdropMask()
      Returns:
      Where the backdrop started by pushBackdrop(int) shows
    • popBackdrop

      void popBackdrop()
    • pushTextGlow

      void pushTextGlow(int spread, float strength)
      Makes text and icons drawn until the matching popTextGlow() glow in their own colors. The glow can reach past clips. Text drawn with the vanilla font, and characters that font draws for Boze's fonts, do not glow. Glows nest; the innermost applies.
      Parameters:
      spread - How far the glow reaches, 1 to 6
      strength - How bright it is, 0 to 1. 0.5 is as bright as the HUD's text bloom at its default brightness
    • popTextGlow

      void popTextGlow()
    • outlineMask

      GuiMask outlineMask()
      Returns:
      Silhouettes the next drawOutline(OutlineStyle) draws around
    • drawOutline

      void drawOutline(OutlineStyle style)
      Draws an outline around everything added to outlineMask() since the last call, then clears the mask.
    • setFont

      void setFont(GuiFont font)
      Sets the font later text uses. Each frame starts with GuiFonts.gui().
    • font

      GuiFont font()