public typealias UIPath = Path extension BackendFeatures { /// Backend methods for path rendering. /// /// These are used by ``Shape`` and related types and modifiers. @MainActor public protocol Paths: Core { /// The underlying path type. Can be a wrapper or subclass. associatedtype Path /// Create a widget that can contain a path. /// /// - Returns: A path widget. func createPathWidget() -> Widget /// Create a path. /// /// - Returns: An empty path. func createPath() -> Path /// Add the instructions from a path to a backend path. /// /// The instructions shouldn't be added to the path again on subsequent updates. Wait for /// `updatePath` to be called with `pointsChanged == true` before re-applying instructions. /// /// If a backend's path isn't mutable, this method should return the new path rather than /// updating it in-place. Alternatively, the old path can be mutated in-place and returned. /// /// - Parameters: /// - path: The backend path to update. /// - source: The path instructions. /// - bounds: The bounds that the path is being rendered within. /// - pointsChanged: An indicator of whether the instructions have changed since the last /// call to this method. The backend can use this to optimize when updates occur. /// - environment: The environment of the path. func updatePath( _ path: Path, _ source: UIPath, bounds: UIPath.Rect, pointsChanged: Bool, environment: EnvironmentValues ) /// Draw a path to the screen. /// /// - Parameters: /// - path: The path to be rendered. /// - container: The container widget that the path will render in. /// Created with ``createPathWidget()``. /// - strokeColor: The color to draw the path's stroke. /// - fillColor: The color to shade the path's fill. /// - overrideStrokeStyle: A value to override the path's stroke style. func renderPath( _ path: Path, container: Widget, strokeColor: Color.Resolved, fillColor: Color.Resolved, overrideStrokeStyle: StrokeStyle? ) } }