Skip to content

Commit ea671db

Browse files
authored
Merge pull request #16 from spacenation/rounded-star-smoothness-fix
Fixing rounded star when smoothness is greater than 0.5
2 parents 42d2e54 + 75c0b06 commit ea671db

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Sources/Shapes/RoundedStarPolygons/RoundedStarPolygon.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ extension Path {
102102

103103
let lastPoint: CGPoint = getLastPoint(from: centerPoint, angle: lastAngle, hypotenuse: hypotenuse, smoothness: smoothness)
104104

105-
path.addCircularCornerRadiusArc(from: point, via: viaPoint, to: nextPoint, radius: -usableConcaveRadius, clockwise: true)
105+
path.addCircularCornerRadiusArc(from: point, via: viaPoint, to: nextPoint, radius: smoothness > 0.5 ? usableConcaveRadius: -usableConcaveRadius, clockwise: smoothness > 0.5 ? false : true)
106106

107107
path.addCircularCornerRadiusArc(from: viaPoint, via: nextPoint, to: lastPoint, radius: usableConvexRadius, clockwise: false)
108108
}
@@ -120,6 +120,11 @@ struct RoundedStarPolygon_Previews: PreviewProvider {
120120
.background(Circle())
121121
.previewLayout(.fixed(width: 400, height: 400))
122122

123+
RoundedStarPolygon(points: 3, smoothness: 0.87, radius: 40)
124+
.fill(Color.orange)
125+
.background(Circle())
126+
.previewLayout(.fixed(width: 400, height: 400))
127+
123128
RoundedStarPolygon(points: 5, smoothness: 0.5, radius: 20)
124129
.strokeBorder(lineWidth: 1)
125130
.foregroundColor(.yellow)

0 commit comments

Comments
 (0)