Nine Slice Sprite
A texture stretched to any size while its borders keep their size (panels, buttons, frames).
Type: NineSliceNode · Category: Graphics & Rendering · Also found as: nineslice, ninepatch
Properties
Section titled “Properties”| Property | Type | Default | Description |
|---|---|---|---|
texturePath |
string | "" |
Texture to slice. |
size |
vec2 | (200, 100) |
Drawn size (px); the borders keep their size, the middle stretches. Range 1 to 4000. |
marginsLT |
vec2 | (16, 16) |
Left and top border widths (texture px). Range 0 to 512. |
marginsRB |
vec2 | (16, 16) |
Right and bottom border widths (texture px). Range 0 to 512. |
tint |
color | #ffffffff |
Multiplies the texture’s colours (white = unchanged; alpha fades it). |
Plus the common properties every node has.
Lua methods
Section titled “Lua methods”Call them on the node (self.node in its script, or self.node:get_node("path")). Every node also has the Node methods.
NineSliceNode:get_property(path)
Section titled “NineSliceNode:get_property(path)”Reads an Inspector property by its path (vectors and colours as tables); “script.
local value = self.node:get_property("texturePath")pathNineSliceNodeProperty|string
Returns any
NineSliceNode:set_property(path, value, y)
Section titled “NineSliceNode:set_property(path, value, y)”Sets an Inspector property by its path: vectors as {x, y} or x, y; colours as {r, g, b[, a]} 0..1 or “#rrggbb[aa]”; enums by name; “script.
self.node:set_property("texturePath", "text")pathNineSliceNodeProperty|stringvalueanyy?number
In a scene file
Section titled “In a scene file”{ "type": "NineSliceNode", "name": "NineSliceSprite", "position": [ 0, 0 ], "properties": { "texturePath": "", "size": [ 200, 100 ], "marginsLT": [ 16, 16 ] }}