Created
January 16, 2019 04:27
-
-
Save almaleh/7d4ca4fa4ec0fc9acabc59491a6c2003 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
func calculateRectBetween(lastPoint: CGPoint, newPoint: CGPoint) -> CGRect { | |
let originX = min(lastPoint.x, newPoint.x) - (lineWidth / 2) | |
let originY = min(lastPoint.y, newPoint.y) - (lineWidth / 2) | |
let maxX = max(lastPoint.x, newPoint.x) + (lineWidth / 2) | |
let maxY = max(lastPoint.y, newPoint.y) + (lineWidth / 2) | |
let width = maxX - originX | |
let height = maxY - originY | |
return CGRect(x: originX, y: originY, width: width, height: height) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment