Documentation
Reference
2.1.55 (current version)
collection
interactivityModel
Interfaces

geometry.pixel.Polygon

Extends IPixelPolygonGeometry.

The "Polygon" pixel geometry.

Constructor | Fields | Methods

Constructor

geometry.pixel.Polygon(coordinates, fillRule[, metaData])

Parameters:

ParameterDefault valueDescription
coordinates *
[no-highlight[

* Mandatory parameter/option.

]no-highlight]

Type: Number[][][]

Coordinates of the polygon.

fillRule *
[no-highlight[

* Mandatory parameter/option.

]no-highlight]

Type: String

String ID that defines the polygon fill rule. 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.

metaData

Type: Object

Metadata.

metaData.convex false

Type: Boolean

Convex indicator for a polygon. If true, it is convex; if false, it is not. For convex polygons, it is faster to calculate whether points fall in the polygon.

* Mandatory parameter/option.

Fields

NameTypeDescription
eventsIEventManager

Event manager.

Inherited from IEventEmitter.

Methods

NameReturnsDescription
contains(position)

Boolean

Checks whether the passed point is located inside the polygon.

Inherited from IPixelPolygonGeometry.

equals(geometry)

Boolean

Returns true if the passed geometry is equivalent to the given one.

Inherited from IPixelGeometry.

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.

getClosest(anchorPosition)

Object

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

Inherited from IPixelPolygonGeometry.

getCoordinates()

Number[][][]

Returns coordinates of the polygon.

Inherited from IPixelPolygonGeometry.

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.
.

Inherited from IPixelPolygonGeometry.

getLength()

Integer

Returns the number of contours in the polygon.

Inherited from IPixelPolygonGeometry.

getMetaData()

Object

Returns metadata of the pixel geometry.

Inherited from IPixelGeometry.

getType()

String

Returns ID of the geometry type.

Inherited from IBaseGeometry.

scale(factor)

IPixelGeometry

Creates a scaled copy of the geometry.

Inherited from IPixelGeometry.

shift(offset)

IPixelGeometry

Creates a copy of the geometry that is shifted by the specified amount.

Inherited from IPixelGeometry.