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
-
Field Summary
Fields inherited from interface io.github.cottonmc.cotton.gui.client.BackgroundPainter
SLOT, VANILLA
-
Constructor Summary
ConstructorDescriptionNinePatchBackgroundPainter
(juuxel.libninepatch.NinePatch<Identifier> ninePatch) -
Method Summary
Modifier and TypeMethodDescriptionint
int
int
int
void
paintBackground
(DrawContext context, int left, int top, WWidget panel) Paint the specified panel to the screen.setBottomPadding
(int bottomPadding) setLeftPadding
(int leftPadding) setPadding
(int padding) setPadding
(int vertical, int horizontal) setPadding
(int topPadding, int leftPadding, int bottomPadding, int rightPadding) setRightPadding
(int rightPadding) setTopPadding
(int topPadding)
-
Constructor Details
-
NinePatchBackgroundPainter
-
-
Method Details
-
getTopPadding
public int getTopPadding() -
setTopPadding
-
getLeftPadding
public int getLeftPadding() -
setLeftPadding
-
getBottomPadding
public int getBottomPadding() -
setBottomPadding
-
getRightPadding
public int getRightPadding() -
setRightPadding
-
setPadding
-
setPadding
-
setPadding
public NinePatchBackgroundPainter setPadding(int topPadding, int leftPadding, int bottomPadding, int rightPadding) -
paintBackground
Description copied from interface:BackgroundPainter
Paint the specified panel to the screen.- Specified by:
paintBackground
in interfaceBackgroundPainter
- 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
-