A structure that contains a point in a two-dimensional ( x , y ) coordinate system.
Usage
const CGPoint = ; // Create point representing two coordinates in 2D spacelet point = 5 10;console; // 5, 10 //Default valueslet defaultPoint = ; // null, null
Static Methods and Properties
CGPoint . zero
Returns a point constant with location (0,0). The zero point is equivalent to CGPoint(0,0).
let point = 0 0;point; //true let other = 1 1;other; //false
CGPoint . null
Unlike CGPoint.zero, CGPoint.null has no assigned position. Both coordinates are null
let point = null null;point; //true let defaultPoint = ;defaultPoint; //true let other = 1 1;other; //false
CGPoint . infinite
Returns a point constant with location (Infinity, Infinity). An infinite point is one that has no defined bounds. .
let point = Infinity Infinity;point; //true let other = 1 1;other; //false
CGPoint . fromString( str )
Returns a CGPoint instance from the string. If string is malformed, it returns a CGPoint.zero
let point = "{1,2}";console; //1,2 let other = "%##@$#@";console; //0,0
Instance Methods and Properties
#isEmpty
Returns true if point is empty. An empty point is either a null point or a valid point with zero x or y.
let one = 0 0;console; // true let two = null null;console; // true let three = Infinity Infinity;console; // false
#isNull
Returns true if both point coordinates are null.
let one = 0 0;console; // false let two = null null;console; // true let three = Infinity Infinity;console; // false
#isInfinite
Returns true if point is infinite. An infinite point is one that has no defined bounds
let one = 0 0;console; // false let two = null null;console; // false let three = Infinity Infinity;console; // true
#integral
A point with the smallest integer values for its x and y coorindates. That is, given a point with fractional x or y values, integral rounds down the points x or y coordinates to the nearest whole integer. Returns a null point if rect is a null point.
let double = 15 -15;console; // {1,-2}
equalTo ( point: CGPoint )
Checks if a point has the same x, y coordinates as another (inclusive)
let point = 1 1;let other = -2 -2; point; //false let match = 1 1;point; //true
toString ( point )
Produces a string representation of the point
let point = 1 1;console // {1,1}