Skip to content

Commit e30c216

Browse files
committed
added EllipticalArc to DrawPathTests
1 parent e66dfdb commit e30c216

9 files changed

Lines changed: 13 additions & 11 deletions

File tree

src/ImageSharp.Drawing/Shapes/EllipticalArcLineSegment.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public sealed class EllipticalArcLineSegment : ILineSegment
3131
/// <param name="y"> The y-coordinate of the center point of the ellips from which the arc is taken.</param>
3232
/// <param name="radiusX">X radius of the ellipsis.</param>
3333
/// <param name="radiusY">Y radius of the ellipsis.</param>
34-
/// <param name="rotation">The rotation of (<paramref name="radiusX"/> to the X-axis and (<paramref name="radiusY"/> to the Y-axis, measured in degrees anticlockwise.</param>
34+
/// <param name="rotation">The rotation of (<paramref name="radiusX"/> to the X-axis and (<paramref name="radiusY"/> to the Y-axis, measured in degrees clockwise.</param>
3535
/// <param name="startAngle">The Start angle of the ellipsis, measured in degrees anticlockwise from the Y-axis.</param>
3636
/// <param name="sweepAngle"> The angle between (<paramref name="startAngle"/> and the end of the arc. </param>
3737
/// <param name="transformation">The Tranformation matrix, that should be used on the arc.</param>
@@ -43,7 +43,7 @@ public EllipticalArcLineSegment(float x, float y, float radiusX, float radiusY,
4343
this.y = y;
4444
this.radiusX = radiusX;
4545
this.radiusY = radiusY;
46-
this.rotation = -rotation % 360;
46+
this.rotation = rotation % 360;
4747
this.startAngle = startAngle % 360;
4848
this.transformation = transformation;
4949
this.sweepAngle = sweepAngle;

src/ImageSharp.Drawing/Shapes/PathBuilder.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ public PathBuilder AddBezier(PointF startPoint, PointF controlPoint1, PointF con
203203
/// Adds an elliptical arc to the current figure
204204
/// </summary>
205205
/// <param name="rect"> A <see cref="RectangleF"/> that represents the rectangular bounds of the ellipse from which the arc is taken.</param>
206-
/// <param name="rotation">The rotation of (<paramref name="rect"/>, measured in degrees anticlockwise.</param>
206+
/// <param name="rotation">The rotation of (<paramref name="rect"/>, measured in degrees clockwise.</param>
207207
/// <param name="startAngle">The Start angle of the ellipsis, measured in degrees anticlockwise from the Y-axis.</param>
208208
/// <param name="sweepAngle"> The angle between (<paramref name="startAngle"/> and the end of the arc. </param>
209209
/// <returns>The <see cref="PathBuilder"/></returns>
@@ -213,7 +213,7 @@ public PathBuilder AddBezier(PointF startPoint, PointF controlPoint1, PointF con
213213
/// Adds an elliptical arc to the current figure
214214
/// </summary>
215215
/// <param name="rect"> A <see cref="Rectangle"/> that represents the rectangular bounds of the ellipse from which the arc is taken.</param>
216-
/// <param name="rotation">The rotation of (<paramref name="rect"/>, measured in degrees anticlockwise.</param>
216+
/// <param name="rotation">The rotation of (<paramref name="rect"/>, measured in degrees clockwise.</param>
217217
/// <param name="startAngle">The Start angle of the ellipsis, measured in degrees anticlockwise from the Y-axis.</param>
218218
/// <param name="sweepAngle"> The angle between (<paramref name="startAngle"/> and the end of the arc. </param>
219219
/// <returns>The <see cref="PathBuilder"/></returns>
@@ -225,7 +225,7 @@ public PathBuilder AddBezier(PointF startPoint, PointF controlPoint1, PointF con
225225
/// <param name="center"> The center <see cref="PointF"/> of the ellips from which the arc is taken.</param>
226226
/// <param name="radiusX">X radius of the ellipsis.</param>
227227
/// <param name="radiusY">Y radius of the ellipsis.</param>
228-
/// <param name="rotation">The rotation of (<paramref name="radiusX"/> to the X-axis and (<paramref name="radiusY"/> to the Y-axis, measured in degrees anticlockwise.</param>
228+
/// <param name="rotation">The rotation of (<paramref name="radiusX"/> to the X-axis and (<paramref name="radiusY"/> to the Y-axis, measured in degrees clockwise.</param>
229229
/// <param name="startAngle">The Start angle of the ellipsis, measured in degrees anticlockwise from the Y-axis.</param>
230230
/// <param name="sweepAngle"> The angle between (<paramref name="startAngle"/> and the end of the arc. </param>
231231
/// <returns>The <see cref="PathBuilder"/></returns>
@@ -237,7 +237,7 @@ public PathBuilder AddBezier(PointF startPoint, PointF controlPoint1, PointF con
237237
/// <param name="center"> The center <see cref="Point"/> of the ellips from which the arc is taken.</param>
238238
/// <param name="radiusX">X radius of the ellipsis.</param>
239239
/// <param name="radiusY">Y radius of the ellipsis.</param>
240-
/// <param name="rotation">The rotation of (<paramref name="radiusX"/> to the X-axis and (<paramref name="radiusY"/> to the Y-axis, measured in degrees anticlockwise.</param>
240+
/// <param name="rotation">The rotation of (<paramref name="radiusX"/> to the X-axis and (<paramref name="radiusY"/> to the Y-axis, measured in degrees clockwise.</param>
241241
/// <param name="startAngle">The Start angle of the ellipsis, measured in degrees anticlockwise from the Y-axis.</param>
242242
/// <param name="sweepAngle"> The angle between (<paramref name="startAngle"/> and the end of the arc. </param>
243243
/// <returns>The <see cref="PathBuilder"/></returns>
@@ -250,7 +250,7 @@ public PathBuilder AddBezier(PointF startPoint, PointF controlPoint1, PointF con
250250
/// <param name="y"> The y-coordinate of the center point of the ellips from which the arc is taken.</param>
251251
/// <param name="radiusX">X radius of the ellipsis.</param>
252252
/// <param name="radiusY">Y radius of the ellipsis.</param>
253-
/// <param name="rotation">The rotation of (<paramref name="radiusX"/> to the X-axis and (<paramref name="radiusY"/> to the Y-axis, measured in degrees anticlockwise.</param>
253+
/// <param name="rotation">The rotation of (<paramref name="radiusX"/> to the X-axis and (<paramref name="radiusY"/> to the Y-axis, measured in degrees clockwise.</param>
254254
/// <param name="startAngle">The Start angle of the ellipsis, measured in degrees anticlockwise from the Y-axis.</param>
255255
/// <param name="sweepAngle"> The angle between (<paramref name="startAngle"/> and the end of the arc. </param>
256256
/// <returns>The <see cref="PathBuilder"/></returns>
@@ -268,7 +268,7 @@ public PathBuilder AddEllipticalArc(int x, int y, int radiusX, int radiusY, int
268268
/// <param name="y"> The y-coordinate of the center point of the ellips from which the arc is taken.</param>
269269
/// <param name="radiusX">X radius of the ellipsis.</param>
270270
/// <param name="radiusY">Y radius of the ellipsis.</param>
271-
/// <param name="rotation">The rotation of (<paramref name="radiusX"/> to the X-axis and (<paramref name="radiusY"/> to the Y-axis, measured in degrees anticlockwise.</param>
271+
/// <param name="rotation">The rotation of (<paramref name="radiusX"/> to the X-axis and (<paramref name="radiusY"/> to the Y-axis, measured in degrees clockwise.</param>
272272
/// <param name="startAngle">The Start angle of the ellipsis, measured in degrees anticlockwise from the Y-axis.</param>
273273
/// <param name="sweepAngle"> The angle between (<paramref name="startAngle"/> and the end of the arc. </param>
274274
/// <returns>The <see cref="PathBuilder"/></returns>

tests/ImageSharp.Drawing.Tests/Drawing/DrawPathTests.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public class DrawPathTests
2323
};
2424

2525
[Theory]
26-
[WithSolidFilledImages(nameof(DrawPathData), 300, 450, "Blue", PixelTypes.Rgba32)]
26+
[WithSolidFilledImages(nameof(DrawPathData), 300, 600, "Blue", PixelTypes.Rgba32)]
2727
public void DrawPath<TPixel>(TestImageProvider<TPixel> provider, string colorName, byte alpha, float thickness)
2828
where TPixel : unmanaged, IPixel<TPixel>
2929
{
@@ -36,8 +36,10 @@ public void DrawPath<TPixel>(TestImageProvider<TPixel> provider, string colorNam
3636
new Vector2(500, 500),
3737
new Vector2(60, 10),
3838
new Vector2(10, 400));
39+
var ellipticArcSegment1 = new EllipticalArcLineSegment(80, 425, (float)Math.Sqrt(5525), 40, (float)(Math.Atan2(25, 70) * 180 / Math.PI), -90, -180, Matrix3x2.Identity);
40+
var ellipticArcSegment2 = new EllipticalArcLineSegment(150, 520, 140, 70, 0, 180, 360, Matrix3x2.Identity);
3941

40-
var path = new Path(linearSegment, bezierSegment);
42+
var path = new Path(linearSegment, bezierSegment, ellipticArcSegment1, ellipticArcSegment2);
4143

4244
Rgba32 rgba = TestUtils.GetColorByName(colorName);
4345
rgba.A = alpha;

tests/ImageSharp.Drawing.Tests/Shapes/EllipticalArcLineSegmentTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class EllipticalArcLineSegmentTest
1212
[Fact]
1313
public void ContainsStartandEnd()
1414
{
15-
var segment = new EllipticalArcLineSegment(new PointF(10, 10), 10, 20, 0, 0, 90, Matrix3x2.Identity);
15+
var segment = new EllipticalArcLineSegment(10, 10, 10, 20, 0, 0, 90, Matrix3x2.Identity);
1616
IReadOnlyList<PointF> points = segment.Flatten().ToArray();
1717
Assert.Equal(10, points[0].X, 5);
1818
Assert.Equal(30, points[0].Y, 5);
-4.87 KB
Loading
-8.29 KB
Loading
-4.58 KB
Loading
-4.44 KB
Loading
-4.73 KB
Loading

0 commit comments

Comments
 (0)