IPixelRectangleGeometry

Extends IPixelGeometry.

Interface for the "Rectangle" pixel geometry.

Constructor | Fields | Methods

Constructor

IPixelRectangleGeometry()

Fields

Name Type Description
events IEventManager

Event manager.

Inherited from IEventEmitter.

Methods

Name Returns Description
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 rectangle.

getCoordinates()

Number[][]

Returns coordinates of two opposite corners of the rectangle.

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.

Methods details

getClosest

{Object} getClosest(anchorPosition)

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

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

Parameters:

Parameter Default value Description
anchorPosition *

Type: Number[]

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

* Mandatory parameter/option.

getCoordinates

{Number[][]} getCoordinates()

Returns coordinates of two opposite corners of the rectangle.