File tree Expand file tree Collapse file tree 3 files changed +16
-12
lines changed
Examples/Sources/PathsExample Expand file tree Collapse file tree 3 files changed +16
-12
lines changed Original file line number Diff line number Diff line change @@ -12,13 +12,10 @@ struct ArcShape: StyledShape {
1212 let strokeStyle : StrokeStyle ? = StrokeStyle ( width: 5.0 )
1313
1414 func path( in bounds: Path . Rect ) -> Path {
15- let radius = min ( bounds. width, bounds. height) / 2.0 - 2.5
16-
17- return Path ( )
18- . move ( to: bounds. center + radius * SIMD2( x: cos ( startAngle) , y: sin ( startAngle) ) )
15+ Path ( )
1916 . addArc (
2017 center: bounds. center,
21- radius: radius ,
18+ radius: min ( bounds . width , bounds . height ) / 2.0 - 2.5 ,
2219 startAngle: startAngle,
2320 endAngle: endAngle,
2421 clockwise: clockwise
Original file line number Diff line number Diff line change @@ -267,13 +267,6 @@ public struct Path {
267267 }
268268
269269 /// Add an arc segment to the path.
270- ///
271- /// The behavior is not defined if the starting point is not what is implied by `center`,
272- /// `radius`, and `startAngle`. Some backends (such as UIKit) will add a line segment
273- /// to connect the arc to the starting point, while others (such as WinUI) will move the
274- /// arc in unintuitive ways. If this arc is the first segment of the current path, or
275- /// the previous segment was a rectangle or circle, be sure to call ``move(to:)`` before
276- /// this.
277270 /// - Parameters:
278271 /// - center: The location of the center of the circle.
279272 /// - radius: The radius of the circle.
Original file line number Diff line number Diff line change @@ -1293,6 +1293,10 @@ public final class WinUIBackend: AppBackend {
12931293 let endAngle,
12941294 let clockwise
12951295 ) :
1296+ let startPoint = Point (
1297+ x: Float ( center. x + radius * cos( startAngle) ) ,
1298+ y: Float ( center. y + radius * sin( startAngle) )
1299+ )
12961300 let endPoint = Point (
12971301 x: Float ( center. x + radius * cos( endAngle) ) ,
12981302 y: Float ( center. y + radius * sin( endAngle) )
@@ -1301,6 +1305,16 @@ public final class WinUIBackend: AppBackend {
13011305
13021306 let figure = requirePathFigure ( geometry, lastPoint: lastPoint)
13031307
1308+ if startPoint != lastPoint {
1309+ if figure. segments. size > 0 {
1310+ let connector = LineSegment ( )
1311+ connector. point = startPoint
1312+ figure. segments. append ( connector)
1313+ } else {
1314+ figure. startPoint = startPoint
1315+ }
1316+ }
1317+
13041318 let segment = ArcSegment ( )
13051319
13061320 if clockwise {
You can’t perform that action at this time.
0 commit comments