A Point is a class describing the position of a graphic. It has two elements, the horizontal offset (in points) and the vertical offset (in points) of the object from the canvas origin. A Point is also the first component of a Rect, which describes both the location (Point) and dimensions (Size) of a graphic.

Creating a Point

An instance of the Point class is created by preceding the class name with the new command, and following the class name with the horizontal offset (in points), and vertical offset (in points) of the object, enclosed in a pair of parens (). The result is a new instance of the Point class:

pt = new Point(72, 90) // [object Point: (72.0, 90.0)]

Class Properties

By default, the Point class has three intrinsic properties for creating a defined point.

ptX = Point.unitX ptY = Point.unitY pt0 = Point.zero

Instance Properties

An instance of the Point class has five properties which can be accessed by scripts.

pt = new Point(200, 200) pt.length //282.842712474619

The value of the length property is the Point’s distance from the canvas origin. In essence, this value is length of the hypotenuse of the right triangle formed by the horizontal and vertical offsets of the point. It is determined using the Pythagorean theorem.

pt = new Point(100, 200) pt.negative
pt = new Point(100, 200) pt.normalized
pt = new Point(100, 200) pt.x
pt = new Point(100, 200) pt.x

Instance Functions

There are three functions you can use to derive a new point based upon an instance of a point, and two functions for deriving a measurement from a point instance.

Here’s an example script that uses the add() instance function with the duplicateTo() graphic function to create a diagonal row of squares:

cnvs = document.windows[0].selection.canvas side = 100 pt = new Point(side,side) shape = cnvs.addShape('Square',new Rect(0,0,side,side)) for(i = 0; i < 3; i++){ shape = shape.duplicateTo(shape.geometry.origin.add(pt)) }

This webpage is in the process of being developed. Any content may change and may not be accurate or complete at this time.