Class Rect2

Color metatype, wrapper for godot_rect2.

Construct using the idiom Rect2(...), which calls __new.

Components may be accessed through elements, individually using x/y/width/height or as Vector2 position/size:

typedef union godot_rect2 {
    uint8_t data[16];
    float elements[4];
    struct { float x, y, width, height; };
    struct { Vector2 position; Vector2 size; };
} godot_rect2;

Methods

Rect2:abs () Returns a Rect2 with equivalent position and area, modified so that the top-left corner is the origin and width and height are positive.
Rect2:clip (b) Returns the intersection of this Rect2 and b.
Rect2:encloses (b) Returns true if this Rect2 completely encloses another one.
Rect2:expand (point) Returns this Rect2 expanded to include a given point.
Rect2:get_area () Returns the area of the Rect2.
Rect2:grow (amount) Returns a copy of the Rect2 grown a given amount of units towards all the sides.
Rect2:grow_individual (left, top, right, bottom) Returns a copy of the Rect2 grown a given amount of units towards each direction individually.
Rect2:grow_margin (margin, amount) Returns a copy of the Rect2 grown a given amount of units towards the Margin direction.
Rect2:has_no_area () Returns true if the Rect2 is flat or empty.
Rect2:has_point (point) Returns true if the Rect2 contains a point.
Rect2:intersects (b[, include_borders=false]) Returns true if the Rect2 overlaps with b.
Rect2:merge (b) Returns a larger Rect2 that contains this Rect2 and b.
Rect2:unpack () Returns all elements.

Metamethods

Rect2:__concat (a, b) Concatenates values.
Rect2:__eq (a, b) Equality operation
Rect2:__new (...) Rect2 constructor, called by the idiom Rect2(...).
Rect2:__tostring () Returns a Lua string representation of this rect.


Methods

Rect2:abs ()
Returns a Rect2 with equivalent position and area, modified so that the top-left corner is the origin and width and height are positive.

Returns:

    Rect2
Rect2:clip (b)
Returns the intersection of this Rect2 and b.

Parameters:

Returns:

    Rect2
Rect2:encloses (b)
Returns true if this Rect2 completely encloses another one.

Parameters:

Returns:

    bool
Rect2:expand (point)
Returns this Rect2 expanded to include a given point.

Parameters:

Returns:

    Rect2
Rect2:get_area ()
Returns the area of the Rect2.

Returns:

    number
Rect2:grow (amount)
Returns a copy of the Rect2 grown a given amount of units towards all the sides.

Parameters:

  • amount number

Returns:

    Rect2
Rect2:grow_individual (left, top, right, bottom)
Returns a copy of the Rect2 grown a given amount of units towards each direction individually.

Parameters:

  • left number
  • top number
  • right number
  • bottom number

Returns:

    Rect2
Rect2:grow_margin (margin, amount)
Returns a copy of the Rect2 grown a given amount of units towards the Margin direction.

Parameters:

  • margin int
  • amount number

Returns:

    Rect2
Rect2:has_no_area ()
Returns true if the Rect2 is flat or empty.

Returns:

    bool
Rect2:has_point (point)
Returns true if the Rect2 contains a point.

Parameters:

Returns:

    bool
Rect2:intersects (b[, include_borders=false])
Returns true if the Rect2 overlaps with b. (i.e. they have at least one point in common).

Parameters:

  • b Rect2
  • include_borders If true, they will also be considered overlapping if their borders touch, even without intersection. (default false)

Returns:

    bool
Rect2:merge (b)
Returns a larger Rect2 that contains this Rect2 and b.

Parameters:

Returns:

    Rect2
Rect2:unpack ()
Returns all elements.

Returns:

  1. number X
  2. number Y
  3. number width
  4. number height

Metamethods

Rect2:__concat (a, b)
Concatenates values.

Parameters:

  • a First value, stringified with GD.str
  • b First value, stringified with GD.str

Returns:

    String
Rect2:__eq (a, b)
Equality operation

Parameters:

Returns:

    bool
Rect2:__new (...)

Rect2 constructor, called by the idiom Rect2(...).

  • Rect2(): all zeros (Rect2() == Rect2(0, 0, 0, 0))
  • Rect2(number x, number y, number width, number height): set XY and width/height
  • Rect2(Vector2 position, Vector2 size): set position and size
  • Rect2(Rect2 other): copy values from other

Parameters:

  • ...

Returns:

    Rect2
Rect2:__tostring ()
Returns a Lua string representation of this rect.

Returns:

    string
generated by LDoc 1.4.6 Last updated 2023-01-04 08:52:34