CGPoint

struct CGPoint
  • Mechanica

    Returns the distance between self and another point..

    Declaration

    Swift

    public func distance(to point: CGPoint) -> CGFloat

    Parameters

    point

    The point to which to calculate the distance.

    Return Value

    the distance between self and point.

  • Mechanica

    Checks if a point is on a straight line.

    Declaration

    Swift

    public func isOnStraightLine(passingThrough firstPoint: CGPoint, and secondPoint: CGPoint) -> Bool

    Parameters

    firstPoint

    The first point that defines a straight line.

    secondPoint

    The second point that defines a straight line.

    Return Value

    true if self lies on the straigth lined defined by firstPoint and secondPoint.

  • 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 CGPoint to self.

    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 CGPoint from self.

    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 CGPoint with 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 self with 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)