Interface BackgroundPainter
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Background painters are used to paint the background of a widget.
The background painter instance of a widget can be changed to customize the look of a widget.
Nine-patch background painters
Nine-patch background painters paint rectangles using a special nine-patch texture. The texture is divided into nine sections: four corners, four edges and a center part. The edges and the center are either tiled or stretched, depending on the mode of the painter, to fill the area between the corners. By default, the texture is tiled.Nine-patch background painters are created using createNinePatch(Identifier) or
createNinePatch(Texture, Consumer). The latter lets you customise the look of
the background more finely.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic BackgroundPainterTheSLOTbackground painter draws item slots or slot-like widgets.static BackgroundPainterTheVANILLAbackground painter draws a vanilla-like GUI panel using nine-patch textures. -
Method Summary
Modifier and TypeMethodDescriptionstatic BackgroundPaintercreateColorful(int panelColor)Creates a colorful gui panel painter.static BackgroundPaintercreateColorful(int panelColor, float contrast)Creates a colorful gui panel painter that has a custom contrast between the shadows and highlights.static BackgroundPaintercreateLightDarkVariants(BackgroundPainter light, BackgroundPainter dark)Creates a background painter that uses either thelightor thedarkbackground painter depending on the current setting.static BackgroundPaintercreateNinePatch(Texture texture, Consumer<juuxel.libninepatch.NinePatch.Builder<net.minecraft.util.Identifier>> configurator)Creates a new nine-patch background painter with a custom configuration.static BackgroundPaintercreateNinePatch(net.minecraft.util.Identifier texture)Creates a new nine-patch background painter.voidpaintBackground(net.minecraft.client.util.math.MatrixStack matrices, int left, int top, WWidget panel)Paint the specified panel to the screen.
-
Field Details
-
VANILLA
TheVANILLAbackground painter draws a vanilla-like GUI panel using nine-patch textures.This background painter uses
libgui:textures/widget/panel_light.pngas the light texture andlibgui:textures/widget/panel_dark.pngas the dark texture.This background painter is the default painter for root panels. * You can override
GuiDescription.addPainters()to customize the painter yourself.- Since:
- 1.5.0
-
SLOT
TheSLOTbackground painter draws item slots or slot-like widgets.
-
-
Method Details
-
paintBackground
void paintBackground(net.minecraft.client.util.math.MatrixStack matrices, int left, int top, WWidget panel)Paint the specified panel to the screen.- Parameters:
left- The absolute position of the left of the panel, in gui-screen coordinatestop- The absolute position of the top of the panel, in gui-screen coordinatespanel- The panel being painted
-
createColorful
Creates a colorful gui panel painter. This painter paints the panel using the specified color.- Parameters:
panelColor- the panel background color- Returns:
- a colorful gui panel painter
- See Also:
ScreenDrawing.drawGuiPanel(MatrixStack, int, int, int, int, int)
-
createColorful
Creates a colorful gui panel painter that has a custom contrast between the shadows and highlights.- Parameters:
panelColor- the panel background colorcontrast- the contrast between the shadows and highlights- Returns:
- a colorful gui panel painter
-
createNinePatch
Creates a new nine-patch background painter.The resulting painter has a corner size of 4 px and a corner UV of 0.25.
- Parameters:
texture- the background painter texture- Returns:
- a new nine-patch background painter
- Since:
- 1.5.0
-
createNinePatch
static BackgroundPainter createNinePatch(Texture texture, Consumer<juuxel.libninepatch.NinePatch.Builder<net.minecraft.util.Identifier>> configurator)Creates a new nine-patch background painter with a custom configuration.- Parameters:
texture- the background painter textureconfigurator- a consumer that configures theNinePatch.Builder- Returns:
- the created nine-patch background painter
- Since:
- 4.0.0
- See Also:
NinePatch,NinePatch.Builder
-
createLightDarkVariants
Creates a background painter that uses either thelightor thedarkbackground painter depending on the current setting.- Parameters:
light- the light mode background painterdark- the dark mode background painter- Returns:
- a new background painter that chooses between the two inputs
- Since:
- 1.5.0
-