Expand description
Filling a box with an image that is bigger, or smaller, than the box.
Two questions this answers that a plain scale cannot. A tiled fill repeats its source instead of stretching it, which is how a texture, a hatch or a skin’s background covers an area of any size without going soft. And a nine-patch fill keeps the corners of a source at their own size while the edges and the middle grow, which is how a button, a panel or a scrollbar trough drawn once at one size is drawn correctly at every other.
Both are expressed the same way: a list of source-rectangle to destination-rectangle pairs, each of which is one ordinary image draw. That keeps the answer identical on every backend and, unlike a repeating sampler, cannot bleed a neighbouring sprite in from a shared atlas — the sprite an application tiles is usually a region of an atlas, and a wrapped sampler reads whatever is next to it.
Structs§
- Nine
Patch Insets - How far in from each edge of a source image the stretchable middle starts.
- Patch
Quad - One image draw: the part of the source to read and the part of the destination to fill.
Enums§
- Patch
Fill - How a region larger than its source is filled.
Functions§
- nine_
patch_ quads - The draws that fill
destinationwithsourceas a nine-patch. - tile_
count - How many tiles
tile_quadswould produce, without building them. - tile_
quads - The draws that tile
sourceacrossdestinationat the source’s own size.