Skip to content

Instantly share code, notes, and snippets.

@laevandus
Created April 9, 2020 12:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save laevandus/07955ff394984bda6de4922734429c84 to your computer and use it in GitHub Desktop.
Save laevandus/07955ff394984bda6de4922734429c84 to your computer and use it in GitHub Desktop.
import CoreGraphics
extension CGRect {
init(center: CGPoint, size: CGSize) {
self.init(x: center.x - size.width / 2.0, y: center.y - size.height / 2.0, width: size.width, height: size.height)
}
var center: CGPoint { return CGPoint(x: midX, y: midY) }
}
extension CGSize {
var innerRadius: CGFloat { return min(width, height) / 2.0 }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment