> ## Documentation Index
> Fetch the complete documentation index at: https://docs.simular.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# BoundingBox

> Axis-aligned rectangle.

Axis-aligned rectangle. `right` and `bottom` are exclusive (Playwright /
DOM convention), so the box covers `[left, right) × [top, bottom)`.

Spatial predicates (`isBelow`, `overlapsX`, …) match the Rust methods
and are what you compose in `searchRelative`.

## Constructor

```typescript
BoundingBox(left: number, top: number, right: number, bottom: number): BoundingBox
```

Construct a box from exclusive-edge coordinates. Throws if the box is
degenerate (`right <= left` or `bottom <= top`).

### Parameters

<ResponseField name={"left"} type={"number"} required />

<ResponseField name={"top"} type={"number"} required />

<ResponseField name={"right"} type={"number"} required />

<ResponseField name={"bottom"} type={"number"} required />

### Returns

`BoundingBox`

## Properties

<ResponseField name={"bottom"} type={"number"} required />

<ResponseField name={"height"} type={"number"} required>
  Height (`bottom - top`). Always positive by construction.
</ResponseField>

<ResponseField name={"left"} type={"number"} required />

<ResponseField name={"right"} type={"number"} required />

<ResponseField name={"top"} type={"number"} required />

<ResponseField name={"width"} type={"number"} required>
  Width (`right - left`). Always positive by construction.
</ResponseField>

## Methods

### area()

```typescript
area(): number
```

Area in pixels.

#### Returns

`number`

### center()

```typescript
center(): [number, number]
```

Geometric center as `[x, y]` (integer-truncated, the pixel midpoint).

#### Returns

`[number, number]`

### containsBox()

```typescript
containsBox(other: BoundingBox): boolean
```

`true` if this box fully encloses `other` (equal boxes count).

#### Parameters

<ResponseField name={"other"} type={"BoundingBox"} required />

#### Returns

`boolean`

### containsPoint()

```typescript
containsPoint(x: number, y: number): boolean
```

`true` if the point `(x, y)` lies inside this box. Exclusive `right` /
`bottom` edges are outside.

#### Parameters

<ResponseField name={"x"} type={"number"} required />

<ResponseField name={"y"} type={"number"} required />

#### Returns

`boolean`

### equals()

```typescript
equals(other: BoundingBox): boolean
```

`true` if both boxes have the same exclusive-edge corners. `===` is
still object identity — two separately constructed boxes with the
same corners need this method.

#### Parameters

<ResponseField name={"other"} type={"BoundingBox"} required />

#### Returns

`boolean`

### fromXywh()

```typescript
fromXywh(x: number, y: number, width: number, height: number): BoundingBox
```

Construct from origin + size. Throws if `width` / `height` are not
positive or if `x + width` / `y + height` overflow `i32`.

#### Parameters

<ResponseField name={"x"} type={"number"} required />

<ResponseField name={"y"} type={"number"} required />

<ResponseField name={"width"} type={"number"} required />

<ResponseField name={"height"} type={"number"} required />

#### Returns

`BoundingBox`

### intersects()

```typescript
intersects(other: BoundingBox): boolean
```

`true` if the boxes' interiors overlap. Exclusive edges that merely
touch do not count.

#### Parameters

<ResponseField name={"other"} type={"BoundingBox"} required />

#### Returns

`boolean`

### isAbove()

```typescript
isAbove(other: BoundingBox): boolean
```

`true` if this box sits entirely above `other` (no vertical overlap;
exclusive edges that touch still count).

#### Parameters

<ResponseField name={"other"} type={"BoundingBox"} required />

#### Returns

`boolean`

### isBelow()

```typescript
isBelow(other: BoundingBox): boolean
```

`true` if this box sits entirely below `other`. See \[`isAbove`].

#### Parameters

<ResponseField name={"other"} type={"BoundingBox"} required />

#### Returns

`boolean`

### isContainedIn()

```typescript
isContainedIn(other: BoundingBox): boolean
```

`true` if `other` fully encloses this box. Inverse of \[`containsBox`].

#### Parameters

<ResponseField name={"other"} type={"BoundingBox"} required />

#### Returns

`boolean`

### isLeftOf()

```typescript
isLeftOf(other: BoundingBox): boolean
```

`true` if this box sits entirely to the left of `other`. See \[`isAbove`].

#### Parameters

<ResponseField name={"other"} type={"BoundingBox"} required />

#### Returns

`boolean`

### isRightOf()

```typescript
isRightOf(other: BoundingBox): boolean
```

`true` if this box sits entirely to the right of `other`. See \[`isAbove`].

#### Parameters

<ResponseField name={"other"} type={"BoundingBox"} required />

#### Returns

`boolean`

### overlapArea()

```typescript
overlapArea(other: BoundingBox): number
```

Overlap area with `other` in pixels, `0` when the boxes do not
intersect.

#### Parameters

<ResponseField name={"other"} type={"BoundingBox"} required />

#### Returns

`number`

### overlapsX()

```typescript
overlapsX(other: BoundingBox): boolean
```

`true` if the x-projections overlap (exclusive edges that touch do not).
A narrow button over a wide field typically matches even when centers
do not — compose with \[`isAbove`] for "above in this column".

#### Parameters

<ResponseField name={"other"} type={"BoundingBox"} required />

#### Returns

`boolean`

### overlapsY()

```typescript
overlapsY(other: BoundingBox): boolean
```

`true` if the y-projections overlap. See \[`overlapsX`].

#### Parameters

<ResponseField name={"other"} type={"BoundingBox"} required />

#### Returns

`boolean`

### sameColumn()

```typescript
sameColumn(other: BoundingBox, tolerance: number): boolean
```

`true` if the boxes share a column: centers within `tolerance` on `x`.

#### Parameters

<ResponseField name={"other"} type={"BoundingBox"} required />

<ResponseField name={"tolerance"} type={"number"} required />

#### Returns

`boolean`

### sameRow()

```typescript
sameRow(other: BoundingBox, tolerance: number): boolean
```

`true` if the boxes share a row: centers within `tolerance` on `y`.
`tolerance` is in OS-native units (physical pixels on Windows/Linux,
logical points on macOS).

#### Parameters

<ResponseField name={"other"} type={"BoundingBox"} required />

<ResponseField name={"tolerance"} type={"number"} required />

#### Returns

`boolean`

### shortestDistanceTo()

```typescript
shortestDistanceTo(other: BoundingBox): number
```

Shortest edge-to-edge distance to `other`, `0` when they touch or
overlap. Rank matches with `Math.min` / `Math.max` on this value.

#### Parameters

<ResponseField name={"other"} type={"BoundingBox"} required />

#### Returns

`number`

### toString()

```typescript
toString(): string
```

Playwright / DOM shape: `{x: …, y: …, width: …, height: …}`.

#### Returns

`string`
