NinePatchImage
A 9-patch ("scale-9") stretchable background image: a source bitmap is sliced once (at construction) into 9 roRegions - 4 corners (drawn at fixed size), 4 edges (stretched along one axis), and a center (stretched both axes) - so a single small source texture can back a background of any width/height without visibly stretching its corners. Assign to Theme.backgroundImage to opt a widget's background fill into this instead of a flat color - see Theme.backgroundImage's own doc comment.
Takes a roBitmap, not a roRegion: CreateObject("roRegion", ...) only accepts a roBitmap as its source, not another roRegion (confirmed via Roku's own component type data and an actual runtime Type Mismatch when a roRegion was tried) - so slicing has to start from the real bitmap.
Properties
slices(object) — Slice name (see specs) -> roRegion, invalid if that slice's inset ' resolved to 0 (see makeSlice()).specs(object) — The 9 slice specs, computed once in new() and reused by draw() every ' frame - see NinePatchSliceSpec. A fixed, unchanging list, so building ' it once avoids 9 fresh AA allocations on every single draw() call.left(integer)top(integer)right(integer)bottom(integer)sourceWidth(integer)sourceHeight(integer)
Constructor
new NinePatchImage(
sourceBitmap: roBitmap,
left: integer,
top: integer,
right: integer,
bottom: integer,
): NinePatchImageParameters
sourceBitmap(roBitmap) — the full source imageleft(integer) — px from the left edge that stay unstretchedtop(integer) — px from the top edge that stay unstretchedright(integer) — px from the right edge that stay unstretchedbottom(integer) — px from the bottom edge that stay unstretched
Instance Methods
draw(
renderer: BGE.Renderer,
x: float,
y: float,
width: float,
height: float,
): void
Draws this 9-patch at (x, y) stretched to fill width x height. width/height must each be >= left+right / top+bottom respectively, or the edge/corner slices will overlap - same caveat as any 9-patch implementation.
Parameters
renderer(BGE.Renderer) — the renderer to draw tox(float) — destination xy(float) — destination ywidth(float) — destination widthheight(float) — destination height
Returns
void
getTopLeft(): roRegion
Test-only accessors - not part of the public API surface, no JSDoc.
Returns
roRegion
getCenter(): roRegion
Returns
roRegion
getLeft(): integer
Returns
integer
getTop(): integer
Returns
integer
getRight(): integer
Returns
integer
getBottom(): integer
Returns
integer