TextureRect

Inherits:Control<CanvasItem<Node<Object

A control that displays a texture.

Description

A control that displays a texture, for example an icon inside a GUI. The texture's placement can be controlled with thestretch_mode property. It can scale, tile, or stay centered inside its bounding rectangle.

Tutorials

Properties

ExpandMode

expand_mode

0

bool

flip_h

false

bool

flip_v

false

MouseFilter

mouse_filter

1 (overridesControl)

StretchMode

stretch_mode

0

Texture2D

texture


Enumerations

enumExpandMode:🔗

ExpandModeEXPAND_KEEP_SIZE =0

The minimum size will be equal to texture size, i.e.TextureRect can't be smaller than the texture.

ExpandModeEXPAND_IGNORE_SIZE =1

The size of the texture won't be considered for minimum size calculation, so theTextureRect can be shrunk down past the texture size.

ExpandModeEXPAND_FIT_WIDTH =2

The height of the texture will be ignored. Minimum width will be equal to the current height. Useful for horizontal layouts, e.g. insideHBoxContainer.

ExpandModeEXPAND_FIT_WIDTH_PROPORTIONAL =3

Same asEXPAND_FIT_WIDTH, but keeps texture's aspect ratio.

ExpandModeEXPAND_FIT_HEIGHT =4

The width of the texture will be ignored. Minimum height will be equal to the current width. Useful for vertical layouts, e.g. insideVBoxContainer.

ExpandModeEXPAND_FIT_HEIGHT_PROPORTIONAL =5

Same asEXPAND_FIT_HEIGHT, but keeps texture's aspect ratio.


enumStretchMode:🔗

StretchModeSTRETCH_SCALE =0

Scale to fit the node's bounding rectangle.

StretchModeSTRETCH_TILE =1

Tile inside the node's bounding rectangle.

StretchModeSTRETCH_KEEP =2

The texture keeps its original size and stays in the bounding rectangle's top-left corner.

StretchModeSTRETCH_KEEP_CENTERED =3

The texture keeps its original size and stays centered in the node's bounding rectangle.

StretchModeSTRETCH_KEEP_ASPECT =4

Scale the texture to fit the node's bounding rectangle, but maintain the texture's aspect ratio.

StretchModeSTRETCH_KEEP_ASPECT_CENTERED =5

Scale the texture to fit the node's bounding rectangle, center it and maintain its aspect ratio.

StretchModeSTRETCH_KEEP_ASPECT_COVERED =6

Scale the texture so that the shorter side fits the bounding rectangle. The other side clips to the node's limits.


Property Descriptions

ExpandModeexpand_mode =0🔗

Experimental: UsingEXPAND_FIT_WIDTH,EXPAND_FIT_WIDTH_PROPORTIONAL,EXPAND_FIT_HEIGHT, orEXPAND_FIT_HEIGHT_PROPORTIONAL may result in unstable behavior in someContainer controls. This behavior may be re-evaluated and changed in the future.

Defines how minimum size is determined based on the texture's size.


boolflip_h =false🔗

Iftrue, texture is flipped horizontally.


boolflip_v =false🔗

Iftrue, texture is flipped vertically.


StretchModestretch_mode =0🔗

Controls the texture's behavior when resizing the node's bounding rectangle.


Texture2Dtexture🔗

The node'sTexture2D resource.


User-contributed notes

Please read theUser-contributed notes policy before submitting a comment.