Created
December 26, 2014 17:15
-
-
Save mattt/fb9e595e001ca4653e96 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import CoreGraphics | |
infix operator |> { precedence 50 associativity left } | |
// MARK: CGPoint | |
func +(lhs: CGPoint, rhs: CGPoint) -> CGPoint { | |
return CGPoint(x: lhs.x + rhs.x, y: lhs.y + rhs.y) | |
} | |
func -(lhs: CGPoint, rhs: CGPoint) -> CGPoint { | |
return CGPoint(x: lhs.x - rhs.x, y: lhs.y - rhs.y) | |
} | |
func |>(lhs: CGPoint, rhs: CGAffineTransform) -> CGPoint { | |
return CGPointApplyAffineTransform(lhs, rhs) | |
} | |
// MARK: CGSize | |
func *(lhs: CGSize, rhs: CGFloat) -> CGSize { | |
return CGSize(width: lhs.width * rhs, height: lhs.height * rhs) | |
} | |
func /(lhs: CGSize, rhs: CGFloat) -> CGSize { | |
return CGSize(width: lhs.width / rhs, height: lhs.height / rhs) | |
} | |
func |>(lhs: CGSize, rhs: CGAffineTransform) -> CGSize { | |
return CGSizeApplyAffineTransform(lhs, rhs) | |
} | |
// MARK: CGRect | |
func |(lhs: CGRect, rhs: CGRect) -> CGRect { | |
return CGRectUnion(lhs, rhs) | |
} | |
func &(lhs: CGRect, rhs: CGRect) -> CGRect { | |
return CGRectIntersection(lhs, rhs) | |
} | |
func /(lhs: CGRect, rhs: (amount: CGFloat, edge: CGRectEdge)) -> (slice: CGRect, remainder: CGRect) { | |
return lhs.rectsByDividing(rhs.amount, fromEdge: rhs.edge) | |
} | |
func *(lhs: CGRect, rhs: CGFloat) -> CGRect { | |
return CGRect(origin: lhs.origin, size: lhs.size * rhs) | |
} | |
func |>(lhs: CGRect, rhs: CGAffineTransform) -> CGRect { | |
return CGRectApplyAffineTransform(lhs, rhs) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment