Table of Contents

Class NinePatchRect

A control that displays a texture by keeping its corners intact, but tiling its edges and center.

Inheritance
NinePatchRect

Remarks

Also known as 9-slice panels, NinePatchRect produces clean panels of any size based on a small texture. To do so, it splits the texture in a 3×3 grid. When you scale the node, it tiles the texture's edges horizontally or vertically, tiles the center on both axes, and leaves the corners unchanged.

Properties

axis_stretch_horizontal

The stretch mode to use for horizontal stretching/tiling. See AxisStretchMode for possible values.

var axis_stretch_horizontal : int = 0

Property Value

int

Remarks

  • void set_h_axis_stretch_mode(int value)
  • int get_h_axis_stretch_mode

axis_stretch_vertical

The stretch mode to use for vertical stretching/tiling. See AxisStretchMode for possible values.

var axis_stretch_vertical : int = 0

Property Value

int

Remarks

  • void set_v_axis_stretch_mode(int value)
  • int get_v_axis_stretch_mode

draw_center

If true, draw the panel's center. Else, only draw the 9-slice's borders.

var draw_center : bool = true

Property Value

bool

Remarks

  • void set_draw_center(bool value)
  • bool is_draw_center_enabled

patch_margin_bottom

The height of the 9-slice's bottom row. A margin of 16 means the 9-slice's bottom corners and side will have a height of 16 pixels. You can set all 4 margin values individually to create panels with non-uniform borders.

var patch_margin_bottom : int = 0

Property Value

int

Remarks

  • void set_patch_margin(int margin, int value)
  • int get_patch_margin(int margin)

patch_margin_left

The width of the 9-slice's left column. A margin of 16 means the 9-slice's left corners and side will have a width of 16 pixels. You can set all 4 margin values individually to create panels with non-uniform borders.

var patch_margin_left : int = 0

Property Value

int

Remarks

  • void set_patch_margin(int margin, int value)
  • int get_patch_margin(int margin)

patch_margin_right

The width of the 9-slice's right column. A margin of 16 means the 9-slice's right corners and side will have a width of 16 pixels. You can set all 4 margin values individually to create panels with non-uniform borders.

var patch_margin_right : int = 0

Property Value

int

Remarks

  • void set_patch_margin(int margin, int value)
  • int get_patch_margin(int margin)

patch_margin_top

The height of the 9-slice's top row. A margin of 16 means the 9-slice's top corners and side will have a height of 16 pixels. You can set all 4 margin values individually to create panels with non-uniform borders.

var patch_margin_top : int = 0

Property Value

int

Remarks

  • void set_patch_margin(int margin, int value)
  • int get_patch_margin(int margin)

region_rect

Rectangular region of the texture to sample from. If you're working with an atlas, use this property to define the area the 9-slice should use. All other properties are relative to this one. If the rect is empty, NinePatchRect will use the whole texture.

var region_rect : Rect2 = Rect2(0, 0, 0, 0)

Property Value

Rect2

Remarks

  • void set_region_rect(Rect2 value)
  • Rect2 get_region_rect

texture

The node's texture resource.

var texture : Texture2D

Property Value

Texture2D

Remarks

Methods

get_patch_margin(int)

Qualifiers: const

Returns the size of the margin on the specified Side.

int get_patch_margin(int margin)

Parameters

margin int

set_patch_margin(int, int)

Sets the size of the margin on the specified Side to value pixels.

void set_patch_margin(int margin, int value)

Parameters

margin int
value int

Events

texture_changed

Emitted when the node's texture changes.

signal texture_changed