Last active
December 12, 2022 18:25
-
-
Save nonisolated/9f72b632b1f9d6ed9b42ec3c7b245ea5 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