Click or drag to resize

Rect2 Structure

2D axis-aligned bounding box. Rect2 consists of a position, a size, and several utility functions. It is typically used for fast overlap tests.

Namespace:  Godot
Assembly:  GodotSharp (in GodotSharp.dll) Version: 1.0.0
Syntax
C#
[SerializableAttribute]
public struct Rect2 : IEquatable<Rect2>

The Rect2 type exposes the following members.

Constructors
  NameDescription
Public methodRect2(Vector2, Vector2)
Constructs a Rect2 from a position and size.
Public methodRect2(Single, Single, Vector2)
Constructs a Rect2 from x, y, and size.
Public methodRect2(Vector2, Single, Single)
Constructs a Rect2 from a position, width, and height.
Public methodRect2(Single, Single, Single, Single)
Constructs a Rect2 from x, y, width, and height.
Top
Properties
  NameDescription
Public propertyArea
The area of this rect.
Public propertyEnd
Ending corner. This is calculated as Position plus Size. Setting this value will change the size.
Public propertyPosition
Beginning corner. Typically has values lower than End.
Public propertySize
Size from Position to End. Typically all components are positive. If the size is negative, you can use Abs() to fix it.
Top
Methods
  NameDescription
Public methodAbs
Returns a Rect2 with equivalent position and size, modified so that the top-left corner is the origin and width and height are positive.
Public methodClip
Returns the intersection of this Rect2 and `b`.
Public methodEncloses
Returns true if this Rect2 completely encloses another one.
Public methodEquals(Object) (Overrides ValueType.Equals(Object).)
Public methodEquals(Rect2)
Public methodExpand
Returns this Rect2 expanded to include a given point.
Public methodGetArea
Returns the area of the Rect2.
Public methodGetHashCode (Overrides ValueType.GetHashCode().)
Public methodGetType (Inherited from Object.)
Public methodGrow
Returns a copy of the Rect2 grown a given amount of units towards all the sides.
Public methodGrowIndividual
Returns a copy of the Rect2 grown a given amount of units towards each direction individually.
Public methodGrowMargin
Returns a copy of the Rect2 grown a given amount of units towards the Margin direction.
Public methodHasNoArea
Returns true if the Rect2 is flat or empty, or false otherwise.
Public methodHasPoint
Returns true if the Rect2 contains a point, or false otherwise.
Public methodIntersects
Returns true if the Rect2 overlaps with `b` (i.e. they have at least one point in common). If `includeBorders` is true, they will also be considered overlapping if their borders touch, even without intersection.
Public methodIsEqualApprox
Returns true if this rect and `other` are approximately equal, by running IsEqualApprox(Vector2) on each component.
Public methodMerge
Returns a larger Rect2 that contains this Rect2 and `b`.
Public methodToString() (Overrides ValueType.ToString().)
Public methodToString(String)
Top
Operators
  NameDescription
Public operatorStatic memberEquality
Public operatorStatic memberInequality
Top
See Also