Table of Contents

Struct Rect2D

Namespace
Cobilas.GodotEngine.Utility
Assembly
com.cobilas.godot.utility.dll

Represents a 2D rectangle with advanced properties for geometric transformations.

[Serializable]
public struct Rect2D : IEquatable<Rect2D>, IFormattable
Implements
Inherited Members

Remarks

This structure extends the functionality of a traditional rectangle, including rotation, scale, pivot, and minimum size, making it useful for advanced UI and sprite operations in the Godot Engine.

Constructors

Rect2D(Vector2D, Vector2D, Vector2D, float, Vector2D, Vector2D)

Initializes a new instance of the Rect2D structure using vectors.

public Rect2D(Vector2D position, Vector2D size, Vector2D minSize, float rotation, Vector2D scale, Vector2D pivot)

Parameters

position Vector2D

Position of the rectangle.

size Vector2D

Size of the rectangle.

minSize Vector2D

Minimum size of the rectangle.

rotation float

Rotation in degrees.

scale Vector2D

Scale of the rectangle.

pivot Vector2D

Pivot point of the rectangle.

Rect2D(Rect2D)

Initializes a new instance of the Rect2D structure by copying another instance.

public Rect2D(Rect2D rect)

Parameters

rect Rect2D

Rect2D to be copied.

Rect2D(Rect2, Vector2D, float, Vector2D, Vector2D)

Initializes a new instance of the Rect2D structure from a Godot Godot.Rect2.

public Rect2D(Rect2 rect, Vector2D minSize, float rotation, Vector2D scale, Vector2D pivot)

Parameters

rect Rect2

Godot's base rectangle.

minSize Vector2D

Minimum size of the rectangle.

rotation float

Rotation in degrees.

scale Vector2D

Rectangle scale.

pivot Vector2D

Rectangle pivot point.

Rect2D(float, float, float, float, float, float, float, float, float, float, float)

Represents a 2D rectangle with advanced properties for geometric transformations.

public Rect2D(float x, float y, float width, float height, float minWidth, float minHeight, float rotation, float scaleX, float scaleY, float pivotX, float pivotY)

Parameters

x float

X coordinate of the rectangle's position.

y float

Y coordinate of the rectangle's position.

width float

Width of the rectangle.

height float

Height of the rectangle.

minWidth float

Minimum width of the rectangle.

minHeight float

Minimum height of the rectangle.

rotation float

Rotation of the rectangle in degrees.

scaleX float

Scale of the rectangle on the X axis.

scaleY float

Scale of the rectangle on the Y axis.

pivotX float

X coordinate of the pivot point of the rectangle.

pivotY float

Y coordinate of the rectangle's pivot point.

Remarks

This structure extends the functionality of a traditional rectangle, including rotation, scale, pivot, and minimum size, making it useful for advanced UI and sprite operations in the Godot Engine.

Properties

Bottom

Gets the Y coordinate of the rectangle's base.

public readonly float Bottom { get; }

Property Value

float

Y coordinate of the base.

Empty

Gets an empty Rect2D instance.

public static Rect2D Empty { get; }

Property Value

Rect2D

An empty instance of Rect2D.

Left

Gets the X coordinate of the left side of the rectangle.

public readonly float Left { get; }

Property Value

float

X coordinate on the left side.

MinSize

Gets the minimum size of the rectangle.

public readonly Vector2D MinSize { get; }

Property Value

Vector2D

A Vector2D representing the minimum size of the rectangle.

MinSizeScale

Gets the minimum size of the rectangle applied to the scale.

public readonly Vector2D MinSizeScale { get; }

Property Value

Vector2D

A Vector2D representing the minimum scaled size of the rectangle.

Pivot

Gets the pivot point of the rectangle.

public readonly Vector2D Pivot { get; }

Property Value

Vector2D

A Vector2D representing the pivot point of the rectangle.

PivotScale

Gets the pivot of the rectangle applied to the scale.

public readonly Vector2D PivotScale { get; }

Property Value

Vector2D

A Vector2D representing the scaled pivot of the rectangle.

Position

Gets the position of the top-left corner of the rectangle.

