func +(left: CGPoint, right: CGPoint)->CGPoint{ return CGPoint(x: left.x+right.x, y: left.y+right.y) } prefix func -(right: CGPoint)->CGPoint{ return CGPoint(x: -right.x, y: -right.y) } func -(left: CGPoint, right: CGPoint)->CGPoint{ return left + (-right) }
func *(left: CGPoint, right: CGFloat)->CGPoint{ return CGPoint(x: left.x*right, y: left.y*right) } func *(left: CGFloat, right: CGPoint)->CGPoint{ return right*left } func /(left: CGPoint, right: CGFloat)->CGPoint{ return left*(1/right) }
func +=(inout left:CGPoint, right:CGPoint){ left = left+right } func -=(inout left:CGPoint, right:CGPoint){ left = left-right } func *=(inout left:CGPoint, right:CGFloat){ left = left*right } func /=(inout left:CGPoint, right:CGFloat){ left = left/right }
func *(left: CGPoint, right: CGPoint)->CGFloat{ return left.x*right.x + left.y*right.y } func ^(left: CGPoint, right: CGPoint)->CGFloat{ return left.x*right.y - left.y*right.x }
func *(left: CGPoint, right: CGAffineTransform)->CGPoint{ return CGPointApplyAffineTransform(left, right) } func *=(inout left:CGPoint, right:CGAffineTransform){ left = left*right }
func *(left: CGAffineTransform, right: CGAffineTransform)->CGAffineTransform{ return CGAffineTransformConcat(left, right) } func *=(inout left:CGAffineTransform, right:CGAffineTransform){ left = left*right }
import Foundation func +(left: CGPoint, right: CGPoint)->CGPoint{ return CGPoint(x: left.x+right.x, y: left.y+right.y) } prefix func -(right: CGPoint)->CGPoint{ return CGPoint(x: -right.x, y: -right.y) } func -(left: CGPoint, right: CGPoint)->CGPoint{ return left + (-right) } /////////////////////////////////////////////////// func *(left: CGPoint, right: CGFloat)->CGPoint{ return CGPoint(x: left.x*right, y: left.y*right) } func *(left: CGFloat, right: CGPoint)->CGPoint{ return right*left } func /(left: CGPoint, right: CGFloat)->CGPoint{ return left*(1/right) } /////////////////////////////////////////////////// func +=(inout left:CGPoint, right:CGPoint){ left = left+right } func -=(inout left:CGPoint, right:CGPoint){ left = left-right } func *=(inout left:CGPoint, right:CGFloat){ left = left*right } func /=(inout left:CGPoint, right:CGFloat){ left = left/right } /////////////////////////////////////////////////// /////////////////////////////////////////////////// func *(left: CGPoint, right: CGPoint)->CGFloat{ return left.x*right.x + left.y*right.y } func /(left: CGPoint, right: CGPoint)->CGFloat{ return left.x*right.y - left.y*right.x } /////////////////////////////////////////////////// /////////////////////////////////////////////////// func *(left: CGPoint, right: CGAffineTransform)->CGPoint{ return CGPointApplyAffineTransform(left, right) } func *=(inout left:CGPoint, right:CGAffineTransform){ left = left*right } /////////////////////////////////////////////////// func *(left: CGAffineTransform, right: CGAffineTransform)->CGAffineTransform{ return CGAffineTransformConcat(left, right) } func *=(inout left:CGAffineTransform, right:CGAffineTransform){ left = left*right }
Source: https://habr.com/ru/post/271647/
All Articles