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.
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 TypeMethodDescriptionfloatalpha()voidbackdropBlur(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.voidA filled circle whose bounding square starts at (x, y).voiddrawOutline(OutlineStyle style) Draws an outline around everything added tooutlineMask()since the last call, then clears the mask.font()voidgradient(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.voiddoubleiconHeight(double scale, boolean shadow) doubledefault voidDraws an image in a square ofsize.default voidDraws an image in a rectangle.default voidDraws an image in a rectangle, asimage(GuiImage, double, double, double, double).voidimage(GuiImage image, double x, double y, double width, double height, GuiPaint paint, boolean shadow) Draws an image in a rectangle, asimage(GuiImage, double, double, double, double).voidimage(GuiImage image, double x, double y, double width, double height, GuiPaint paint, boolean shadow, double degrees) Draws an image in a rectangle, asimage(GuiImage, double, double, double, double, GuiPaint, boolean), turned around the rectangle's center.voidA one pixel line.voidpopAlpha()voidvoidpopClip()voidpopLayer()voidvoidvoidpushAlpha(float alpha) Multiplies the opacity of later drawing.voidpushBackdrop(int strength) Blurs what is already on screen once, and shows it until the matchingpopBackdrop()inside the shapes added tobackdropMask(), under everything drawn in between.voidpushBackdrop(int strength, boolean soft) voidpushClip(double x, double y, double width, double height) Clips later drawing, outline masks included, to a rectangle intersected with the current clip.voidpushLayer(float alpha) Draws everything until the matchingpopLayer()as one image, blended in atalpha, so shapes that overlap inside the layer fade together instead of showing through each other.voidpushTextGlow(int spread, float strength) Makes text and icons drawn until the matchingpopTextGlow()glow in their own colors.voidpushTransform(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.voidrect(double x, double y, double width, double height, int argb) voidvoidroundRect(double x, double y, double width, double height, double radius, int corners, int argb) voidroundRect(double x, double y, double width, double height, double radius, int corners, GuiPaint paint) voidSets the font later text uses.voidshadow(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 outreachpast it.voidstrokeCircle(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).voidstrokeRect(double x, double y, double width, double height, double thickness, GuiPaint paint) A rectangle's outline, drawn inside its bounds.voidstrokeRoundRect(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.doubledoubleDraws text with its top-left at (x, y) in the current font.doubletext(net.minecraft.network.chat.Component text, double x, double y, double scale, GuiPaint paint, boolean shadow) Draws formatted text.doubletextBaseline(double scale) doubletextCapHeight(double scale) doubletextHeight(double scale, boolean shadow) double
-
Method Details
-
rect
-
rect
void rect(double x, double y, double width, double height, int argb) -
roundRect
-
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 withGuiPaint.horizontal(GuiPaint, GuiPaint)orGuiPaint.vertical(GuiPaint, GuiPaint). Gradient client colors cannot be used here. -
circle
A filled circle whose bounding square starts at (x, y). -
strokeRect
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 sidecorners- Which corners are rounded, seeCornersthickness- Outline width; half the shorter side or more fills the shape
-
strokeCircle
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 outreachpast 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 thandrawOutline(OutlineStyle), which follows any shapes in the outline mask.- Parameters:
radius- Corner radius, clamped to half the shorter sidereach- How far it reaches past the edge
-
line
A one pixel line. -
text
-
text
-
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 overridepaint.- Returns:
- The drawn width
-
textWidth
-
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
-
iconWidth
-
iconHeight
double iconHeight(double scale, boolean shadow) -
image
Draws an image in a square ofsize. SeeGuiImage.deferred(). -
image
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
Draws an image in a rectangle, asimage(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, asimage(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, asimage(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 matchingpopLayer()as one image, blended in atalpha, 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 sidecorners- Which corners are rounded, seeCornersstrength- How blurry, 1 to 8
-
pushBackdrop
void pushBackdrop(int strength) Blurs what is already on screen once, and shows it until the matchingpopBackdrop()inside the shapes added tobackdropMask(), under everything drawn in between. For several panels this costs onebackdropBlur(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 abackdropBlur(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) AspushBackdrop(int). Withsoft, 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 matchingpopTextGlow()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 6strength- 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
Draws an outline around everything added tooutlineMask()since the last call, then clears the mask. -
setFont
Sets the font later text uses. Each frame starts withGuiFonts.gui(). -
font
GuiFont font()
-