public readonly Vector2D Position { get; }

Property Value

Vector2D

A Vector2D representing the position of the rectangle.

RadianRotation

Gets the rotation of the rectangle in radians.

public readonly float RadianRotation { get; }

Property Value

float

Angle of rotation in radians.

Right

Gets the X coordinate of the right side of the rectangle.

public readonly float Right { get; }

Property Value

float

X coordinate on the right side.

Rotation

Gets the rotation of the rectangle in degrees.

public readonly float Rotation { get; }

Property Value

float

Rotation angle in degrees.

Scale

Gets the scale of the rectangle.

public readonly Vector2D Scale { get; }

Property Value

Vector2D

A Vector2D representing the scale of the rectangle.

Size

Gets the size of the rectangle.

public readonly Vector2D Size { get; }

Property Value

Vector2D

A Vector2D representing the size of the rectangle.

SizeScale

Gets the size of the rectangle applied to the scale.

public readonly Vector2D SizeScale { get; }

Property Value

Vector2D

A Vector2D representing the scaled size of the rectangle.

Top

Gets the Y coordinate of the top of the rectangle.

public readonly float Top { get; }

Property Value

float

Y coordinate of the top.

Methods

Equals(Rect2D)

Indicates whether the current object is equal to another object of the same type.

public readonly bool Equals(Rect2D other)

Parameters

other Rect2D

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

Equals(object)

Indicates whether this instance and a specified object are equal.

public override readonly bool Equals(object obj)

Parameters

obj object

The object to compare with the current instance.

Returns

bool

true if obj and this instance are the same type and represent the same value; otherwise, false.

GetHashCode()

Returns the hash code for this instance.

public override readonly int GetHashCode()

Returns

int

A 32-bit signed integer that is the hash code for this instance.

HasPoint(Vector2D)

Checks if a point is inside the rectangle, considering rotation and transformations.

public readonly bool HasPoint(Vector2D point)

Parameters

point Vector2D

The point to be checked.

Returns

bool

true if the point is inside the rectangle; otherwise, false.

SetMinSize(Vector2D)

Sets the minimum size of the rectangle using a Vector2D.

public Rect2D SetMinSize(Vector2D minSize)

Parameters

minSize Vector2D

Vector containing the minimum size.

Returns

Rect2D

The Rect2D itself to allow chained calls.

SetMinSize(Vector2DInt)

Sets the minimum size of the rectangle using a Vector2DInt.

public Rect2D SetMinSize(Vector2DInt minSize)

Parameters

minSize Vector2DInt

Integer vector containing the minimum size.

Returns

Rect2D

The Rect2D itself to allow chained calls.

SetMinSize(float, float)

Sets the minimum size of the rectangle using individual values.

public Rect2D SetMinSize(float minWidth, float minHeight)

Parameters

minWidth float

Minimum width of the rectangle.

minHeight float

Minimum height of the rectangle.

Returns

Rect2D

The Rect2D itself to allow chained calls.

SetPivot(Vector2D)

Sets the rectangle's pivot point using Vector2D.

public Rect2D SetPivot(Vector2D pivot)

Parameters

pivot Vector2D

Vector containing the pivot.

Returns

Rect2D

The Rect2D itself to allow chained calls.

SetPivot(Vector2DInt)

Sets the rectangle's pivot point using Vector2DInt.

public Rect2D SetPivot(Vector2DInt pivot)

Parameters

pivot Vector2DInt

Integer vector containing the pivot.

Returns

Rect2D

The Rect2D itself to allow chained calls.

SetPivot(float, float)

Sets the rectangle's pivot point using individual values.

public Rect2D SetPivot(float pivotX, float pivotY)

Parameters

pivotX float

X coordinate of the pivot.

pivotY float

Y coordinate of the pivot.

Returns

Rect2D

The Rect2D itself to allow chained calls.

SetPosition(Vector2D)

Sets the rectangle's position using a Vector2D.

public Rect2D SetPosition(Vector2D position)

Parameters

position Vector2D

Vector containing the position.

Returns

Rect2D

The Rect2D itself to allow chained calls.

