Skip to content

Commit 93777d3

Browse files
committed
improved input checking for elliptical Arc
1 parent 6a16b0c commit 93777d3

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

src/ImageSharp.Drawing/Shapes/EllipticalArcLineSegment.cs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,20 @@ public EllipticalArcLineSegment(PointF center, float firstRadius, float secondRa
3535
{
3636
Guard.MustBeGreaterThan(firstRadius, 0, nameof(firstRadius));
3737
Guard.MustBeGreaterThan(secondRadius, 0, nameof(secondRadius));
38-
Guard.MustBeBetweenOrEqualTo(rotation, 0, 360, nameof(rotation));
39-
Guard.MustBeBetweenOrEqualTo(startAngle, 0, 360, nameof(startAngle));
40-
Guard.MustBeBetweenOrEqualTo(sweepAngle, 0, 360, nameof(sweepAngle));
38+
Guard.MustBeGreaterThanOrEqualTo(rotation, 0, nameof(rotation));
39+
Guard.MustBeGreaterThanOrEqualTo(startAngle, 0, nameof(startAngle));
40+
Guard.MustBeGreaterThanOrEqualTo(sweepAngle, 0, nameof(sweepAngle));
4141
this.center = center;
4242
this.firstRadius = firstRadius;
4343
this.secondRadius = secondRadius;
44-
this.rotation = rotation;
45-
this.startAngle = startAngle;
44+
this.rotation = rotation % 360;
45+
this.startAngle = startAngle % 360;
4646
this.sweepAngle = sweepAngle;
47+
if (sweepAngle > 360)
48+
{
49+
sweepAngle = 360;
50+
}
51+
4752
this.linePoints = this.GetDrawingPoints();
4853
this.EndPoint = this.linePoints[this.linePoints.Length - 1];
4954
}

0 commit comments

Comments
 (0)