Rectangle is a JavaScript object that allows you to interactively manipulate a rectangle via handle objects: two corner handles and a center handle. This code is used in the 2D Geometry section of this site.
Rectangle is a sub-class of the Shape class.
constructor - new Rectangle(svgNode);
This method creates a new Rectangle object. All initialization is handled by the init() method. All parameters for this method are described below.
init() initialized all properties for this object. Handles are created for the upper-lefthand corner, lower-righthand corner and the center of the SVG rect element.
svgNode is an SVG rect element that is to be managed by this object.
realize() constructs the SVG DOM nodes needed to visualize the handles of this widget. Event listeners are registered as needed to implement this object's functionality.
refresh() applies the handle positions to the SVG element associated with this object.
registerHandles() adds all handles used by this object to the mouser's handle list.
unregisterHandles() removes all handles used by this object from the mouser's handle list.
selectHandles() set the current select value for all handles used by this object.
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.
p1 is a handle on the rectangle managed by this object. Adjusting this handle adjusts the rectangle's size.
p2 is a handle on the rectangle managed by this object. Adjusting this handle adjusts the rectangle's size.
This example allows you to adjust the rectangles within the SVG document. Here is a brief summary of the editing procedures:
Rectangle.js - the rectangle object only...cannot be used in isolation
2D.js.gz - all objects needed to use this object and other 2D geometry objects