Interface BackgroundPainter
- All Known Implementing Classes:
NinePatchBackgroundPainter
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final BackgroundPainterTheSLOTbackground painter draws item slots or slot-like widgets.static final 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 BackgroundPaintercreateGuiSprite(Identifier texture) Creates a background painter that uses a texture from the GUI atlas.static BackgroundPaintercreateLightDarkVariants(BackgroundPainter light, BackgroundPainter dark) Creates a background painter that uses either thelightor thedarkbackground painter depending on the current setting.static NinePatchBackgroundPaintercreateNinePatch(Texture texture, Consumer<juuxel.libninepatch.NinePatch.Builder<Identifier>> configurator) Creates a new nine-patch background painter with a custom configuration.static NinePatchBackgroundPaintercreateNinePatch(Identifier texture) Creates a new nine-patch background painter.voidpaintBackground(DrawContext context, 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/gui/sprites/widget/panel_light.pngas the light texture andlibgui:textures/gui/sprites/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.For item slots, this painter uses
libgui:textures/widget/item_slot.png.
-
-
Method Details
-
paintBackground
Paint the specified panel to the screen.- Parameters:
context- The draw contextleft- 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:
-
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
- See Also:
-
createNinePatch
static NinePatchBackgroundPainter createNinePatch(Texture texture, Consumer<juuxel.libninepatch.NinePatch.Builder<Identifier>> configurator) Creates a new nine-patch background painter with a custom configuration.This method cannot be used for GUI sprites. Instead, you can use the vanilla nine-slice mechanism or use a standalone texture referring to the same file.
- Parameters:
texture- the background painter textureconfigurator- a consumer that configures theNinePatch.Builder- Returns:
- the created nine-patch background painter
- Throws:
IllegalArgumentException- when the texture is not standalone- Since:
- 4.0.0
- See Also:
-
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
-
createGuiSprite
Creates a background painter that uses a texture from the GUI atlas.This method can be used to draw tiled or nine-slice GUI sprites from resource packs as a simpler and more data-driven alternative to
createNinePatch(Identifier).- Parameters:
texture- the texture ID- Returns:
- a new background painter that uses a GUI sprite
- Since:
- 9.0.0
-