Reference

Methods

This method creates a new Polygon object. All initialization is handled by the init() method. All parameters for this method are described below

init(svgNode);

init() initialized all properties for this object. This method parses the points attribute of the svgNode. Each vertex is used to create an associated Handle object.

svgNode is an SVG polygon element to be managed by this object.

realize();

realize() constructs the SVG DOM nodes needed to visualize the handles of this widget. Any event listeners that are used by this object will be registered by this method.

refresh();

refresh() applies the handle positions to the SVG element associated with this object.

registerHandles();

registerHandles() adds all handles used by this object to the mouser's handle list.

unregisterHandles();

unregisterHandles() removes all handles used by this object from the mouser's handle list.

selectHandles();

selectHandles() set the current select value for all handles used by this object.

showHandles();

showHandles() sets the current visibility value for all handles used by this object.

getIntersectionParams() : IntersectionParams;

This method returns an IntersectionParams object to specify this shape's name and the necessary parameters to find the intersection of this shape with another. The name is used by the Intersection object to determine which intersection routine to call.

pointInPolygon(point) : boolean;

pointInPolygon() determines if the specified Point2D is within the polygon.

getArea() : float;

getArea() returns the area of the polygon managed by this object. Negative values are returned for polygons whose vertices are drawn in a clockwise order. Please note that the current implementation does not return correct values for self-intersecting polygons.

isClockwise() : boolean;

isClockwise() determines if the vertices of the polygon are in a clockwise order.

isCounterClockwise() : boolean;

isCounterClockwise() determines if the vertices of the polygon are in a counter-clockwise order.

isConcave() : boolean;

isConcave() determines if the polygon is concave.

isConvex() : boolean;

isConvex() determines if the polygon is convex.

setCallback(callback);

setCallback() sets the callback property of all handles to the specified value.

Properties

handles is an array of Handles. Each handle corresponds to a vertex on the polygon

Example

This example allows you to adjust the vertices of the polygons within the SVG document. Here is a brief summary of the editing procedures:

Click an unselected polygon once to select it.

Click a selected polygon to select all of its handles.

Shift-click an unselected polygon to add all of its handles it to the current selection.

Shift-click a selected polygon to remove it from the current selection.