Rect2
Category: Built-In Types
Brief Description
2D Axis-aligned bounding box.
Member Functions
Rect2 | Rect2 ( Vector2 pos, Vector2 size ) |
Rect2 | Rect2 ( float x, float y, float width, float height ) |
Rect2 | clip ( Rect2 b ) |
bool | encloses ( Rect2 b ) |
Rect2 | expand ( Vector2 to ) |
float | get_area ( ) |
Rect2 | grow ( float by ) |
Rect2 | grow_individual ( float left, float top, float right, float bottom ) |
Rect2 | grow_margin ( int margin, float by ) |
bool | has_no_area ( ) |
bool | has_point ( Vector2 point ) |
bool | intersects ( Rect2 b ) |
Rect2 | merge ( Rect2 b ) |
Member Variables
- Vector2 end - Ending corner.
- Vector2 pos - Position (starting corner).
- Vector2 size - Size from position to end.
Description
Rect2 provides an 2D Axis-Aligned Bounding Box. It consists of a position, a size, and several utility functions. It is typically used for fast overlap tests.
Member Function Description
Rect2 Rect2 ( Vector2 pos, Vector2 size )
Construct a Rect2 by position and size.
Rect2 Rect2 ( float x, float y, float width, float height )
Construct a Rect2 by x, y, width and height.
Rect2 clip ( Rect2 b )
Returns the intersection of this Rect2 and b.
bool encloses ( Rect2 b )
Returns true if this Rect2 completely encloses another one.
Rect2 expand ( Vector2 to )
Return this Rect2 expanded to include a given point.
float get_area ( )
Get the area of the Rect2.
Rect2 grow ( float by )
Return a copy of the Rect2 grown a given amount of units towards all the sides.
Rect2 grow_individual ( float left, float top, float right, float bottom )
Rect2 grow_margin ( int margin, float by )
bool has_no_area ( )
Return true if the Rect2 is flat or empty.
bool has_point ( Vector2 point )
Return true if the Rect2 contains a point.
bool intersects ( Rect2 b )
Return true if the Rect2 overlaps with another.
Rect2 merge ( Rect2 b )
Combine this Rect2 with another, a larger one is returned that contains both.
© 2014–2020 Juan Linietsky, Ariel Manzur, Godot Engine contributors
Licensed under the MIT License.
https://docs.godotengine.org/en/2.1/classes/class_rect2.html