# Rect2¶

2D 轴对齐边界框。

## 描述¶

`Rect2` consists of a position, a size, and several utility functions. It is typically used for fast overlap tests.

It uses floating-point coordinates.

The 3D counterpart to `Rect2` is AABB.

Negative values for size are not supported and will not work for most methods. Use abs to get a Rect2 with a positive size.

## 属性¶

 Vector2 end `Vector2( 0, 0 )` Vector2 position `Vector2( 0, 0 )` Vector2 size `Vector2( 0, 0 )`

## 方法¶

 Rect2 Rect2 ( Vector2 position, Vector2 size ) Rect2 Rect2 ( float x, float y, float width, float height ) Rect2 abs ( ) Rect2 clip ( Rect2 b ) bool Rect2 expand ( Vector2 to ) float get_area ( ) Vector2 Rect2 grow ( float by ) Rect2 grow_individual ( float left, float top, float right, float bottom ) Rect2 grow_margin ( int margin, float by ) bool bool has_point ( Vector2 point ) bool intersects ( Rect2 b, bool include_borders=false ) bool is_equal_approx ( Rect2 rect ) Rect2 merge ( Rect2 b )

## 属性说明¶

 Default `Vector2( 0, 0 )`

 Default `Vector2( 0, 0 )`

 Default `Vector2( 0, 0 )`

positionend 的大小。通常所有分量都是正数。

## 方法说明¶

```# position (-3, 2), size (1, 1)
var rect = Rect2(Vector2(-3, 2), Vector2(1, 1))
# position (-3, -1), size (3, 4), 包含原来的 Rect 和 Vector2(0, -1)
var rect2 = rect.expand(Vector2(0, -1))
```

Returns the center of the `Rect2`, which is equal to position + (size / 2).

• bool has_no_area ( )