Skip to content

StyleBoxTexture

Inherits: StyleBox < Resource < RefCounted < Object

A texture-based nine-patch StyleBox.

A texture-based nine-patch StyleBox, in a way similar to NinePatchRect. This stylebox performs a 3×3 scaling of a texture, where only the center cell is fully stretched. This makes it possible to design bordered styles regardless of the stylebox’s size.

Type Name Default
AxisStretchMode axis_stretch_horizontal 0
AxisStretchMode axis_stretch_vertical 0
bool draw_center true
float expand_margin_bottom 0.0
float expand_margin_left 0.0
float expand_margin_right 0.0
float expand_margin_top 0.0
Color modulate_color Color(1, 1, 1, 1)
Rect2 region_rect Rect2(0, 0, 0, 0)
Texture2D texture
float texture_margin_bottom 0.0
float texture_margin_left 0.0
float texture_margin_right 0.0
float texture_margin_top 0.0
Returns Method
float get_expand_margin(margin: Side) const
float get_texture_margin(margin: Side) const
void set_expand_margin(margin: Side, size: float)
void set_expand_margin_all(size: float)
void set_texture_margin(margin: Side, size: float)
void set_texture_margin_all(size: float)

AxisStretchMode

enum AxisStretchMode

AXIS_STRETCH_MODE_STRETCH = 0

Stretch the stylebox’s texture. This results in visible distortion unless the texture size matches the stylebox’s size perfectly.

AXIS_STRETCH_MODE_TILE = 1

Repeats the stylebox’s texture to match the stylebox’s size according to the nine-patch system.

AXIS_STRETCH_MODE_TILE_FIT = 2

Repeats the stylebox’s texture to match the stylebox’s size according to the nine-patch system. Unlike AXIS_STRETCH_MODE_TILE, the texture may be slightly stretched to make the nine-patch texture tile seamlessly.

axis_stretch_horizontal

AxisStretchMode axis_stretch_horizontal = 0

Controls how the stylebox’s texture will be stretched or tiled horizontally.

axis_stretch_vertical

AxisStretchMode axis_stretch_vertical = 0

Controls how the stylebox’s texture will be stretched or tiled vertically.

draw_center

bool draw_center = true

If true, the nine-patch texture’s center tile will be drawn.

expand_margin_bottom

float expand_margin_bottom = 0.0

Expands the bottom margin of this style box when drawing, causing it to be drawn larger than requested.

expand_margin_left

float expand_margin_left = 0.0

Expands the left margin of this style box when drawing, causing it to be drawn larger than requested.

expand_margin_right

float expand_margin_right = 0.0

Expands the right margin of this style box when drawing, causing it to be drawn larger than requested.

expand_margin_top

float expand_margin_top = 0.0

Expands the top margin of this style box when drawing, causing it to be drawn larger than requested.

modulate_color

Color modulate_color = Color(1, 1, 1, 1)

Modulates the color of the texture when this style box is drawn.

region_rect

Rect2 region_rect = Rect2(0, 0, 0, 0)

The region to use from the texture.

This is equivalent to first wrapping the texture in an AtlasTexture with the same region.

If empty (Rect2(0, 0, 0, 0)), the whole texture is used.

texture

Texture2D texture

The texture to use when drawing this style box.

texture_margin_bottom

float texture_margin_bottom = 0.0

Increases the bottom margin of the 3×3 texture box.

A higher value means more of the source texture is considered to be part of the bottom border of the 3×3 box.

This is also the value used as fallback for StyleBox.content_margin_bottom if it is negative.

texture_margin_left

float texture_margin_left = 0.0

Increases the left margin of the 3×3 texture box.

A higher value means more of the source texture is considered to be part of the left border of the 3×3 box.

This is also the value used as fallback for StyleBox.content_margin_left if it is negative.

texture_margin_right

float texture_margin_right = 0.0

Increases the right margin of the 3×3 texture box.

A higher value means more of the source texture is considered to be part of the right border of the 3×3 box.

This is also the value used as fallback for StyleBox.content_margin_right if it is negative.

texture_margin_top

float texture_margin_top = 0.0

Increases the top margin of the 3×3 texture box.

A higher value means more of the source texture is considered to be part of the top border of the 3×3 box.

This is also the value used as fallback for StyleBox.content_margin_top if it is negative.

get_expand_margin

float get_expand_margin(margin: Side) const

Returns the expand margin size of the specified Side.

get_texture_margin

float get_texture_margin(margin: Side) const

Returns the margin size of the specified Side.

set_expand_margin

void set_expand_margin(margin: Side, size: float)

Sets the expand margin to size pixels for the specified Side.

set_expand_margin_all

void set_expand_margin_all(size: float)

Sets the expand margin to size pixels for all sides.

set_texture_margin

void set_texture_margin(margin: Side, size: float)

Sets the margin to size pixels for the specified Side.

set_texture_margin_all

void set_texture_margin_all(size: float)

Sets the margin to size pixels for all sides.