A Swift playground demonstrating two approaches (protocol-oriented and enum-oriented) for drawing diagrams using value types.
Swift-Diagram-Playgrounds is a collection of Swift playgrounds that demonstrate two different approaches—protocol-oriented and enum-oriented design—for creating and drawing diagrams as value types. It adapts Apple's WWDC 2015 sample code to explore how these architectures handle shape representation, transformations, and rendering using Core Graphics.
Swift developers interested in design patterns, protocol-oriented programming, functional programming techniques, or educational resources for diagram generation in Swift.
Developers choose this project to compare practical implementations of protocol-oriented vs. enum-oriented designs in a visual context, using real Swift code updated for modern versions, with clear examples of trade-offs like extensibility and transformation handling.
Drawing diagrams in Swift using a recursive enum data structure
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Provides a clear, practical example of Apple's protocol-oriented programming approach from WWDC 2015, using structs conforming to a Drawable protocol for extensible shape representation.
Offers a contrasting functional-style architecture with a recursive enum (Diagram) to store shape data, showcasing how to handle tree-like structures and transformations differently.
Illustrates bridging high-level abstractions with low-level Core Graphics by drawing diagrams into a CGContext, making it a hands-on resource for graphics programming in Swift.
Includes multiple playground pages with example diagrams, allowing developers to interactively explore and compare the two design patterns without setting up a full project.
Based on Swift 3, which is significantly outdated; developers must manually update the code for modern Swift versions (e.g., Swift 5+), as noted by the README's Swift 3 badge.
Primarily an educational sample, not a maintained library—it lacks features like error handling, performance optimizations, or integration with modern SwiftUI or UIKit frameworks.
Relies on Swift playgrounds with known issues like continuous redrawing in livePreview (requiring manual stop), making it cumbersome for repeated use or debugging in real apps.