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

# IPixelPolygonGeometry

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

Interface for the "Polygon" pixel geometry.

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

## Constructor {#constructor-summary}

```javascript
IPixelPolygonGeometry()
```

## Fields {#properties-summary}

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

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

## Methods {#methods-summary}

#|
|| **Name** | **Returns** | **Description** ||
|| [contains](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IPixelPolygonGeometry.md#contains)([position](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IPixelPolygonGeometry.md#contains-param-position)) | Boolean | Checks whether the passed point is located inside the polygon. ||
|| [equals](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IPixelGeometry.md#equals)([geometry](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IPixelGeometry.md#equals-param-geometry)) | Boolean | Returns true if the passed geometry is equivalent to the given one.

Inherited from [IPixelGeometry](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IPixelGeometry.md#equals). ||
|| [getBounds](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IBaseGeometry.md#getBounds)() | Number[][]\|null | Returns coordinates of the two opposite corners of the area that surrounds the geometry. The first item in the array is the corner with the smallest coordinate values relative to the rest of the points in the area; the second item is the corner with the largest coordinate values.

Inherited from [IBaseGeometry](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IBaseGeometry.md#getBounds). ||
|| [getClosest](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IPixelPolygonGeometry.md#getClosest)([anchorPosition](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IPixelPolygonGeometry.md#getClosest-param-anchorPosition)) | Object | Searches for the point nearest to "anchorPosition" on the polygon contour. ||
|| [getCoordinates](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IPixelPolygonGeometry.md#getCoordinates)() | Number[][][] | Returns coordinates of the polygon. ||
|| [getFillRule](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IPixelPolygonGeometry.md#getFillRule)() | String | Returns string ID that defines the polygon fill rule. The ID accepts one of two values: 
- evenOdd - Algorithm that checks whether a point is located in the fill area by drawing a ray from this point to infinity 	in any direction, and counting the number of contour segments in this shape that are crossed by this ray. If the number is odd, the point is inside it; if even, the point is outside it.
- nonZero - Algorithm that checks whether a point is located in the fill area by drawing a ray from this point to infinity 	in any direction, and checking the points at which a segment of the shape crosses this ray. Starting 	from zero, one is added each time a segment crosses the ray from left to right, and one is subtracted each time a segment 	crosses the ray from right to left. If the result equals zero, the point 	is inside the contour. Otherwise, it is outside it. ||
|| [getLength](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IPixelPolygonGeometry.md#getLength)() | Integer | Returns the number of contours in the polygon. ||
|| [getMetaData](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IPixelGeometry.md#getMetaData)() | Object | Returns metadata of the pixel geometry.

Inherited from [IPixelGeometry](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IPixelGeometry.md#getMetaData). ||
|| [getType](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IBaseGeometry.md#getType)() | String | Returns ID of the geometry type.

Inherited from [IBaseGeometry](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IBaseGeometry.md#getType). ||
|| [scale](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IPixelGeometry.md#scale)([factor](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IPixelGeometry.md#scale-param-factor)) | [IPixelGeometry](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IPixelGeometry.md) | Creates a scaled copy of the geometry.

Inherited from [IPixelGeometry](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IPixelGeometry.md#scale). ||
|| [shift](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IPixelGeometry.md#shift)([offset](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IPixelGeometry.md#shift-param-offset)) | [IPixelGeometry](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IPixelGeometry.md) | Creates a copy of the geometry that is shifted by the specified amount.

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

## Methods details {#method_detail}

### contains {#contains}

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

Checks whether the passed point is located inside the polygon.

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

**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 polygon contour.

**Returns** an object with the following fields: 
- position - The point on the polygon contour that is nearest to "anchorPosition".
- distance - Distance from "anchorPosition" to "position".
- closestPointIndex - Index of the polygon vertex closest to "position".
- nextPointIndex - Index of the polygon vertex that follows "position".
- prevPointIndex - Index of the polygon vertex that precedes "position".
- pathIndex - Index of the polygon contour that the found point is associated with.
The "nextPointIndex" and "prevPointIndex" fields may be omitted if "position" coincides with one of the polygon vertexes.

**Parameters:**

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

Coordinates of a point for which the nearest vertex on the polygon contour is calculated. ||
|#

\* Mandatory parameter/option.

### getCoordinates {#getCoordinates}

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

**Returns** coordinates of the polygon.

### getFillRule {#getFillRule}

```javascript
{String} getFillRule()
```

**Returns** string ID that defines the polygon fill rule. The ID accepts one of two values: 
- evenOdd - Algorithm that checks whether a point is located in the fill area by drawing a ray from this point to infinity 	in any direction, and counting the number of contour segments in this shape that are crossed by this ray. If the number is odd, the point is inside it; if even, the point is outside it.
- nonZero - Algorithm that checks whether a point is located in the fill area by drawing a ray from this point to infinity 	in any direction, and checking the points at which a segment of the shape crosses this ray. Starting 	from zero, one is added each time a segment crosses the ray from left to right, and one is subtracted each time a segment 	crosses the ray from right to left. If the result equals zero, the point 	is inside the contour. Otherwise, it is outside it.

### getLength {#getLength}

```javascript
{Integer} getLength()
```

**Returns** the number of contours in the polygon.

[*star]: Mandatory parameter/option.