Path builder is a complete result builder for lifting Path into the declarative SwiftUI world. This @resultBuilder can be used for elegant and short definition of paths. Missing documentation gaps in SwiftUI are filled in using the old but good CGMutablePath knowledge.
Motivation
I just wanted to learn to implement result builders. And during playing with animated paths in SwiftUI found a perfect place to experiment.
Usage
Examples
With PathBuilder you can write this to draw a triangle:
PathBuilder
Path builder is a complete result builder for lifting
Path
into the declarative SwiftUI world. This@resultBuilder
can be used for elegant and short definition of paths. Missing documentation gaps in SwiftUI are filled in using the old but good CGMutablePath knowledge.Motivation
I just wanted to learn to implement result builders. And during playing with animated paths in SwiftUI found a perfect place to experiment.
Usage
Examples
With PathBuilder you can write this to draw a triangle:
Instead of longer version:
Drawing a Swift logo can be implemented like this.
Path components
There are many basic path components present. You can create a new one by conforming to the
PathComponent
protocol.Elementary components
Grouping components
Requirements
For Swift 5.1 to 5.3 use package version 1.1.1.
Otherwise for version 2.0+ use latest tools:
Installation
Using Swift Package Manager in Xcode or by adding to your Package manifest file.
Contributing
All contributions are welcome.
Project was created by Matěj Kašpar Jirásek.
Project is licensed under MIT license.