From 958066b442bddb69a64277ac8fbc8d401cbf0c27 Mon Sep 17 00:00:00 2001 From: robloo Date: Wed, 26 Aug 2026 15:59:01 +0000 Subject: [PATCH] Fix `GeometryBuilder.DrawRoundedCornersRectangle` for `Rect` (#21482) * Use 0 degree rotation angle in DrawRoundedCornersRectangle() for Rect * Fix units in rotationAngle comment * Improve ArcTo() XML docs * Remove unused PiOver2 const causing build checks to fail --------- Co-authored-by: Steven Kirk --- src/Avalonia.Base/Media/GeometryBuilder.cs | 9 ++++---- .../Platform/IGeometryContext.cs | 23 +++++++++++-------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/Avalonia.Base/Media/GeometryBuilder.cs b/src/Avalonia.Base/Media/GeometryBuilder.cs index 074c48d8ee..2f65827f7b 100644 --- a/src/Avalonia.Base/Media/GeometryBuilder.cs +++ b/src/Avalonia.Base/Media/GeometryBuilder.cs @@ -20,7 +20,6 @@ namespace Avalonia.Media /// internal class GeometryBuilder { - private const double PiOver2 = 1.57079633; // 90 deg to rad private const double Epsilon = 0.00000153; // Same as LayoutHelper.LayoutEpsilon /// @@ -157,7 +156,7 @@ namespace Avalonia.Media context.ArcTo( new Point(rect.Right, rect.Top + radiusY), arcSize, - rotationAngle: PiOver2, + rotationAngle: 0.0, isLargeArc: false, SweepDirection.Clockwise); @@ -166,7 +165,7 @@ namespace Avalonia.Media context.ArcTo( new Point(rect.Right - radiusX, rect.Bottom), arcSize, - rotationAngle: PiOver2, + rotationAngle: 0.0, isLargeArc: false, SweepDirection.Clockwise); @@ -175,7 +174,7 @@ namespace Avalonia.Media context.ArcTo( new Point(rect.Left, rect.Bottom - radiusY), arcSize, - rotationAngle: PiOver2, + rotationAngle: 0.0, isLargeArc: false, SweepDirection.Clockwise); @@ -184,7 +183,7 @@ namespace Avalonia.Media context.ArcTo( new Point(rect.Left + radiusX, rect.Top), arcSize, - rotationAngle: PiOver2, + rotationAngle: 0.0, isLargeArc: false, SweepDirection.Clockwise); diff --git a/src/Avalonia.Base/Platform/IGeometryContext.cs b/src/Avalonia.Base/Platform/IGeometryContext.cs index 4305dccd3f..c112ae63d4 100644 --- a/src/Avalonia.Base/Platform/IGeometryContext.cs +++ b/src/Avalonia.Base/Platform/IGeometryContext.cs @@ -11,14 +11,19 @@ namespace Avalonia.Platform /// /// Draws an arc to the specified point. /// - /// The destination point. - /// The radii of an oval whose perimeter is used to draw the angle. - /// The rotation angle (in radians) of the oval that specifies the curve. - /// true to draw the arc greater than 180 degrees; otherwise, false. + /// The destination point where the arc ends. + /// The radii of an ellipse whose path is used to draw the arc. + /// + /// The rotation angle (in degrees) of the ellipse that specifies the path of the arc; positive values are clockwise. + /// This will rotate the entire arc relative to the X-axis and is not commonly used. + /// + /// + /// Specifies whether the arc should follow the longer path around an ellipse rather than the shorter one. + /// true to draw the arc greater than 180 degrees; otherwise, false. /// /// A value that indicates whether the arc is drawn in the Clockwise or Counterclockwise direction. /// - /// Whether the segment is stroked + /// Whether the segment is stroked. void ArcTo(Point point, Size size, double rotationAngle, bool isLargeArc, SweepDirection sweepDirection, bool isStroked = true); /// @@ -34,22 +39,22 @@ namespace Avalonia.Platform /// The first control point used to specify the shape of the curve. /// The second control point used to specify the shape of the curve. /// The destination point for the end of the curve. - /// Whether the segment is stroked + /// Whether the segment is stroked. void CubicBezierTo(Point controlPoint1, Point controlPoint2, Point endPoint, bool isStroked = true); /// - /// Draws a quadratic Bezier curve to the specified point + /// Draws a quadratic Bezier curve to the specified point. /// /// The control point used to specify the shape of the curve. /// The destination point for the end of the curve. - /// Whether the segment is stroked + /// Whether the segment is stroked. void QuadraticBezierTo(Point controlPoint, Point endPoint, bool isStroked = true); /// /// Draws a line to the specified point. /// /// The destination point. - /// Whether the segment is stroked + /// Whether the segment is stroked. void LineTo(Point point, bool isStroked = true); ///