Sg2.0
Point
Packages

The Point object represents a point in the two dimensional space of the Illustrator document. Some functions also use it as a two dimensional vector object.

Constructors

Parameters:
x: Number
y: Number
Parameters:
pt: Point
Parameters:
p: Point
Parameters:
map: Object

Functions

Returns the addition of the supplied point to the point object as a new point. The object itself is not modified! Sample code:
 var firstPoint = new Point(5,10);
 var secondPoint = new Point(10,20);
 var thirdPoint = firstPoint.add(secondPoint);
 print(thirdPoint); // returns { x: 15.0, y: 30.0 }
 
Parameters:
pt: Point - the point to add
Returns:
Point - the addition of the two points as a new point
Returns the addition of the supplied x and y values to the point object as a new point. The object itself is not modified! Sample code:
 var firstPoint = new Point(5,10);
 var secondPoint = firstPoint.add(10,20);
 print(secondPoint); // returns { x: 15.0, y: 30.0 }
 
Parameters:
x: Number - the x value to add
y: Number - the y value to add
Returns:
Point - the addition of the two points as a new point
Returns a copy of the point. This is useful as the following code only generates a flat copy:
 var point1 = new Point();
 var point2 = point1;
 point2.x = 1; // also changes point1.x
 
 var point2 = pt1.clone();
 point2.x = 1; // doesn't change point1.x
 
Returns:
Object - the cloned point
Returns the dot product of the point and another point.
Parameters:
pt: Point
Returns:
Number - the dot product of the two points
Parameters:
pt: Point
Returns:
Number
Parameters:
px: Number
py: Number
Returns:
Number
Parameters:
pt: Point
Returns:
Number
Parameters:
px: Number
py: Number
Returns:
Number
Parameters:
pt: Point
Returns:
Number
Returns the interpolation point between the point and another point. The object itself is not modified!
Parameters:
pt: Point
t: Number - the position between the two points as a value between 0 and 1
Returns:
Point - the interpolation point
Checks if the point is within a given distance of another point
Parameters:
pt: Point - the point to check against
tolerance: Number - the maximum distance allowed
Returns:
Boolean - true if it is within the given distance, false otherwise
Checks wether the point is inside the rectangle
Parameters:
rect: Rectangle - the rectangle to check against
Returns:
Boolean - true if the point is inside the rectangle, false otherwise
Returns the multiplication of the point object by the supplied point as a new point. The object itself is not modified! Sample code:
 var firstPoint = new Point(5,10);
 var secondPoint = new Point(4,2);
 var thirdPoint = firstPoint.multiply(secondPoint);
 print(thirdPoint); // returns { x: 20.0, y: 20.0 }
 
Parameters:
pt: Point - the point to multiply with
Returns:
Point - the multiplication of the two points as a new point
Returns the multiplication of the point object by the supplied x and y values as a new point. When no y value is supplied, the point's x and y values are multiplied by scale (x). The object itself is not modified! Sample code:
 var firstPoint = new Point(5,10);
 
 var secondPoint = firstPoint.multiply(4,2);
 print(secondPoint); // returns { x: 20.0, y: 20.0 }
 
 var secondPoint = firstPoint.multiply(2);
 print(secondPoint); // returns { x: 10.0, y: 20.0 }
 
Parameters:
x: Number - the x (or scale) value to multiply with
y: Number - the y value to multiply with
Returns:
Point - the multiplication of the two points as a new point
Parameters:
length: Number
Returns:
Returns the projection of the point on another point. Both points are interpreted as vectors.
Parameters:
pt: Point
Returns:
Point - the project of the point on another point
Rotates a point. The object itself is not modified!
Parameters:
theta: Number - the rotation angle in radians
Returns:
Point - the rotated point
Parameters:
x: Number
y: Number
Returns the subtraction of the supplied point to the point object as a new point. The object itself is not modified! Sample code:
 var firstPoint = new Point(10,20);
 var secondPoint = new Point(5,5);
 var thirdPoint = firstPoint.subtract(secondPoint);
 print(thirdPoint); // returns { x: 5.0, y: 15.0 }
 
Parameters:
pt: Point - the point to subtract
Returns:
Point - the subtraction of the two points as a new point
Returns the subtraction of the supplied x and y values to the point object as a new point. The object itself is not modified! Sample code:
 var firstPoint = new Point(10,20);
 var secondPoint = firstPoint.subtract(5,5);
 print(secondPoint); // returns { x: 5.0, y: 15.0 }
 
Parameters:
x: Number - The x value to subtract
y: Number - The y value to subtract
Returns:
Point - the subtraction of the two points as a new point
Parameters:
m: Matrix
Returns: