Skip to content

Commit 5dca6a8

Browse files
committed
format code
1 parent c11935b commit 5dca6a8

File tree

3 files changed

+60
-25
lines changed

3 files changed

+60
-25
lines changed

Examples/Sources/PathsExample/PathsApp.swift

Lines changed: 50 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import SwiftCrossUI
21
import DefaultBackend
3-
import Foundation // for sin, cos
2+
import Foundation // for sin, cos
3+
import SwiftCrossUI
44

55
struct ArcShape: StyledShape {
66
var startAngle: Double
@@ -13,7 +13,7 @@ struct ArcShape: StyledShape {
1313

1414
func path(in bounds: Path.Rect) -> Path {
1515
let radius = min(bounds.width, bounds.height) / 2.0 - 2.5
16-
16+
1717
return Path()
1818
.move(to: bounds.center + radius * SIMD2(x: cos(startAngle), y: sin(startAngle)))
1919
.addArc(
@@ -53,31 +53,63 @@ struct PathsApp: App {
5353
Text("Clockwise")
5454

5555
HStack {
56-
ArcShape(startAngle: .pi * 2.0/3.0, endAngle: .pi * 1.5, clockwise: true)
57-
58-
ArcShape(startAngle: .pi * 1.5, endAngle: .pi * 1.0/3.0, clockwise: true)
56+
ArcShape(
57+
startAngle: .pi * 2.0 / 3.0,
58+
endAngle: .pi * 1.5,
59+
clockwise: true
60+
)
61+
62+
ArcShape(
63+
startAngle: .pi * 1.5,
64+
endAngle: .pi * 1.0 / 3.0,
65+
clockwise: true
66+
)
5967
}
6068

61-
HStack {
62-
ArcShape(startAngle: .pi * 1.5, endAngle: .pi * 2.0/3.0, clockwise: true)
63-
64-
ArcShape(startAngle: .pi * 1.0/3.0, endAngle: .pi * 1.5, clockwise: true)
69+
HStack {
70+
ArcShape(
71+
startAngle: .pi * 1.5,
72+
endAngle: .pi * 2.0 / 3.0,
73+
clockwise: true
74+
)
75+
76+
ArcShape(
77+
startAngle: .pi * 1.0 / 3.0,
78+
endAngle: .pi * 1.5,
79+
clockwise: true
80+
)
6581
}
6682
}
67-
83+
6884
VStack {
6985
Text("Counter-clockwise")
7086

71-
HStack {
72-
ArcShape(startAngle: .pi * 1.5, endAngle: .pi * 2.0/3.0, clockwise: false)
73-
74-
ArcShape(startAngle: .pi * 1.0/3.0, endAngle: .pi * 1.5, clockwise: false)
87+
HStack {
88+
ArcShape(
89+
startAngle: .pi * 1.5,
90+
endAngle: .pi * 2.0 / 3.0,
91+
clockwise: false
92+
)
93+
94+
ArcShape(
95+
startAngle: .pi * 1.0 / 3.0,
96+
endAngle: .pi * 1.5,
97+
clockwise: false
98+
)
7599
}
76100

77101
HStack {
78-
ArcShape(startAngle: .pi * 2.0/3.0, endAngle: .pi * 1.5, clockwise: false)
79-
80-
ArcShape(startAngle: .pi * 1.5, endAngle: .pi * 1.0/3.0, clockwise: false)
102+
ArcShape(
103+
startAngle: .pi * 2.0 / 3.0,
104+
endAngle: .pi * 1.5,
105+
clockwise: false
106+
)
107+
108+
ArcShape(
109+
startAngle: .pi * 1.5,
110+
endAngle: .pi * 1.0 / 3.0,
111+
clockwise: false
112+
)
81113
}
82114
}
83115
}.padding()

Sources/SwiftCrossUI/Path.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ public struct Path {
267267
}
268268

269269
/// Add an arc segment to the path.
270-
///
270+
///
271271
/// The behavior is not defined if the starting point is not what is implied by `center`,
272272
/// `radius`, and `startAngle`. Some backends (such as UIKit) will add a line segment
273273
/// to connect the arc to the starting point, while others (such as WinUI) will move the
@@ -291,7 +291,7 @@ public struct Path {
291291
endAngle: Double,
292292
clockwise: Bool
293293
) -> Path {
294-
assert((0.0 ... (2.0 * .pi)).contains(startAngle) && (0.0 ... (2.0 * .pi)).contains(endAngle))
294+
assert((0.0...(2.0 * .pi)).contains(startAngle) && (0.0...(2.0 * .pi)).contains(endAngle))
295295
actions.append(
296296
.arc(
297297
center: center,

Sources/WinUIBackend/WinUIBackend.swift

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,7 +1193,8 @@ public final class WinUIBackend: AppBackend {
11931193
) -> PathFigure {
11941194
var pathGeo: PathGeometry
11951195
if collection.size > 0,
1196-
let castedLast = collection.getAt(collection.size - 1) as? PathGeometry {
1196+
let castedLast = collection.getAt(collection.size - 1) as? PathGeometry
1197+
{
11971198
pathGeo = castedLast
11981199
} else {
11991200
pathGeo = PathGeometry()
@@ -1215,7 +1216,8 @@ public final class WinUIBackend: AppBackend {
12151216
return figure
12161217
}
12171218

1218-
func applyActions(_ actions: [SwiftCrossUI.Path.Action], to geometry: WinUI.GeometryCollection) {
1219+
func applyActions(_ actions: [SwiftCrossUI.Path.Action], to geometry: WinUI.GeometryCollection)
1220+
{
12191221
var lastPoint = Point(x: 0.0, y: 0.0)
12201222

12211223
for action in actions {
@@ -1224,8 +1226,9 @@ public final class WinUIBackend: AppBackend {
12241226
lastPoint = Point(x: Float(point.x), y: Float(point.y))
12251227

12261228
if geometry.size > 0,
1227-
let pathGeo = geometry.getAt(geometry.size - 1) as? PathGeometry,
1228-
pathGeo.figures.size > 0 {
1229+
let pathGeo = geometry.getAt(geometry.size - 1) as? PathGeometry,
1230+
pathGeo.figures.size > 0
1231+
{
12291232
let figure = pathGeo.figures.getAt(pathGeo.figures.size - 1)!
12301233
if figure.segments.size > 0 {
12311234
let newFigure = PathFigure()
@@ -1251,7 +1254,7 @@ public final class WinUIBackend: AppBackend {
12511254

12521255
let figure = requirePathFigure(geometry, lastPoint: lastPoint)
12531256

1254-
let segment = QuadraticBezierSegment ()
1257+
let segment = QuadraticBezierSegment()
12551258
segment.point1 = wfControl
12561259
segment.point2 = wfEnd
12571260
figure.segments.append(segment)

0 commit comments

Comments
 (0)