@@ -8,18 +8,15 @@ namespace SixLabors.ImageSharp.Drawing;
88/// <summary>
99/// An elliptical shape made up of a single path made up of one of more <see cref="ILineSegment"/>s.
1010/// </summary>
11- public sealed class EllipsePolygon : IPath , ISimplePath , IPathInternals , IInternalPathOwner
11+ public sealed class EllipsePolygon : Polygon , IPathInternals
1212{
13- private readonly InternalPath innerPath ;
14- private readonly CubicBezierLineSegment segment ;
15-
1613 /// <summary>
1714 /// Initializes a new instance of the <see cref="EllipsePolygon" /> class.
1815 /// </summary>
1916 /// <param name="location">The location the center of the ellipse will be placed.</param>
2017 /// <param name="size">The width/height of the final ellipse.</param>
2118 public EllipsePolygon ( PointF location , SizeF size )
22- : this ( CreateSegment ( location , size ) )
19+ : base ( CreateSegment ( location , size ) )
2320 {
2421 }
2522
@@ -45,6 +42,11 @@ public EllipsePolygon(float x, float y, float width, float height)
4542 {
4643 }
4744
45+ private EllipsePolygon ( ILineSegment [ ] segments )
46+ : base ( segments , true )
47+ {
48+ }
49+
4850 /// <summary>
4951 /// Initializes a new instance of the <see cref="EllipsePolygon" /> class.
5052 /// </summary>
@@ -56,46 +58,28 @@ public EllipsePolygon(float x, float y, float radius)
5658 {
5759 }
5860
59- private EllipsePolygon ( CubicBezierLineSegment segment )
60- {
61- this . segment = segment ;
62- this . innerPath = new InternalPath ( segment , true ) ;
63- }
64-
65- /// <inheritdoc/>
66- public bool IsClosed => true ;
67-
68- /// <inheritdoc/>
69- public ReadOnlyMemory < PointF > Points => this . innerPath . Points ( ) ;
70-
71- /// <inheritdoc />
72- public RectangleF Bounds => this . innerPath . Bounds ;
73-
7461 /// <inheritdoc/>
75- public PathTypes PathType => PathTypes . Closed ;
62+ public override IPath Transform ( Matrix3x2 matrix )
63+ {
64+ if ( matrix . IsIdentity )
65+ {
66+ return this ;
67+ }
7668
77- /// <inheritdoc/>
78- public IPath Transform ( Matrix3x2 matrix ) => matrix . IsIdentity
79- ? this
80- : new EllipsePolygon ( this . segment . Transform ( matrix ) ) ;
69+ ILineSegment [ ] segments = new ILineSegment [ this . LineSegments . Count ] ;
8170
82- /// <inheritdoc/>
83- public IPath AsClosedPath ( ) => this ;
71+ for ( int i = 0 ; i < segments . Length ; i ++ )
72+ {
73+ segments [ i ] = this . LineSegments [ i ] . Transform ( matrix ) ;
74+ }
8475
85- /// <inheritdoc />
86- public IEnumerable < ISimplePath > Flatten ( )
87- {
88- yield return this ;
76+ return new EllipsePolygon ( segments ) ;
8977 }
9078
9179 /// <inheritdoc />
9280 // TODO switch this out to a calculated algorithm
9381 SegmentInfo IPathInternals . PointAlongPath ( float distance )
94- => this . innerPath . PointAlongPath ( distance ) ;
95-
96- /// <inheritdoc/>
97- IReadOnlyList < InternalPath > IInternalPathOwner . GetRingsAsInternalPath ( )
98- => new [ ] { this . innerPath } ;
82+ => this . InnerPath . PointAlongPath ( distance ) ;
9983
10084 private static CubicBezierLineSegment CreateSegment ( Vector2 location , SizeF size )
10185 {
0 commit comments