$ show onmyway133/Snowflake
Snowflake is an SVG rendering library for iOS/macOS that parses SVG XML data and renders it using native CALayer and UIBezierPath. The architecture follows a modular design with separate components for document parsing, SVG element handling, style interpretation, path parsing, and utility functions. Key entry points are Document.init(data:) for parsing SVG data and SVG.view(size:) or SVG.layers(size:) for rendering. The library transforms SVG elements into shape objects that create UIBezierPath instances, which are then converted to styled CAShapeLayer objects for display. It supports inline styling, CSS-style attributes, animations, scaling, and base64-embedded images.
The LLM identified 5 files worth highlighting for reuse:
Implements a robust SVG path data parser that handles all standard SVG path commands (M, L, C, Q, A, Z, etc.) with proper absolute/relative coordinate handling. Demonstrates the command pattern for parsing vector graphics instructions and is isolated enough to be extracted with minimal dependencies.
Provides essential utility functions for parsing numbers and points from strings, calculating aspect ratios for scaling, computing bounding boxes of graphical elements, and applying affine transformations. Demonstrates well-scoped, pure utility functions with no side effects that could be reused in any graphics-related project.
Encapsulates common Core Animation patterns for shape layers, providing easy-to-use stroke and opacity animations. Demonstrates good encapsulation of animation logic that would otherwise be repeated throughout an application, making animation implementation consistent and concise.
Implements comprehensive color parsing from hex strings, rgb() functional notation, and named CSS colors, backed by an extensive color dictionary. Demonstrates proper separation of concerns between color parsing logic and color data, with robust error handling and fallback to clear color.
Parses SVG style attributes from both inline attributes and CSS-style style attributes, converting SVG-specific values to CoreGraphics equivalents. Demonstrates robust attribute parsing with proper fallback handling and value conversion, handling complex CSS-like syntax in a clean, maintainable way.