What is 9-slice (nine-patch) scaling?
A way to stretch a UI panel or button to any size by cutting it into 9 parts: the corners never scale, the edges stretch in one direction and the centre fills the rest.
You set four margins (left, top, right, bottom) that mark the corners. The result keeps crisp borders at any size, so one small image serves every dialog box. Godot uses NinePatchRect or a StyleBoxTexture with texture margins; Unity sets the border in the Sprite Editor and uses an Image of type Sliced.
For pixel art, keep the stretch mode on tile rather than stretch if the edge has a pattern, and keep the panel size a multiple of the pattern.
Sources
Related terms
- Nearest-neighbour filtering (pixel-perfect)Texture sampling that takes the closest pixel instead of blending neighbours, which keeps pixel art sharp when it is scaled up.
- Texture atlasA single large texture packing many unrelated images (icons, UI pieces, props) so the game can draw them without switching textures.