Class GuiPaintContext
java.lang.Object
com.render.api.gui.GuiPaintContext
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordImmutable options for a custom box paint operation.static final recordImmutable text drawing and measurement options. -
Method Summary
Modifier and TypeMethodDescriptionbounds()Returns this component's visual border box.voidbox()Paints the component bounds with its resolved background, border, radius, and effects.voidbox(GuiPaintContext.BoxOptions options) voidPaints a rectangle with this component's resolved box style.voidbox(GuiRect rect, GuiPaintContext.BoxOptions options) Paints a rectangle with explicit background, border, radius, opacity, and effects.Returns the component box after border and padding have been removed.voiddrawText(GuiRichText text, float x, float y, GuiTextStyle style, GuiTextConstraints constraints) voiddrawText(String text, float x, float y, GuiPaintContext.TextOptions options) voiddrawText(String text, float x, float y, GuiTextStyle style) voiddrawText(net.minecraft.network.chat.Component text, float x, float y, GuiPaintContext.TextOptions options) Draws rich text at a design-space position.voidfill(GuiRect rect, RenderColor color) voidfill(RenderColor color) layoutText(GuiRichText text, GuiTextConstraints constraints) Shapes typed rich text and returns all metrics and interaction geometry.layoutText(String text, GuiTextStyle style, GuiTextConstraints constraints) measureText(GuiRichText text, GuiTextConstraints constraints) floatmeasureTextHeight(String text, GuiPaintContext.TextOptions options) floatmeasureTextHeight(net.minecraft.network.chat.Component text, GuiPaintContext.TextOptions options) floatmeasureTextWidth(String text, GuiPaintContext.TextOptions options) floatmeasureTextWidth(net.minecraft.network.chat.Component text, GuiPaintContext.TextOptions options) floatmouseX()floatmouseY()voidpopClip()Removes the most recent clip pushed by this custom paint callback.voidpushClip()Pushes the component's content bounds as a clip rectangle.voidPushes a clip rectangle.double
-
Method Details
-
bounds
Returns this component's visual border box.- Returns:
- immutable component bounds
-
contentBounds
Returns the component box after border and padding have been removed.- Returns:
- immutable content bounds
-
fill
-
fill
-
box
public void box()Paints the component bounds with its resolved background, border, radius, and effects. -
box
Paints a rectangle with this component's resolved box style.- Parameters:
rect- rectangle to paint
-
box
-
box
Paints a rectangle with explicit background, border, radius, opacity, and effects.- Parameters:
rect- rectangle to paintoptions- box styling options
-
measureTextWidth
-
measureTextWidth
public float measureTextWidth(net.minecraft.network.chat.Component text, GuiPaintContext.TextOptions options) -
layoutText
Shapes typed rich text and returns all metrics and interaction geometry. -
layoutText
-
measureText
-
measureTextHeight
-
measureTextHeight
public float measureTextHeight(net.minecraft.network.chat.Component text, GuiPaintContext.TextOptions options) -
drawText
-
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 drawx- left coordinatey- top coordinateoptions- text styling and optional wrapping width
-
drawText
-
drawText
public void drawText(GuiRichText text, float x, float y, GuiTextStyle style, GuiTextConstraints constraints) -
pushClip
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()
-