Skip to main content

Function: computeNineSliceRegions()

computeNineSliceRegions(width, height, pivot, uvOffset, uvScale, slices): NineSliceRegion[]

Defined in: rendering/utilities/compute-nine-slice-regions.ts:226

Computes the nine-slice regions for a sprite, given its current size, and cuts each stretching band into tiled segments where its mode is 'tile'.

Corner regions are always a single, fixed-size quad. Edge regions stretch or tile along their one free axis (edgeMode); the center region stretches or tiles along both axes (centerMode). A border with an inset of 0 (the default for any axis with no slicing) collapses to just its center band, so a sprite with no insets at all degenerates to the single region a non-sliced sprite would render.

Parameters​

width​

number

The sprite's current width, in unscaled sprite-space units.

height​

number

The sprite's current height, in unscaled sprite-space units.

pivot​

Vector2

The sprite's pivot, normalized to its own size and Y-up ((0, 0) is bottom-left, (1, 1) is top-right), matching SpriteEcsComponent.pivot.

uvOffset​

Vector2

The sprite's texture rect offset, 0 to 1.

uvScale​

Vector2

The sprite's texture rect size, 0 to 1.

slices​

NineSliceOptions

The nine-slice configuration.

Returns​

NineSliceRegion[]

Up to nine regions, each a quad to draw in place of the sprite's single quad.