Implementation of 9-slice scaling. There is currently no support for tiling, the sub-images are scaled to the size of the target tiles.
To enable 9-slice scaling in the theme:
- set
textureBgto the Kha asset name of the background image - set the
atlasvalues according to the inner (center) slice - set
border.nineSlicetotrue
Static methods
staticcreateSlices(imgInnerSlice:Rect, imgWidth:FastFloat, imgHeight:FastFloat, elemWidth:FastFloat, elemHeight:FastFloat):Vector<Vector<Rect>>
Creates the individual slice rectangles required for rendering, used internally most of the time.
It returns a vector of two Vector<Rect>:
- the first vector holds source image slices (not scaled) to be used as texture coordinates
- the second vector holds element slices (scaled to target) to be used for the actual scaled drawing
Parameters:
imgInnerSlice | A rectangle defining the inner slice of the source image |
|---|---|
imgWidth | The width of the source image |
imgHeight | The height of the source image |
elemWidth | The width of the element to which 9-slice scaling should be applied |
elemHeight | The height of the element to which 9-slice scaling should be applied |