Skip to content

Commit

Permalink
fix: Circular cut hole.
Browse files Browse the repository at this point in the history
  • Loading branch information
laosb committed Sep 7, 2023
1 parent 030ac8c commit c296f3e
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions Sources/CropImage/DefaultCutHoleView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,19 @@ public struct DefaultCutHoleView: View {
.foregroundColor(maskColor)
}

@ViewBuilder
var strokeShape: some View {
if isCircular {
Circle()
.strokeBorder(style: .init(lineWidth: strokeWidth))
} else {
Rectangle()
.strokeBorder(style: .init(lineWidth: strokeWidth))
}
}

var stroke: some View {
Rectangle()
.strokeBorder(style: .init(lineWidth: strokeWidth))
strokeShape
.frame(
width: targetSize.width + strokeWidth * 2,
height: targetSize.height + strokeWidth * 2
Expand All @@ -54,5 +64,8 @@ public struct DefaultCutHoleView: View {
struct DefaultCutHoleView_Previews: PreviewProvider {
static var previews: some View {
DefaultCutHoleView(targetSize: .init(width: 100, height: 100))
.previewDisplayName("Default")
DefaultCutHoleView(targetSize: .init(width: 100, height: 100), isCircular: true)
.previewDisplayName("Circular")
}
}

0 comments on commit c296f3e

Please sign in to comment.