Class GuiPaintContext

java.lang.Object
com.render.api.gui.GuiPaintContext

public final class GuiPaintContext extends Object
Public drawing surface supplied to custom GuiComponent leaf components.

Coordinates use the same design space as component layout. A paint context is only valid for the duration of GuiComponent.paint(GuiPaintContext) and must not be retained. RenderLib reuses the wrapper to avoid allocating one for every component and frame.

  • Method Details

    • bounds

      public GuiRect bounds()
      Returns this component's visual border box.
      Returns:
      immutable component bounds
    • contentBounds

      public GuiRect contentBounds()
      Returns the component box after border and padding have been removed.
      Returns:
      immutable content bounds
    • fill

      public void fill(RenderColor color)
    • fill

      public void fill(GuiRect rect, RenderColor color)
    • box

      public void box()
      Paints the component bounds with its resolved background, border, radius, and effects.
    • box

      public void box(GuiRect rect)
      Paints a rectangle with this component's resolved box style.
      Parameters:
      rect - rectangle to paint
    • box

      public void box(GuiPaintContext.BoxOptions options)
    • box

      public void box(GuiRect rect, GuiPaintContext.BoxOptions options)
      Paints a rectangle with explicit background, border, radius, opacity, and effects.
      Parameters:
      rect - rectangle to paint
      options - box styling options
    • measureTextWidth

      public float measureTextWidth(String text, GuiPaintContext.TextOptions options)
    • measureTextWidth

      public float measureTextWidth(net.minecraft.network.chat.Component text, GuiPaintContext.TextOptions options)
    • layoutText

      public GuiTextLayout layoutText(GuiRichText text, GuiTextConstraints constraints)
      Shapes typed rich text and returns all metrics and interaction geometry.
    • layoutText

      public GuiTextLayout layoutText(String text, GuiTextStyle style, GuiTextConstraints constraints)
    • measureText

      public GuiTextMetrics measureText(GuiRichText text, GuiTextConstraints constraints)
    • measureTextHeight

      public float measureTextHeight(String text, GuiPaintContext.TextOptions options)
    • measureTextHeight

      public float measureTextHeight(net.minecraft.network.chat.Component text, GuiPaintContext.TextOptions options)
    • drawText

      public void drawText(String text, float x, float y, GuiPaintContext.TextOptions options)
    • drawText

      public void drawText(net.minecraft.network.chat.Component text, float x, float y, GuiPaintContext.TextOptions options)
      Draws rich text at a design-space position.
      Parameters:
      text - text to draw
      x - left coordinate
      y - top coordinate
      options - text styling and optional wrapping width
    • drawText

      public void drawText(String text, float x, float y, GuiTextStyle style)
    • drawText

      public void drawText(GuiRichText text, float x, float y, GuiTextStyle style, GuiTextConstraints constraints)
    • pushClip

      public void pushClip(GuiRect rect)
      Pushes a clip rectangle. Clips are intersected with the active parent clip. Unbalanced pushes are automatically removed when the paint callback returns.
      Parameters:
      rect - rectangle to clip to
    • pushClip

      public void pushClip()
      Pushes the component's content bounds as a clip rectangle.
    • popClip

      public void popClip()
      Removes the most recent clip pushed by this custom paint callback.
    • mouseX

      public float mouseX()
    • mouseY

      public float mouseY()
    • timeSeconds

      public double timeSeconds()