Skip to content

Commit

Permalink
shape api for decompose
Browse files Browse the repository at this point in the history
  • Loading branch information
NailxSharipov committed Nov 27, 2024
1 parent 0f3eaf9 commit 6a505d5
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions Sources/iOverlay/Core/Divide.swift
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,28 @@ public extension Path {
}

}

public extension Shape {

mutating func decomposeContours() {
let n = self.count
for i in 0..<n {
let path = self[i]
guard let contours = path.decomposeContours() else { continue }
self[i] = contours[0]
for j in 1..<contours.count {
self.append(contours[j])
}
}
}
}

public extension Shapes {

mutating func decomposeContours() {
let n = self.count
for i in 0..<n {
self[i].decomposeContours()
}
}
}

0 comments on commit 6a505d5

Please sign in to comment.