From 7eb6cb31e7d7605b26484fd50d3505bbdfdf5909 Mon Sep 17 00:00:00 2001 From: robloo Date: Sun, 3 Apr 2022 13:46:21 -0400 Subject: [PATCH] Share the same arc size struct --- src/Avalonia.Controls/Shapes/Rectangle.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Avalonia.Controls/Shapes/Rectangle.cs b/src/Avalonia.Controls/Shapes/Rectangle.cs index c7653b2ed2..24c61747aa 100644 --- a/src/Avalonia.Controls/Shapes/Rectangle.cs +++ b/src/Avalonia.Controls/Shapes/Rectangle.cs @@ -63,7 +63,8 @@ namespace Avalonia.Controls.Shapes { var rect = new Rect(Bounds.Size).Deflate(StrokeThickness / 2); var geometry = new StreamGeometry(); - double piOver2 = 1.57079633; // 90 deg to rad + var arcSize = new Size(x, y); + var piOver2 = 1.57079633; // 90 deg to rad using (StreamGeometryContext context = geometry.Open()) { @@ -89,7 +90,7 @@ namespace Avalonia.Controls.Shapes context.LineTo(new Point(rect.Right - x, rect.Top)); context.ArcTo( new Point(rect.Right, rect.Top + y), - new Size(x, y), + arcSize, rotationAngle: piOver2, isLargeArc: false, SweepDirection.Clockwise); @@ -98,7 +99,7 @@ namespace Avalonia.Controls.Shapes context.LineTo(new Point(rect.Right, rect.Bottom - y)); context.ArcTo( new Point(rect.Right - x, rect.Bottom), - new Size(x, y), + arcSize, rotationAngle: piOver2, isLargeArc: false, SweepDirection.Clockwise); @@ -107,7 +108,7 @@ namespace Avalonia.Controls.Shapes context.LineTo(new Point(rect.Left + x, rect.Bottom)); context.ArcTo( new Point(rect.Left, rect.Bottom - y), - new Size(x, y), + arcSize, rotationAngle: piOver2, isLargeArc: false, SweepDirection.Clockwise); @@ -116,7 +117,7 @@ namespace Avalonia.Controls.Shapes context.LineTo(new Point(rect.Left, rect.Top + y)); context.ArcTo( new Point(rect.Left + x, rect.Top), - new Size(x, y), + arcSize, rotationAngle: piOver2, isLargeArc: false, SweepDirection.Clockwise);