Browse Source

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 <grokys@users.noreply.github.com>
pull/21888/head
robloo 1 month ago
committed by GitHub
parent
commit
958066b442
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 9
      src/Avalonia.Base/Media/GeometryBuilder.cs
  2. 23
      src/Avalonia.Base/Platform/IGeometryContext.cs

9
src/Avalonia.Base/Media/GeometryBuilder.cs

@ -20,7 +20,6 @@ namespace Avalonia.Media
/// </summary> /// </summary>
internal class GeometryBuilder internal class GeometryBuilder
{ {
private const double PiOver2 = 1.57079633; // 90 deg to rad
private const double Epsilon = 0.00000153; // Same as LayoutHelper.LayoutEpsilon private const double Epsilon = 0.00000153; // Same as LayoutHelper.LayoutEpsilon
/// <summary> /// <summary>
@ -157,7 +156,7 @@ namespace Avalonia.Media
context.ArcTo( context.ArcTo(
new Point(rect.Right, rect.Top + radiusY), new Point(rect.Right, rect.Top + radiusY),
arcSize, arcSize,
rotationAngle: PiOver2, rotationAngle: 0.0,
isLargeArc: false, isLargeArc: false,
SweepDirection.Clockwise); SweepDirection.Clockwise);
@ -166,7 +165,7 @@ namespace Avalonia.Media
context.ArcTo( context.ArcTo(
new Point(rect.Right - radiusX, rect.Bottom), new Point(rect.Right - radiusX, rect.Bottom),
arcSize, arcSize,
rotationAngle: PiOver2, rotationAngle: 0.0,
isLargeArc: false, isLargeArc: false,
SweepDirection.Clockwise); SweepDirection.Clockwise);
@ -175,7 +174,7 @@ namespace Avalonia.Media
context.ArcTo( context.ArcTo(
new Point(rect.Left, rect.Bottom - radiusY), new Point(rect.Left, rect.Bottom - radiusY),
arcSize, arcSize,
rotationAngle: PiOver2, rotationAngle: 0.0,
isLargeArc: false, isLargeArc: false,
SweepDirection.Clockwise); SweepDirection.Clockwise);
@ -184,7 +183,7 @@ namespace Avalonia.Media
context.ArcTo( context.ArcTo(
new Point(rect.Left + radiusX, rect.Top), new Point(rect.Left + radiusX, rect.Top),
arcSize, arcSize,
rotationAngle: PiOver2, rotationAngle: 0.0,
isLargeArc: false, isLargeArc: false,
SweepDirection.Clockwise); SweepDirection.Clockwise);

23
src/Avalonia.Base/Platform/IGeometryContext.cs

@ -11,14 +11,19 @@ namespace Avalonia.Platform
/// <summary> /// <summary>
/// Draws an arc to the specified point. /// Draws an arc to the specified point.
/// </summary> /// </summary>
/// <param name="point">The destination point.</param> /// <param name="point">The destination point where the arc ends.</param>
/// <param name="size">The radii of an oval whose perimeter is used to draw the angle.</param> /// <param name="size">The radii of an ellipse whose path is used to draw the arc.</param>
/// <param name="rotationAngle">The rotation angle (in radians) of the oval that specifies the curve.</param> /// <param name="rotationAngle">
/// <param name="isLargeArc">true to draw the arc greater than 180 degrees; otherwise, false.</param> /// 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.
/// </param>
/// <param name="isLargeArc">
/// Specifies whether the arc should follow the longer path around an ellipse rather than the shorter one.
/// <c>true</c> to draw the arc greater than 180 degrees; otherwise, <c>false</c>.</param>
/// <param name="sweepDirection"> /// <param name="sweepDirection">
/// A value that indicates whether the arc is drawn in the Clockwise or Counterclockwise direction. /// A value that indicates whether the arc is drawn in the Clockwise or Counterclockwise direction.
/// </param> /// </param>
/// <param name="isStroked">Whether the segment is stroked</param> /// <param name="isStroked">Whether the segment is stroked.</param>
void ArcTo(Point point, Size size, double rotationAngle, bool isLargeArc, SweepDirection sweepDirection, bool isStroked = true); void ArcTo(Point point, Size size, double rotationAngle, bool isLargeArc, SweepDirection sweepDirection, bool isStroked = true);
/// <summary> /// <summary>
@ -34,22 +39,22 @@ namespace Avalonia.Platform
/// <param name="controlPoint1">The first control point used to specify the shape of the curve.</param> /// <param name="controlPoint1">The first control point used to specify the shape of the curve.</param>
/// <param name="controlPoint2">The second control point used to specify the shape of the curve.</param> /// <param name="controlPoint2">The second control point used to specify the shape of the curve.</param>
/// <param name="endPoint">The destination point for the end of the curve.</param> /// <param name="endPoint">The destination point for the end of the curve.</param>
/// <param name="isStroked">Whether the segment is stroked</param> /// <param name="isStroked">Whether the segment is stroked.</param>
void CubicBezierTo(Point controlPoint1, Point controlPoint2, Point endPoint, bool isStroked = true); void CubicBezierTo(Point controlPoint1, Point controlPoint2, Point endPoint, bool isStroked = true);
/// <summary> /// <summary>
/// Draws a quadratic Bezier curve to the specified point /// Draws a quadratic Bezier curve to the specified point.
/// </summary> /// </summary>
/// <param name="controlPoint">The control point used to specify the shape of the curve.</param> /// <param name="controlPoint">The control point used to specify the shape of the curve.</param>
/// <param name="endPoint">The destination point for the end of the curve.</param> /// <param name="endPoint">The destination point for the end of the curve.</param>
/// <param name="isStroked">Whether the segment is stroked</param> /// <param name="isStroked">Whether the segment is stroked.</param>
void QuadraticBezierTo(Point controlPoint, Point endPoint, bool isStroked = true); void QuadraticBezierTo(Point controlPoint, Point endPoint, bool isStroked = true);
/// <summary> /// <summary>
/// Draws a line to the specified point. /// Draws a line to the specified point.
/// </summary> /// </summary>
/// <param name="point">The destination point.</param> /// <param name="point">The destination point.</param>
/// <param name="isStroked">Whether the segment is stroked</param> /// <param name="isStroked">Whether the segment is stroked.</param>
void LineTo(Point point, bool isStroked = true); void LineTo(Point point, bool isStroked = true);
/// <summary> /// <summary>

Loading…
Cancel
Save