SetPosition(Vector2DInt)

Sets the rectangle's position using a Vector2DInt.

public Rect2D SetPosition(Vector2DInt position)

Parameters

position Vector2DInt

Integer vector containing the position.

Returns

Rect2D

The Rect2D itself to allow chained calls.

SetPosition(float, float)

Defines the rectangle's position using individual coordinates.

public Rect2D SetPosition(float x, float y)

Parameters

x float

X coordinate of the position.

y float

Y coordinate of the position.

Returns

Rect2D

The Rect2D itself to allow chained calls.

SetRotation(float)

Defines the rotation of the rectangle in degrees.

public Rect2D SetRotation(float rotation)

Parameters

rotation float

Rotation angle in degrees.

Returns

Rect2D

The Rect2D itself to allow chained calls.

SetScale(Vector2D)

Define a escala do retângulo usando Vector2D.

public Rect2D SetScale(Vector2D scale)

Parameters

scale Vector2D

Vetor contendo a escala.

Returns

Rect2D

The Rect2D itself to allow chained calls.

SetScale(Vector2DInt)

Sets the rectangle's scale using Vector2DInt.

public Rect2D SetScale(Vector2DInt scale)

Parameters

scale Vector2DInt

Integer vector containing the scale.

Returns

Rect2D

The Rect2D itself to allow chained calls.

SetScale(float, float)

Sets the rectangle's scale using individual values.

public Rect2D SetScale(float scaleX, float scaleY)

Parameters

scaleX float

Scale on the X axis.

scaleY float

Scale on the Y axis.

Returns

Rect2D

The Rect2D itself to allow chained calls.

SetSize(Vector2D)

Sets the size of the rectangle using a Vector2D.

public Rect2D SetSize(Vector2D size)

Parameters

size Vector2D

Vector containing the size.

Returns

Rect2D

The Rect2D itself to allow chained calls.

SetSize(Vector2DInt)

Sets the size of the rectangle using a Vector2DInt.

public Rect2D SetSize(Vector2DInt size)

Parameters

size Vector2DInt

Integer vector containing the size.

Returns

Rect2D

The Rect2D itself to allow chained calls.

SetSize(float, float)

Sets the size of the rectangle using individual values.

public Rect2D SetSize(float width, float height)

Parameters

width float

Width of the rectangle.

height float

Height of the rectangle.

Returns

Rect2D

The Rect2D itself to allow chained calls.

ToString()

Returns a string representing the current object.

public override readonly string ToString()

Returns

string

A string representing the current object.

ToString(string)

Returns a string representing the current object using the specified format.

public readonly string ToString(string format)

Parameters

format string

The format to use.

Returns

string

A string representing the current object.

ToString(string, IFormatProvider)

Returns a string that represents the current object using the specified format and format provider.

public readonly string ToString(string format, IFormatProvider formatProvider)

Parameters

format string

The format to use.

formatProvider IFormatProvider

The provider to use to format the value.

Returns

string

A string that represents the current object.

Operators

operator ==(Rect2D, Rect2D)

Determines whether two structures Rect2D are equal.

public static bool operator ==(Rect2D A, Rect2D B)

Parameters

A Rect2D

The first structure to compare.

B Rect2D

The second structure to compare.

Returns

bool

true if A and B are equal; otherwise, false.

explicit operator Rect2(Rect2D)

Explicitly converts a Rect2D to a Godot Godot.Rect2.

public static explicit operator Rect2(Rect2D R)

Parameters

R Rect2D

The Rect2D to convert.

Returns

Rect2

A Rect2 containing only position and size.

explicit operator float(Rect2D)

Explicitly converts a Rect2D to a float value representing its rotation.

public static explicit operator float(Rect2D R)

Parameters

R Rect2D

The Rect2D to convert.

Returns

float

The rotation of the Rect2D as a float.

operator !=(Rect2D, Rect2D)

Determines whether two structures Rect2D are different.

public static bool operator !=(Rect2D A, Rect2D B)

Parameters

A Rect2D

The first structure to compare.

B Rect2D

The second structure to compare.

Returns

bool

true if A and B are different; otherwise, false.