Skip to content

Commit

Permalink
Add transform path component
Browse files Browse the repository at this point in the history
  • Loading branch information
mkj-is committed Sep 30, 2019
1 parent ac7af19 commit d3d6eea
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Sources/PathBuilder/Path components/Transform.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import SwiftUI

/// Appends another transformed subpath object to the path.
public struct Transform: PathComponent {
private let transform: CGAffineTransform
private let path: Path

/// Initializes path component, which appends another transformed subpath object to the path.
/// - Parameter transform: An affine transform to apply to the subpath before adding to the path.
public init(transform: CGAffineTransform, @PathBuilder _ builder: () -> PathComponent) {
self.transform = transform
self.path = Path(builder)
}

public func add(to path: inout Path) {
path.addPath(path.applying(transform))
}
}

0 comments on commit d3d6eea

Please sign in to comment.