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
positionVector2DPosition of the rectangle.
sizeVector2DSize of the rectangle.
minSizeVector2DMinimum size of the rectangle.
rotationfloatRotation in degrees.
scaleVector2DScale of the rectangle.
pivotVector2DPivot point of the rectangle.
Rect2D(Rect2D)
Initializes a new instance of the Rect2D structure by copying another instance.
public Rect2D(Rect2D rect)
Parameters
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
rectRect2Godot's base rectangle.
minSizeVector2DMinimum size of the rectangle.
rotationfloatRotation in degrees.
scaleVector2DRectangle scale.
pivotVector2DRectangle 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
xfloatX coordinate of the rectangle's position.
yfloatY coordinate of the rectangle's position.
widthfloatWidth of the rectangle.
heightfloatHeight of the rectangle.
minWidthfloatMinimum width of the rectangle.
minHeightfloatMinimum height of the rectangle.
rotationfloatRotation of the rectangle in degrees.
scaleXfloatScale of the rectangle on the X axis.
scaleYfloatScale of the rectangle on the Y axis.
pivotXfloatX coordinate of the pivot point of the rectangle.
pivotYfloatY 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
MinSizeScale
Gets the minimum size of the rectangle applied to the scale.
public readonly Vector2D MinSizeScale { get; }
Property Value
Pivot
Gets the pivot point of the rectangle.
public readonly Vector2D Pivot { get; }
Property Value
PivotScale
Gets the pivot of the rectangle applied to the scale.
public readonly Vector2D PivotScale { get; }
Property Value
Position
Gets the position of the top-left corner of the rectangle.
public readonly Vector2D Position { get; }
Property Value
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
Size
Gets the size of the rectangle.
public readonly Vector2D Size { get; }
Property Value
SizeScale
Gets the size of the rectangle applied to the scale.
public readonly Vector2D SizeScale { get; }
Property Value
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
otherRect2DAn object to compare with this object.
Returns
Equals(object)
Indicates whether this instance and a specified object are equal.
public override readonly bool Equals(object obj)
Parameters
objobjectThe object to compare with the current instance.
Returns
- bool
true if
objand 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
pointVector2DThe 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
minSizeVector2DVector containing the minimum size.
Returns
SetMinSize(Vector2DInt)
Sets the minimum size of the rectangle using a Vector2DInt.
public Rect2D SetMinSize(Vector2DInt minSize)
Parameters
minSizeVector2DIntInteger vector containing the minimum size.
Returns
SetMinSize(float, float)
Sets the minimum size of the rectangle using individual values.
public Rect2D SetMinSize(float minWidth, float minHeight)
Parameters
Returns
SetPivot(Vector2D)
Sets the rectangle's pivot point using Vector2D.
public Rect2D SetPivot(Vector2D pivot)
Parameters
pivotVector2DVector containing the pivot.
Returns
SetPivot(Vector2DInt)
Sets the rectangle's pivot point using Vector2DInt.
public Rect2D SetPivot(Vector2DInt pivot)
Parameters
pivotVector2DIntInteger vector containing the pivot.
Returns
SetPivot(float, float)
Sets the rectangle's pivot point using individual values.
public Rect2D SetPivot(float pivotX, float pivotY)
Parameters
Returns
SetPosition(Vector2D)
Sets the rectangle's position using a Vector2D.
public Rect2D SetPosition(Vector2D position)
Parameters
positionVector2DVector containing the position.
Returns
SetPosition(Vector2DInt)
Sets the rectangle's position using a Vector2DInt.
public Rect2D SetPosition(Vector2DInt position)
Parameters
positionVector2DIntInteger vector containing the position.
Returns
SetPosition(float, float)
Defines the rectangle's position using individual coordinates.
public Rect2D SetPosition(float x, float y)
Parameters
Returns
SetRotation(float)
Defines the rotation of the rectangle in degrees.
public Rect2D SetRotation(float rotation)
Parameters
rotationfloatRotation angle in degrees.
Returns
SetScale(Vector2D)
Define a escala do retângulo usando Vector2D.
public Rect2D SetScale(Vector2D scale)
Parameters
scaleVector2DVetor contendo a escala.
Returns
SetScale(Vector2DInt)
Sets the rectangle's scale using Vector2DInt.
public Rect2D SetScale(Vector2DInt scale)
Parameters
scaleVector2DIntInteger vector containing the scale.
Returns
SetScale(float, float)
Sets the rectangle's scale using individual values.
public Rect2D SetScale(float scaleX, float scaleY)
Parameters
Returns
SetSize(Vector2D)
Sets the size of the rectangle using a Vector2D.
public Rect2D SetSize(Vector2D size)
Parameters
sizeVector2DVector containing the size.
Returns
SetSize(Vector2DInt)
Sets the size of the rectangle using a Vector2DInt.
public Rect2D SetSize(Vector2DInt size)
Parameters
sizeVector2DIntInteger vector containing the size.
Returns
SetSize(float, float)
Sets the size of the rectangle using individual values.
public Rect2D SetSize(float width, float height)
Parameters
Returns
ToString()
Returns a string representing the current object.
public override readonly string ToString()
Returns
ToString(string)
public readonly string ToString(string format)
Parameters
formatstringThe format to use.
Returns
ToString(string, IFormatProvider)
public readonly string ToString(string format, IFormatProvider formatProvider)
Parameters
formatstringThe format to use.
formatProviderIFormatProviderThe provider to use to format the value.
Returns
Operators
operator ==(Rect2D, Rect2D)
Determines whether two structures Rect2D are equal.
public static bool operator ==(Rect2D A, Rect2D B)
Parameters
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
Returns
- Rect2
A Rect2 containing only position and size.
explicit operator float(Rect2D)
public static explicit operator float(Rect2D R)
Parameters
Returns
operator !=(Rect2D, Rect2D)
Determines whether two structures Rect2D are different.
public static bool operator !=(Rect2D A, Rect2D B)
Parameters
Returns
- bool
true if A and B are different; otherwise, false.