Rectangle
Source: rectangle.js:31
Rectangle shape.
Constructor
new Rectangle(begin: Point2D, end: Point2D): RectangleParameters
begin(Point2D) — A Point2D representing the beginning of the rectangle.end(Point2D) — A Point2D representing the end of the rectangle.
Instance Methods
getBegin(): Point2D
Get the begin point of the rectangle.
Returns
Point2D— The begin point of the rectangle.
getEnd(): Point2D
Get the end point of the rectangle.
Returns
Point2D— The end point of the rectangle.
equals(rhs: Rectangle): boolean
Check for equality.
Parameters
rhs(Rectangle) — The object to compare to.
Returns
boolean— True if both objects are equal.
getSurface(): number
Get the surface of the rectangle.
Returns
number— The surface of the rectangle.
getWorldSurface(spacing2D: Scalar2D): number
Get the surface of the rectangle according to a spacing.
Parameters
spacing2D(Scalar2D) — The 2D spacing.
Returns
number— The surface of the rectangle multiplied by the given spacing or null for null spacings.
getRealWidth(): number
Get the real width of the rectangle.
Returns
number— The real width of the rectangle.
getRealHeight(): number
Get the real height of the rectangle.
Returns
number— The real height of the rectangle.
getWidth(): number
Get the width of the rectangle.
Returns
number— The width of the rectangle.
getHeight(): number
Get the height of the rectangle.
Returns
number— The height of the rectangle.
getRound(): object
Get the rounded limits of the rectangle.
Returns
object— The rounded limits as {min, max} (Point2D).
getCentroid(): Point2D
Get the centroid of the rectangle.
Returns
Point2D— The centroid point.
contains(point: Point2D, tolerance?: number): boolean
Check if a point is inside the rectangle, or within a tolerance of its outline.
Parameters
point(Point2D) — The point to check.tolerance(number, optional, default: 0) — Optional maximum distance to the outline for an outside point, defaults to 0.
Returns
boolean— True if the point is in the rectangle.
quantify(
viewController: ViewController,
index: Index,
flags: Array.<string>,
): Record.<string, NumberValue>
Quantify a rectangle according to view information.
Parameters
viewController(ViewController) — The associated view controller.index(Index) — The index at which to get the image values.flags(Array.<string>) — A list of stat values to calculate.
Returns
Record.<string,NumberValue>— A quantification object.