QuickDraw-inspired region boolean operations rendered with SwiftUI’s Canvas and GraphicsContext.
This project explores how to model and draw region operations such as union, intersection, difference, and xor using modern SwiftUI APIs, while acknowledging the current limitations around true vector boolean path composition.
- Enum-based region model: compose regions with
.primitive(Path),.union,.intersection,.difference,.xor. - Rendering via
CanvasandGraphicsContext. - Layered clipping approach to visually approximate boolean operations.
- Clear separation between “drawing” and “materializing” a path.
Classic QuickDraw regions supported boolean composition of shapes. SwiftUI’s Path does not yet expose full geometric boolean operations. This repo demonstrates:
- How to represent region expressions declaratively.
- How to render those expressions in SwiftUI using layered clips.
- Where the current API boundaries are and how to bridge beyond them if needed.
QDRegionView accepts a QDRegion.Op and draws it inside a Canvas.
- Primitive
- Directly filled with the current foreground style:
context.fill(path, with: .foreground)