An Objective-C wrapper for CoreGraphics CGContext providing a fluent, cross-platform drawing API for iOS and macOS.
MPWDrawingContext is an Objective-C wrapper for Apple's CoreGraphics CGContextRef that provides a fluent, object-oriented drawing API. It solves the problem of CoreGraphics' C-based API being closed to extension and somewhat unpleasant to use by offering chainable methods, block-based drawing, and a unified interface for both iOS and macOS.
iOS and macOS developers who work with CoreGraphics directly and want a more concise, extensible, and cross-platform drawing interface.
Developers choose MPWDrawingContext because it reduces drawing code by 20-30%, eliminates platform-specific differences, and provides a more pleasant, chainable API compared to raw CoreGraphics function calls.
An Objective-C wrapper for CoreGraphics CGContext
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Enables chainable drawing commands like `[[context moveto:0 :0] lineto:100 :0] stroke`, significantly reducing verbosity compared to CoreGraphics function calls as shown in the README examples.
Provides identical APIs on iOS and macOS via MPWView, allowing the same drawing code to run on both platforms without modifications, eliminating platform-specific boilerplate.
Supports blocks for drawing commands, shadows, and deferred rendering (e.g., `-layerWithSize:content:`), simplifying view creation and reducing the need for subclassing.
The MPWDrawingContext protocol has no dependencies on AppKit, UIKit, or CoreGraphics, making it extensible for future implementations beyond Apple's ecosystem, as noted in the philosophy.
The README explicitly admits text rendering is 'very rudimentary' with only a basic -show: method, lacking advanced features like CoreText integration or rich typography controls.
As an Objective-C wrapper, it doesn't natively support Swift modern conventions, requiring bridging and potentially feeling outdated in Swift-centric projects.
Initial versions aimed for lightweight inclusion, but the README notes it has expanded to multiple classes (e.g., for PDF and Bitmap contexts), increasing integration overhead.