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 textureBg to the Kha asset name of the background image
  • set the atlas values according to the inner (center) slice
  • set border.nineSlice to true

Static methods

privatestatic_createElemSlices(imageSlices:Vector<Rect>, targetWidth:FastFloat, targetHeight:FastFloat):Vector<Rect>

privatestatic_createImageSlices(innerSlice:Rect, targetWidth:FastFloat, targetHeight:FastFloat):Vector<Rect>

privatestatic_createSlices(left:FastFloat, right:FastFloat, top:FastFloat, bottom:FastFloat, width:FastFloat, height:FastFloat, targetWidth:FastFloat, targetHeight:FastFloat):Vector<Rect>

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