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!
Operator Overloading Free:
It's just an opinion, but this is a crucial difference.
Ready For Contributors:
Basic additions to
CGRectand 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.
You can try them in the playground shipped with the framework!
let rect = CGRect(x: 10, y: 10, width: 80, height: 40) rect.center // x: 50, y: 30 rect.aspectRatio // 2
var newRect = rect.update(width: 60) newRect.updateInPlace(x: 20) newRect.updateInPlace(origin: CGPoint.zero)
newRect.insetEdges(left: 20) // Push in the left edge newRect.insetEdges(bottom: -5) // Push down the bottom
let vector = CGVector(dx: -5, dy: 0) vector.angle // π vector.magnitude // 5
let unitVector = CGVector(angle: .pi/2) unitVector.dx // 0 unitVector.dy // 1
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.
Graphicz is released under the MIT license. See LICENSE for details.