Class NinePatchBackgroundPainter

java.lang.Object
io.github.cottonmc.cotton.gui.client.NinePatchBackgroundPainter
All Implemented Interfaces:
BackgroundPainter

@Environment(CLIENT) public final class NinePatchBackgroundPainter extends Object implements BackgroundPainter
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 can be created using BackgroundPainter.createNinePatch(Identifier), BackgroundPainter.createNinePatch(Texture, Consumer), or with the constructor directly. The latter two let you customise the look of the background more finely.

NinePatchBackgroundPainter has a customizable padding that can be applied. By default there is no padding, but you can set it using setPadding(int).

Since:
4.0.0
  • Constructor Details

    • NinePatchBackgroundPainter

      public NinePatchBackgroundPainter(juuxel.libninepatch.NinePatch<Identifier> ninePatch)
  • Method Details

    • getTopPadding

      public int getTopPadding()
    • setTopPadding

      public NinePatchBackgroundPainter setTopPadding(int topPadding)
    • getLeftPadding

      public int getLeftPadding()
    • setLeftPadding

      public NinePatchBackgroundPainter setLeftPadding(int leftPadding)
    • getBottomPadding

      public int getBottomPadding()
    • setBottomPadding

      public NinePatchBackgroundPainter setBottomPadding(int bottomPadding)
    • getRightPadding

      public int getRightPadding()
    • setRightPadding

      public NinePatchBackgroundPainter setRightPadding(int rightPadding)
    • setPadding

      public NinePatchBackgroundPainter setPadding(int padding)
    • setPadding

      public NinePatchBackgroundPainter setPadding(int vertical, int horizontal)
    • setPadding

      public NinePatchBackgroundPainter setPadding(int topPadding, int leftPadding, int bottomPadding, int rightPadding)
    • paintBackground

      public void paintBackground(DrawContext context, int left, int top, WWidget panel)
      Description copied from interface: BackgroundPainter
      Paint the specified panel to the screen.
      Specified by:
      paintBackground in interface BackgroundPainter
      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