Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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