Inheritance #

TextureRect
Table of contents

TextureRect #

is_instantiable, Node, core, not_builtin_classes

A control that displays a texture.

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

Members #

var expand_mode = EXPAND_KEEP_SIZE#

Defines how minimum size is determined based on the texture's size. See ExpandMode for options.

var flip_h: bool = false#

If true, texture is flipped horizontally.

var flip_v: bool = false#

If true, texture is flipped vertically.

var mouse_filter = MOUSE_FILTER_PASS#

var stretch_mode = STRETCH_SCALE#

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

var texture: Texture2D#

The node's Texture2D resource.

Methods #

Annotations #

Constants #

const EXPAND_KEEP_SIZE = 0 enum ExpandMode#

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

const EXPAND_IGNORE_SIZE = 1 enum ExpandMode#

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

const EXPAND_FIT_WIDTH = 2 enum ExpandMode#

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

const EXPAND_FIT_WIDTH_PROPORTIONAL = 3 enum ExpandMode#

Same as EXPAND_FIT_WIDTH, but keeps texture's aspect ratio.

const EXPAND_FIT_HEIGHT = 4 enum ExpandMode#

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

const EXPAND_FIT_HEIGHT_PROPORTIONAL = 5 enum ExpandMode#

Same as EXPAND_FIT_HEIGHT, but keeps texture's aspect ratio.

const STRETCH_SCALE = 0 enum StretchMode#

Scale to fit the node's bounding rectangle.

const STRETCH_TILE = 1 enum StretchMode#

Tile inside the node's bounding rectangle.

const STRETCH_KEEP = 2 enum StretchMode#

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

const STRETCH_KEEP_CENTERED = 3 enum StretchMode#

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

const STRETCH_KEEP_ASPECT = 4 enum StretchMode#

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

const STRETCH_KEEP_ASPECT_CENTERED = 5 enum StretchMode#

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

const STRETCH_KEEP_ASPECT_COVERED = 6 enum StretchMode#

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

Constructors #

Enums #

ExpandMode#

enum ExpandMode { EXPAND_KEEP_SIZE = 0, EXPAND_IGNORE_SIZE = 1, EXPAND_FIT_WIDTH = 2, EXPAND_FIT_WIDTH_PROPORTIONAL = 3, EXPAND_FIT_HEIGHT = 4, EXPAND_FIT_HEIGHT_PROPORTIONAL = 5, }

StretchMode#

enum StretchMode { STRETCH_SCALE = 0, STRETCH_TILE = 1, STRETCH_KEEP = 2, STRETCH_KEEP_CENTERED = 3, STRETCH_KEEP_ASPECT = 4, STRETCH_KEEP_ASPECT_CENTERED = 5, STRETCH_KEEP_ASPECT_COVERED = 6, }

Operators #

Signals #

Theme Items #

Tutorials #