Skip to content

Commit 9a7b72e

Browse files
committed
cleanup
1 parent 26f8855 commit 9a7b72e

File tree

3 files changed

+1
-15
lines changed

3 files changed

+1
-15
lines changed

Sources/Shapes/RegularPolygons/Triangle.swift

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,18 @@ struct Triangle: Shape {
1717

1818
let angle = ((Double(index) * (360.0 / Double(sides))) - 90) * Double.pi / 180
1919

20-
//from point
2120
let point = CGPoint(
2221
x: centerPoint.x + CGFloat(cos(angle) * hypotenuse),
2322
y: centerPoint.y + CGFloat(sin(angle) * hypotenuse)
2423
)
2524

2625
let viaAngle = ((Double(index + 1) * (360.0 / Double(sides))) - 90) * Double.pi / 180
2726

28-
//via point
2927
let viaPoint = CGPoint(
3028
x: centerPoint.x + CGFloat(cos(viaAngle) * hypotenuse),
3129
y: centerPoint.y + CGFloat(sin(viaAngle) * hypotenuse)
3230
)
3331

34-
//radius
3532
if usableRadius == 0 {
3633
let sideLength = sqrt((point.x - viaPoint.x) * (point.x - viaPoint.x) + (point.y - viaPoint.y) * (point.y - viaPoint.y))
3734
let inradius = sideLength / (2 * tan(.pi / CGFloat(sides)))
@@ -41,7 +38,6 @@ struct Triangle: Shape {
4138

4239
let nextAngle = ((Double(index + 2) * (360.0 / Double(sides))) - 90) * Double.pi / 180
4340

44-
//next point
4541
let nextPoint = CGPoint(
4642
x: centerPoint.x + CGFloat(cos(nextAngle) * hypotenuse),
4743
y: centerPoint.y + CGFloat(sin(nextAngle) * hypotenuse)
@@ -57,7 +53,7 @@ struct Triangle: Shape {
5753
struct Triangle_Previews: PreviewProvider {
5854
static var previews: some View {
5955
Triangle(radius: 30)
60-
.stroke(lineWidth: 3)
56+
.stroke(lineWidth: 3)
6157
.foregroundColor(.blue)
6258
.background(Circle())
6359
.animation(.linear)

Sources/Shapes/RoundedRegularPolygons/RoundedRegularPolygon.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,18 @@ extension Path {
4141

4242
let angle = ((Double(index) * (360.0 / Double(sides))) - 90) * Double.pi / 180
4343

44-
//from point
4544
let point = CGPoint(
4645
x: centerPoint.x + CGFloat(cos(angle) * hypotenuse),
4746
y: centerPoint.y + CGFloat(sin(angle) * hypotenuse)
4847
)
4948

5049
let viaAngle = ((Double(index + 1) * (360.0 / Double(sides))) - 90) * Double.pi / 180
5150

52-
//via point
5351
let viaPoint = CGPoint(
5452
x: centerPoint.x + CGFloat(cos(viaAngle) * hypotenuse),
5553
y: centerPoint.y + CGFloat(sin(viaAngle) * hypotenuse)
5654
)
5755

58-
//radius
5956
if usableRadius == 0 {
6057
let sideLength = sqrt((point.x - viaPoint.x) * (point.x - viaPoint.x) + (point.y - viaPoint.y) * (point.y - viaPoint.y))
6158
let inradius = sideLength / (2 * tan(.pi / CGFloat(sides)))
@@ -65,7 +62,6 @@ extension Path {
6562

6663
let nextAngle = ((Double(index + 2) * (360.0 / Double(sides))) - 90) * Double.pi / 180
6764

68-
//next point
6965
let nextPoint = CGPoint(
7066
x: centerPoint.x + CGFloat(cos(nextAngle) * hypotenuse),
7167
y: centerPoint.y + CGFloat(sin(nextAngle) * hypotenuse)

Sources/Shapes/RoundedStarPolygons/RoundedStarPolygon.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,25 +49,21 @@ extension Path {
4949
(0..<points).forEach { index in
5050
let angle = ((Double(index * 2) * (360.0 / Double(sides))) - 90) * Double.pi / 180
5151

52-
//from point
5352
let point = CGPoint(
5453
x: centerPoint.x + CGFloat(cos(angle) * hypotenuse),
5554
y: centerPoint.y + CGFloat(sin(angle) * hypotenuse)
5655
)
5756

5857
let viaAngle = ((Double(index * 2 + 1) * (360.0 / Double(sides))) - 90) * Double.pi / 180
5958

60-
//via point
6159
let viaPoint = CGPoint(
6260
x: centerPoint.x + CGFloat(cos(viaAngle) * hypotenuse * smoothness),
6361
y: centerPoint.y + CGFloat(sin(viaAngle) * hypotenuse * smoothness)
6462
)
6563

66-
// inradius
6764
let sideLength = sqrt((point.x - viaPoint.x) * (point.x - viaPoint.x) + (point.y - viaPoint.y) * (point.y - viaPoint.y))
6865
let inradius = sideLength / (2 * tan(.pi / CGFloat(points * 2)))
6966

70-
//radius
7167
if usableConvexRadius == 0 {
7268
usableConvexRadius = min(convexRadius, inradius)
7369
}
@@ -78,15 +74,13 @@ extension Path {
7874

7975
let nextAngle = ((Double(index * 2 + 2) * (360.0 / Double(sides))) - 90) * Double.pi / 180
8076

81-
//next point
8277
let nextPoint = CGPoint(
8378
x: centerPoint.x + CGFloat(cos(nextAngle) * hypotenuse),
8479
y: centerPoint.y + CGFloat(sin(nextAngle) * hypotenuse)
8580
)
8681

8782
let lastAngle = ((Double(index * 2 + 3) * (360.0 / Double(sides))) - 90) * Double.pi / 180
8883

89-
//next point
9084
let lastPoint = CGPoint(
9185
x: centerPoint.x + CGFloat(cos(lastAngle) * hypotenuse * smoothness),
9286
y: centerPoint.y + CGFloat(sin(lastAngle) * hypotenuse * smoothness)

0 commit comments

Comments
 (0)