---
metadata:
  - name: generator
    content: Diplodoc Platform v5.39.1
alternate:
  - https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IRectangleGeometryAccess.md
  - https://yandex.com/dev/jsapi-v2-1/doc/ru/v2-1/ref/reference/IRectangleGeometryAccess.md
---
> **Documentation Index:** Fetch the complete configuration index at https://yandex.com/dev/jsapi-v2-1/doc/en/llms.txt

# IRectangleGeometryAccess

Extends [IFreezable](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IFreezable.md).

Interface for accessing the "Rectangle" geometry.

[Constructor](#constructor-summary) | [Fields](#properties-summary) | [Events](#events-summary) | [Methods](#methods-summary)

## Constructor {#constructor-summary}

```javascript
IRectangleGeometryAccess()
```

## Fields {#properties-summary}

#|
|| **Name** | **Type** | **Description** ||
|| [events](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IFreezable.md#events) | [IEventManager](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IEventManager.md) | Event manager for the object.

Inherited from [IFreezable](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IFreezable.md#events). ||
|#

## Events {#events-summary}

#|
|| **Name** | **Description** ||
|| [change](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IRectangleGeometryAccess.md#event-change) | Change to corner coordinates. Instance of the [Event](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/Event.md) class. Names of fields that are available via the [Event.get](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/Event.md#get) method: 
- oldCoordinates - Old coordinates of the corners.
- newCoordinates - New coordinates of the corners. ||
|#

## Methods {#methods-summary}

#|
|| **Name** | **Returns** | **Description** ||
|| [contains](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IRectangleGeometryAccess.md#contains)([position](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IRectangleGeometryAccess.md#contains-param-position)) | Boolean | Checks whether the passed point is located inside the rectangle. ||
|| [freeze](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IFreezable.md#freeze)() | [IFreezable](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IFreezable.md) | Switches the object to "frozen" mode.

Inherited from [IFreezable](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IFreezable.md#freeze). ||
|| [getClosest](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IRectangleGeometryAccess.md#getClosest)([anchorPosition](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IRectangleGeometryAccess.md#getClosest-param-anchorPosition)) | Object | Searches for the point nearest to "anchorPosition" on the rectangle contour. ||
|| [getCoordinates](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IRectangleGeometryAccess.md#getCoordinates)() | Number[][] | Returns coordinates of two opposite corners of the rectangle. ||
|| [isFrozen](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IFreezable.md#isFrozen)() | Boolean | Returns true if the object is in "frozen" mode, otherwise false.

Inherited from [IFreezable](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IFreezable.md#isFrozen). ||
|| [setCoordinates](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IRectangleGeometryAccess.md#setCoordinates)([coordinates](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IRectangleGeometryAccess.md#setCoordinates-param-coordinates)) | [IRectangleGeometryAccess](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IRectangleGeometryAccess.md) | Sets the coordinates of two opposite corners of the rectangle. ||
|| [unfreeze](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IFreezable.md#unfreeze)() | [IFreezable](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IFreezable.md) | Switches the object to active mode.

Inherited from [IFreezable](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IFreezable.md#unfreeze). ||
|#

## Events details {#event_detail}

### change {#change}

Change to corner coordinates. Instance of the [Event](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/Event.md) class. Names of fields that are available via the [Event.get](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/Event.md#get) method: 
- oldCoordinates - Old coordinates of the corners.
- newCoordinates - New coordinates of the corners.

## Methods details {#method_detail}

### contains {#contains}

```javascript
{Boolean} contains(position)
```

Checks whether the passed point is located inside the rectangle.

**Returns** indicator for whether the point belongs to the rectangle.

**Parameters:**

#|
|| **Parameter** | **Default value** | **Description**  ||
|| [`position`](#contains-param-position)[*](*star) | — | Type: Number[]

Coordinates of a point. ||
|#

\* Mandatory parameter/option.

### getClosest {#getClosest}

```javascript
{Object} getClosest(anchorPosition)
```

Searches for the point nearest to "anchorPosition" on the rectangle contour.

**Returns** an object with the following fields: 
- position - The point on the rectangle contour that is nearest to "anchorPosition".
- distance - Distance from "anchorPosition" to "position".

**Parameters:**

#|
|| **Parameter** | **Default value** | **Description**  ||
|| [`anchorPosition`](#getClosest-param-anchorPosition)[*](*star) | — | Type: Number[]

Coordinates of a point for which the nearest rectangle vertex is calculated. ||
|#

\* Mandatory parameter/option.

### getCoordinates {#getCoordinates}

```javascript
{Number[][]} getCoordinates()
```

**Returns** coordinates of two opposite corners of the rectangle.

### setCoordinates {#setCoordinates}

```javascript
{IRectangleGeometryAccess} setCoordinates(coordinates)
```

Sets the coordinates of two opposite corners of the rectangle.

**Returns** self-reference.

**Parameters:**

#|
|| **Parameter** | **Default value** | **Description**  ||
|| [`coordinates`](#setCoordinates-param-coordinates)[*](*star) | — | Type: Number[][]

Coordinates of corners. ||
|#

\* Mandatory parameter/option.

[*star]: Mandatory parameter/option.