Skip to content

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

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.

Call them on the node (self.node in its script, or self.node:get_node("path")). Every node also has the Node methods.

Reads an Inspector property by its path (vectors and colours as tables); “script.” reads a field of the node’s script.

local value = self.node:get_property("texturePath")
  • path NineSliceNodeProperty|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.” a field of the node’s script.

self.node:set_property("texturePath", "text")
  • path NineSliceNodeProperty|string
  • value any
  • y? number
{
"type": "NineSliceNode",
"name": "NineSliceSprite",
"position": [
0,
0
],
"properties": {
"texturePath": "",
"size": [
200,
100
],
"marginsLT": [
16,
16
]
}
}