Skip to content

NinePatchRect

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

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

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

Overview

Provides a texture-backed UI rectangle with nine-patch margins.

Syntax

public class Electron2D.NinePatchRect : Electron2D.Control

Godot 4.7 C# profile compatibility

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

Texture-backed nine-patch control with source region, margins, optional center drawing and stretch/tile/tile-fit center axes.

Remarks

NinePatchRect splits a source texture region into corner, edge and center segments. Corners keep their margin sizes while edge and center segments stretch or tile according to axis stretch settings.

Thread Safety

This type is not synchronized. Create and mutate nine-patch rectangles on the main scene thread.

Since

This type is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Texture2D
  • Electron2D.TextureRect

Members

Member Kind Summary
AxisStretchHorizontal Property Gets or sets horizontal center stretch behavior.
AxisStretchVertical Property Gets or sets vertical center stretch behavior.
DrawCenter Property Gets or sets whether the center segment is drawn.
PatchMarginBottom Property Gets or sets the bottom patch margin in pixels.
PatchMarginLeft Property Gets or sets the left patch margin in pixels.
PatchMarginRight Property Gets or sets the right patch margin in pixels.
PatchMarginTop Property Gets or sets the top patch margin in pixels.
RegionRect Property Gets or sets the source region inside Electron2D.NinePatchRect.Texture.
Texture Property Gets or sets the texture drawn by this control.
Electron2D.NinePatchRect() Constructor Initializes a new instance of the Electron2D.NinePatchRect class.
_Draw() Method Draws the nine-patch texture segments.
_GetMinimumSize() Method Gets the minimum size requested by this nine-patch rectangle.

Member Details

AxisStretchHorizontal

Kind: Property

public Electron2D.NinePatchRect.AxisStretchModeEnum AxisStretchHorizontal { get; set; }

Summary

Gets or sets horizontal center stretch behavior.

Remarks

The default is Electron2D.NinePatchRect.AxisStretchModeEnum.Stretch.

Value

The mode used for the center column.

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.NinePatchRect.AxisStretchModeEnum

AxisStretchVertical

Kind: Property

public Electron2D.NinePatchRect.AxisStretchModeEnum AxisStretchVertical { get; set; }

Summary

Gets or sets vertical center stretch behavior.

Remarks

The default is Electron2D.NinePatchRect.AxisStretchModeEnum.Stretch.

Value

The mode used for the center row.

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.NinePatchRect.AxisStretchModeEnum

DrawCenter

Kind: Property

public System.Boolean DrawCenter { get; set; }

Summary

Gets or sets whether the center segment is drawn.

Remarks

Edges and corners are still drawn when this property is false.

Value

true to draw the center segment; 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.NinePatchRect

PatchMarginBottom

Kind: Property

public System.Int32 PatchMarginBottom { get; set; }

Summary

Gets or sets the bottom patch margin in pixels.

Remarks

The margin is clamped to available source and destination size during drawing.

Value

A non-negative margin.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when the assigned value is negative.

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.NinePatchRect.PatchMarginTop

PatchMarginLeft

Kind: Property

public System.Int32 PatchMarginLeft { get; set; }

Summary

Gets or sets the left patch margin in pixels.

Remarks

The margin is clamped to available source and destination size during drawing.

Value

A non-negative margin.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when the assigned value is negative.

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.NinePatchRect.PatchMarginRight

PatchMarginRight

Kind: Property

public System.Int32 PatchMarginRight { get; set; }

Summary

Gets or sets the right patch margin in pixels.

Remarks

The margin is clamped to available source and destination size during drawing.

Value

A non-negative margin.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when the assigned value is negative.

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.NinePatchRect.PatchMarginLeft

PatchMarginTop

Kind: Property

public System.Int32 PatchMarginTop { get; set; }

Summary

Gets or sets the top patch margin in pixels.

Remarks

The margin is clamped to available source and destination size during drawing.

Value

A non-negative margin.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when the assigned value is negative.

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.NinePatchRect.PatchMarginBottom

RegionRect

Kind: Property

public Electron2D.Rect2 RegionRect { get; set; }

Summary

Gets or sets the source region inside Electron2D.NinePatchRect.Texture.

Remarks

Negative size components are rejected.

Value

A source rectangle in texture pixels, or an empty rectangle to use the full texture.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when the rectangle is not finite or has negative size.

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.NinePatchRect.Texture

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.NinePatchRect()

Kind: Constructor

public Electron2D.NinePatchRect()

Summary

Initializes a new instance of the Electron2D.NinePatchRect class.

Remarks

The new control draws its center segment by default.

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.NinePatchRect

_Draw()

Kind: Method

public System.Void _Draw()()

Summary

Draws the nine-patch texture segments.

Remarks

No draw command is submitted when Electron2D.NinePatchRect.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.NinePatchRect.Texture

_GetMinimumSize()

Kind: Method

public Electron2D.Vector2 _GetMinimumSize()()

Summary

Gets the minimum size requested by this nine-patch rectangle.

Remarks

The value is independent of Electron2D.NinePatchRect.Texture.

Returns

The sum of horizontal and vertical patch margins.

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.NinePatchRect.PatchMarginLeft

Clone this wiki locally