@@ -12,14 +12,16 @@ namespace SixLabors.ImageSharp.Drawing;
1212/// </summary>
1313public static class OutlinePathExtensions
1414{
15+ private static readonly StrokeOptions DefaultOptions = new ( ) ;
16+
1517 /// <summary>
1618 /// Generates an outline of the path.
1719 /// </summary>
1820 /// <param name="path">The path to outline</param>
1921 /// <param name="width">The outline width.</param>
2022 /// <returns>A new <see cref="IPath"/> representing the outline.</returns>
2123 public static IPath GenerateOutline ( this IPath path , float width )
22- => GenerateOutline ( path , width , new StrokeOptions ( ) ) ;
24+ => GenerateOutline ( path , width , DefaultOptions ) ;
2325
2426 /// <summary>
2527 /// Generates an outline of the path.
@@ -35,8 +37,7 @@ public static IPath GenerateOutline(this IPath path, float width, StrokeOptions
3537 return Path . Empty ;
3638 }
3739
38- StrokedShapeGenerator generator = new ( strokeOptions ) ;
39- return new ComplexPolygon ( generator . GenerateStrokedShapes ( path , width ) ) ;
40+ return StrokedShapeGenerator . GenerateStrokedShapes ( path , width , strokeOptions ) ;
4041 }
4142
4243 /// <summary>
@@ -69,7 +70,7 @@ public static IPath GenerateOutline(this IPath path, float width, ReadOnlySpan<f
6970 /// <param name="startOff">Whether the first item in the pattern is on or off.</param>
7071 /// <returns>A new <see cref="IPath"/> representing the outline.</returns>
7172 public static IPath GenerateOutline ( this IPath path , float width , ReadOnlySpan < float > pattern , bool startOff )
72- => GenerateOutline ( path , width , pattern , startOff , new StrokeOptions ( ) ) ;
73+ => GenerateOutline ( path , width , pattern , startOff , DefaultOptions ) ;
7374
7475 /// <summary>
7576 /// Generates an outline of the path with alternating on and off segments based on the pattern.
@@ -235,7 +236,6 @@ public static IPath GenerateOutline(
235236 }
236237
237238 // Each outline span is stroked as an open polyline; the union cleans overlaps.
238- StrokedShapeGenerator generator = new ( strokeOptions ) ;
239- return new ComplexPolygon ( generator . GenerateStrokedShapes ( outlines , width ) ) ;
239+ return StrokedShapeGenerator . GenerateStrokedShapes ( outlines , width , strokeOptions ) ;
240240 }
241241}
0 commit comments