🎨
Graphicz Light-weight, operator-overloading-free complements to CoreGraphics!
Even though I shipped it with my app, I still need to invest the time to set this up, and finalize the API. Contributors welcome!
Highlights
-
Operator Overloading Free:
It's just an opinion, but this is a crucial difference. -
Ready For Contributors:
Basic additions toCGRect
and other structs added to show contributors the way! PRs welcome! (I certainly will be submitting some throughout my career) -
Full Test Coverage:
This library requires full test coverage in order to eliminate human error as much as possible.
Features
You can try them in the playground shipped with the framework!
CGRect
Convenient properties:
let rect = CGRect(x: 10, y: 10, width: 80, height: 40)
rect.center // x: 50, y: 30
rect.aspectRatio // 2
Update functions:
var newRect = rect.update(width: 60)
newRect.updateInPlace(x: 20)
newRect.updateInPlace(origin: CGPoint.zero)
Edge functions:
newRect.insetEdges(left: 20) // Push in the left edge
newRect.insetEdges(bottom: -5) // Push down the bottom
CGVector
Convenient properties:
let vector = CGVector(dx: -5, dy: 0)
vector.angle // π
vector.magnitude // 5
Convenient initializers:
let unitVector = CGVector(angle: .pi/2)
unitVector.dx // 0
unitVector.dy // 1
Motivation
Every once in a while, one might find themself writing layout code manually. Auto layout may work for many, but for the rest of us, doing manual layout calculation is something we do regularly. It does become tedious very quickly, but with the help of such a convenient set of additions, things tend to get simpler and more fun, even.
Author
Maz (@Mazyod)
License
Graphicz is released under the MIT license. See LICENSE for details.