API Ninepatch - shmellyorc/Box GitHub Wiki
Ninepatch
Namespace: Box.Entities.Graphics
Description
Represents a nine-patch entity used for scalable UI elements. Splits a source texture region into nine segments (four corners, four edges, and center) and scales each appropriately when rendered to preserve corner fidelity while allowing flexible sizing.
Constructor
public Ninepatch(Surface surface, Rect2 source, Rect2 corners);
public Ninepatch(Surface surface, Spritesheet sheet, string name);
These constructors initialize the nine-patch by storing the source rect and corner dimensions, then populating internal patch arrays via UpdateNinePatch
.
Properties
Property | Description |
---|---|
BoxColor Color |
Tint color applied to all patches when rendering. |
Methods
Method Signature | Description | Returns |
---|---|---|
protected override void Update() |
Recalculates patch bounds if Position or Size changed, then draws the nine patches and an optional debug outline using the current Color . |
void |
Examples
var ninepatch = new Ninepatch(mySurface, new Rect2(0, 0, 64, 64), new Rect2(8, 8, 8, 8))
{
Position = new Vect2(100, 100),
Size = new Vect2(200, 150),
Color = BoxColor.AllShades.White
};
mainScreen.AddEntity(ninepatch);