Circle is a JavaScript object that allows you to interactively manipulate a circle via Handle objects: a center handle and a radius handle. This code is used in the 2D Geometry section of this site.
The circle object includes methods for finding the intersection of a circle with a circle and the intersection of a circle with a line.
Circle is a sub-class of the Shape class and therefore inherits all methods and properties of the Shape class.
constructor - new Circle(svgNode);
This method creates a new Circle 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 center and the radius of the SVG circle element.
svgNode is an SVG circle 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.
translate() translates the SVG element and the associated handles by the specified amount.
delta is a Point2D.
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.
center is a handle at the center of the circle managed by this object.
last is a Point2D that is used to update a circle when the center handle is being dragged.
radius is a handle on the circle managed by this object. Adjusting this handle adjusts the circle's radius.
This example allows you to adjust the position and radius of the circles within the SVG document. Here is a brief summary of the editing procedures:
Circle.js - the circle object only...cannot be used in isolation
2D.js.gz - all objects needed to use this object and other 2D geometry objects