暂无描述

CGPointExt.swift 1.4KB

    // // CGPointExt.swift // ExtensionKit // // Created by FFIB on 2017/9/13. // Copyright © 2017年 FFIB. All rights reserved. // import UIKit extension CGPoint { public static func + (lhs: CGPoint, rhs: CGPoint) -> CGPoint { return CGPoint(x: lhs.x + rhs.x, y: lhs.y + rhs.y) } public static func - (lhs: CGPoint, rhs: CGPoint) -> CGPoint { return CGPoint(x: lhs.x - rhs.x, y: lhs.y - rhs.y) } public static func * (lhs: CGPoint, rhs: CGPoint) -> CGPoint { return CGPoint(x: lhs.x * rhs.x, y: lhs.y * rhs.y) } public static func / (lhs: CGPoint, rhs: CGPoint) -> CGPoint { return CGPoint(x: lhs.x / rhs.x, y: lhs.y / rhs.y) } public static func += (lhs:CGPoint, rhs: CGPoint) -> CGPoint { return lhs + rhs } public static func -= (lhs:CGPoint, rhs: CGPoint) -> CGPoint { return lhs - rhs } public static func *= (lhs:CGPoint, rhs: CGPoint) -> CGPoint { return lhs * rhs } public static func /= (lhs:CGPoint, rhs: CGPoint) -> CGPoint { return lhs / rhs } public func distance(to target: CGPoint) -> CGFloat { return sqrt(pow(self.x - target.x, 2) + pow(self.y - target.y, 2)) } public static func == (lhs: CGPoint, rhs: CGPoint) -> Bool { return lhs.x == rhs.x && lhs.y == rhs.y } }