---
title: Class: Box
source: https://vjmap.com/en/doc/Class_Box.html
---

# Class: Box

[Math2D](#modulesmath2dmd).Box

Alternative 2D box object with less memory impact (four numbers instead of two min/max
objects with two numbers each). Should be faster.

### Table of contents

#### Constructors

- [constructor](#constructor)

#### Properties

- [h](#h)
- [w](#w)
- [x](#x)
- [y](#y)

#### Methods

- [contains](#contains)
- [containsBox](#containsbox)
- [intersects](#intersects)
- [set](#set)

### Constructors

#### constructor

\+ **new Box**(`x?`: *number*, `y?`: *number*, `w?`: *number*, `h?`: *number*): [*Box*](#classesdefaultmath2dboxmd)

Alternative 2D box object with less memory impact (four numbers instead of two min/max
objects with two numbers each). Should be faster.

##### Parameters

| Name | Type | Default value | Description |
| :------ | :------ | :------ | :------ |
| `x` | *number* | 0 | New X value. |
| `y` | *number* | 0 | New y value. |
| `w` | *number* | 0 | New w value. |
| `h` | *number* | 0 | New h value. |

**Returns:** [*Box*](#classesdefaultmath2dboxmd)

### Properties

#### h

• **h**: *number*= 0

___

#### w

• **w**: *number*= 0

___

#### x

• **x**: *number*= 0

___

#### y

• **y**: *number*= 0

### Methods

#### contains

▸ **contains**(`x`: *number*, `y`: *number*): *boolean*

Test box for inclusion of point.

##### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `x` | *number* | X coordinate of point. |
| `y` | *number* | Y coordinate of point. |

**Returns:** *boolean*

___

#### containsBox

▸ **containsBox**(`other`: [*Box*](#classesdefaultmath2dboxmd)): *boolean*

Test box for inclusion of another box.

##### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `other` | [*Box*](#classesdefaultmath2dboxmd) | Box 2 to test for inclusion. |

**Returns:** *boolean*

___

#### intersects

▸ **intersects**(`other`: [*Box*](#classesdefaultmath2dboxmd)): *boolean*

Test two boxes for intersection.

##### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `other` | [*Box*](#classesdefaultmath2dboxmd) | Box 2 to test for intersection. |

**Returns:** *boolean*

___

#### set

▸ **set**(`x`: *number*, `y`: *number*, `w`: *number*, `h`: *number*): *void*

Set new values to all properties of the box.

##### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `x` | *number* | New X value. |
| `y` | *number* | New y value. |
| `w` | *number* | New w value. |
| `h` | *number* | New h value. |

**Returns:** *void*


<a name="classesminimapcontrolmd"></a>

[vjmap](#readmemd) / [Exports](#modulesmd) / MiniMapControl
