Skip to content

TextureRect

Eduard Gushchin edited this page Jul 1, 2026 · 3 revisions

Home | API by Category | Complete API Index | API Compatibility

Field Value
Full name Electron2D.TextureRect
Namespace Electron2D
Kind class
Category UI and Text

Overview

Provides a control that draws a texture inside its rectangle.

Syntax

public class Electron2D.TextureRect : Electron2D.Control

Godot 4.7 C# profile compatibility

Profile: Electron2D 0.1.0 2D
Status: Supported / Parity verified
Out of profile: no
Godot reference: TextureRect

Texture display control with expand mode, stretch mode, horizontal/vertical flip and minimum-size behavior.

Remarks

TextureRect stores a Electron2D.Texture2D and submits texture draw commands according to Electron2D.TextureRect.StretchMode and Electron2D.TextureRect.ExpandMode.

Thread Safety

This type is not synchronized. Create and mutate texture rectangles on the main scene thread.

Since

This type is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Control
  • Electron2D.Texture2D

Members

Member Kind Summary
ExpandMode Property Gets or sets how texture size affects minimum size.
FlipH Property Gets or sets whether the texture is flipped horizontally.
FlipV Property Gets or sets whether the texture is flipped vertically.
StretchMode Property Gets or sets how the texture is drawn.
Texture Property Gets or sets the texture drawn by this control.
Electron2D.TextureRect() Constructor Initializes a new instance of the Electron2D.TextureRect class.
_Draw() Method Draws the texture according to Electron2D.TextureRect.StretchMode.
_GetMinimumSize() Method Gets the minimum size requested by this texture rectangle.

Member Details

ExpandMode

Kind: Property

public Electron2D.TextureRect.ExpandModeEnum ExpandMode { get; set; }

Summary

Gets or sets how texture size affects minimum size.

Remarks

The default is Electron2D.TextureRect.ExpandModeEnum.KeepSize.

Value

The expand mode used by Electron2D.TextureRect._GetMinimumSize.

Thread Safety

This property is not synchronized. Mutate it on the main scene thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.TextureRect.ExpandModeEnum

FlipH

Kind: Property

public System.Boolean FlipH { get; set; }

Summary

Gets or sets whether the texture is flipped horizontally.

Remarks

The flip flag is stored in the internal texture draw command.

Value

true to request horizontal flip; otherwise, false.

Thread Safety

This property is not synchronized. Mutate it on the main scene thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.TextureRect.FlipV

FlipV

Kind: Property

public System.Boolean FlipV { get; set; }

Summary

Gets or sets whether the texture is flipped vertically.

Remarks

The flip flag is stored in the internal texture draw command.

Value

true to request vertical flip; otherwise, false.

Thread Safety

This property is not synchronized. Mutate it on the main scene thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.TextureRect.FlipH

StretchMode

Kind: Property

public Electron2D.TextureRect.StretchModeEnum StretchMode { get; set; }

Summary

Gets or sets how the texture is drawn.

Remarks

The default is Electron2D.TextureRect.StretchModeEnum.Scale.

Value

The stretch mode used by Electron2D.TextureRect._Draw.

Thread Safety

This property is not synchronized. Mutate it on the main scene thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.TextureRect.StretchModeEnum

Texture

Kind: Property

public Electron2D.Texture2D Texture { get; set; }

Summary

Gets or sets the texture drawn by this control.

Remarks

Assigning this property queues a redraw.

Value

The texture resource, or null to draw nothing.

Thread Safety

This property is not synchronized. Mutate it on the main scene thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Texture2D

Electron2D.TextureRect()

Kind: Constructor

public Electron2D.TextureRect()

Summary

Initializes a new instance of the Electron2D.TextureRect class.

Remarks

The new control ignores mouse input by passing it through to controls below it.

Thread Safety

This constructor is not synchronized. Call it from the main scene thread.

Since

This constructor is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.TextureRect

_Draw()

Kind: Method

public System.Void _Draw()()

Summary

Draws the texture according to Electron2D.TextureRect.StretchMode.

Remarks

No draw command is submitted when Electron2D.TextureRect.Texture is null.

Thread Safety

This callback is invoked on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.CanvasItem.DrawTexture(Electron2D.Texture2D,Electron2D.Vector2,System.Nullable{Electron2D.Color})

_GetMinimumSize()

Kind: Method

public Electron2D.Vector2 _GetMinimumSize()()

Summary

Gets the minimum size requested by this texture rectangle.

Remarks

When no texture is assigned, the minimum size is zero.

Returns

A size derived from Electron2D.TextureRect.Texture and Electron2D.TextureRect.ExpandMode.

Thread Safety

This callback is invoked on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.TextureRect.ExpandMode

Clone this wiki locally