Bez is a swift package aimed at making BĂ©zier curves easy to work with and manipulate. Try out the PathEditor
for a quick way to get started!
The various utilities included are:
- Interpolation Functions
- Derivatives
- Arc Lengths
- Segmentation
- Subdivision
- Lookup Table Generation
- Path Description -> Normalized SwiftUI Shape Conversion
Quick Start
- Snag that URL from the github repo
- In Xcode -> File -> Swift Packages -> Add Package Dependencies
- Paste the URL Into the box
- Specify the minimum version number (1.0.5)
- Copy/Paste the following snippet Into The ContentView.swift file
import SwiftUI
import bez
struct ContentView: View {
@ObservedObject var polybezier: PolyBezier = PolyBezier(Circle().path(in: .init(x: 50, y: 100, width: 100, height: 100)))
var body: some View {
NavigationView {
PathEditor(polybezier: _polybezier, name: "Shape",
save: { (name , path) in print(path)})
.navigationBarTitle("Bez Editor", displayMode: .inline)
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView().colorScheme(.dark)
}
}
Mathematical Background
Example Uses
The PSlider
component of the Sliders SwiftUI Library