Last active
June 26, 2017 10:19
-
-
Save charlieelliott/c2e490d119e1ecda0a83 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
extension CGPoint { | |
mutating func move(x:Int? = nil, y:Int? = nil) -> CGPoint { | |
if let i = x { | |
self.x += CGFloat(i) | |
} | |
if let i = y { | |
self.y += CGFloat(i) | |
} | |
return self | |
} | |
mutating func up(y:Int) -> CGPoint { | |
return move(y: -y) | |
} | |
mutating func down(y:Int) -> CGPoint { | |
return move(y: y) | |
} | |
mutating func left(x:Int) -> CGPoint { | |
return move(x: -x) | |
} | |
mutating func right(x:Int) -> CGPoint { | |
return move(x: x) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I like the idea but anyway here is a bit cleaner version of it