CGPoint
struct CGPoint
-
Mechanica
Returns the distance between
selfand anotherpoint..Declaration
Swift
public func distance(to point: CGPoint) -> CGFloatParameters
pointThe point to which to calculate the distance.
Return Value
the distance between
selfandpoint. -
Mechanica
Checks if a point is on a straight line.
Declaration
Swift
public func isOnStraightLine(passingThrough firstPoint: CGPoint, and secondPoint: CGPoint) -> BoolParameters
firstPointThe first point that defines a straight line.
secondPointThe second point that defines a straight line.
Return Value
true if
selflies on the straigth lined defined byfirstPointandsecondPoint.
-
Mechanica
Adds two
CGPoints.Example:
CGPoint(x: 1, y: 2) + CGPoint(x: 10, y: 11) -> CGPoint(x: 11, y: 13)Declaration
Swift
public static func + (lhs: CGPoint, rhs: CGPoint) -> CGPoint -
Mechanica
Adds a
CGPointtoself.Example:
var point = CGPoint(x: 1, y: 2) point += CGPoint(x: 0, y: 0) -> point is equal to CGPoint(x: 11, y: 13)Declaration
Swift
public static func += (lhs: inout CGPoint, rhs: CGPoint) -
Mechanica
Subtracts two
CGPoints.Example:
CGPoint(x: 1, y: 2) - CGPoint(x: 10, y: 11) -> CGPoint(x: -9, y: -9)Declaration
Swift
public static func - (lhs: CGPoint, rhs: CGPoint) -> CGPoint -
Mechanica
Subtracts a
CGPointfromself.Example:
var point = CGPoint(x: 1, y: 2) point -= CGPoint(x: 10, y: 11) -> point is equal to CGPoint(x: -9, y: -9)Declaration
Swift
public static func -= (lhs: inout CGPoint, rhs: CGPoint) -
Mechanica
Multiplies a
CGPointwith a scalar.Example:
CGPoint(x: 1, y: 2) * 3 -> CGPoint(x: 3, y: 6)Declaration
Swift
public static func * (point: CGPoint, scalar: CGFloat) -> CGPoint -
Mechanica
Multiply
selfwith a scalar.Example:
var point = CGPoint(x: 1, y: 2) point *= 3 -> point is equal to CGPoint(x: 3, y: 6)Declaration
Swift
public static func *= (point: inout CGPoint, scalar: CGFloat)
CGPoint Extension Reference