Skip to content

Commit 79b6e7d

Browse files
committed
Add filled circle shape
1 parent b4dd15e commit 79b6e7d

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

CountdownFlimClutter.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
475BE47A2362EB150077A87F /* FilledCircle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 475BE4792362EB150077A87F /* FilledCircle.swift */; };
1011
47BAC423235F2F01007ED558 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47BAC422235F2F01007ED558 /* AppDelegate.swift */; };
1112
47BAC425235F2F01007ED558 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47BAC424235F2F01007ED558 /* SceneDelegate.swift */; };
1213
47BAC427235F2F01007ED558 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47BAC426235F2F01007ED558 /* ContentView.swift */; };
@@ -24,6 +25,7 @@
2425
/* End PBXBuildFile section */
2526

2627
/* Begin PBXFileReference section */
28+
475BE4792362EB150077A87F /* FilledCircle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FilledCircle.swift; sourceTree = "<group>"; };
2729
47BAC41F235F2F01007ED558 /* CountdownFlimClutter.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CountdownFlimClutter.app; sourceTree = BUILT_PRODUCTS_DIR; };
2830
47BAC422235F2F01007ED558 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
2931
47BAC424235F2F01007ED558 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
@@ -119,6 +121,7 @@
119121
47D3E5652361966900B17F33 /* FilmClutterView.swift */,
120122
47D3E5772361CF8B00B17F33 /* HoleInViewMask.swift */,
121123
47D3E5732361983900B17F33 /* SightShape.swift */,
124+
475BE4792362EB150077A87F /* FilledCircle.swift */,
122125
);
123126
path = Views;
124127
sourceTree = "<group>";
@@ -213,6 +216,7 @@
213216
47D3E56A236196B700B17F33 /* FilmClutterContentView.swift in Sources */,
214217
47BAC427235F2F01007ED558 /* ContentView.swift in Sources */,
215218
47D3E5722361977800B17F33 /* Color.swift in Sources */,
219+
475BE47A2362EB150077A87F /* FilledCircle.swift in Sources */,
216220
);
217221
runOnlyForDeploymentPostprocessing = 0;
218222
};
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import SwiftUI
2+
3+
struct FilledCircle: Shape {
4+
5+
func path(in rect: CGRect) -> Path {
6+
let width = rect.size.width
7+
let height = rect.size.height
8+
let center = CGPoint(x: width / 2, y: height / 2)
9+
let radius = sqrt(pow(width, 2) + pow(height, 2)) / 2
10+
11+
return Path { path in
12+
path.addArc(
13+
center: center,
14+
radius: radius,
15+
startAngle: .init(degrees: 0),
16+
endAngle: .init(degrees: 360),
17+
clockwise: false
18+
)
19+
}
20+
}
21+
22+
}

CountdownFlimClutter/Views/FilmClutterProgressView.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ struct FilmClutterProgressView: View {
66

77
var body: some View {
88
GeometryReader { geometry in
9-
Circle()
9+
FilledCircle()
1010
.rotation(.init(degrees: -90))
1111
.trim(from: 0, to: self.viewModel.animateProgress ? 1 : 0)
12-
.stroke(lineWidth: sqrt(pow(geometry.size.width, 2) + pow(geometry.size.height, 2)) / 2)
12+
.stroke(lineWidth: sqrt(pow(geometry.size.height, 2) + pow(geometry.size.width, 2)))
1313
.opacity(0.5)
1414
.clipped()
1515
}

0 commit comments

Comments
 (0)