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.

@FunctionalInterface public interface BackgroundPainter
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.
  • Field Details

    • VANILLA

      static final BackgroundPainter VANILLA
      The VANILLA background painter draws a vanilla-like GUI panel using nine-patch textures.

      This background painter uses libgui:textures/gui/sprites/widget/panel_light.png as the light texture and libgui:textures/gui/sprites/widget/panel_dark.png as 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

      static final BackgroundPainter SLOT
      The SLOT background painter draws item slots or slot-like widgets.

      For item slots, this painter uses libgui:textures/widget/item_slot.png.

  • Method Details

    • paintBackground

      void paintBackground(DrawContext context, int left, int top, WWidget panel)
      Paint the specified panel to the screen.
      Parameters:
      context - The draw context
      left - The absolute position of the left of the panel, in gui-screen coordinates
      top - The absolute position of the top of the panel, in gui-screen coordinates
      panel - The panel being painted
    • createColorful

      static BackgroundPainter createColorful(int panelColor)
      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

      static BackgroundPainter createColorful(int panelColor, float contrast)
      Creates a colorful gui panel painter that has a custom contrast between the shadows and highlights.
      Parameters:
      panelColor - the panel background color
      contrast - the contrast between the shadows and highlights
      Returns:
      a colorful gui panel painter
    • createNinePatch

      static NinePatchBackgroundPainter createNinePatch(Identifier texture)
      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 texture
      configurator - a consumer that configures the NinePatch.Builder
      Returns:
      the created nine-patch background painter
      Throws:
      IllegalArgumentException - when the texture is not standalone
      Since:
      4.0.0
      See Also:
    • createLightDarkVariants

      static BackgroundPainter createLightDarkVariants(BackgroundPainter light, BackgroundPainter dark)
      Creates a background painter that uses either the light or the dark background painter depending on the current setting.
      Parameters:
      light - the light mode background painter
      dark - the dark mode background painter
      Returns:
      a new background painter that chooses between the two inputs
      Since:
      1.5.0
    • createGuiSprite

      static BackgroundPainter createGuiSprite(Identifier texture)
      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