Skip to content

Commit 5b2179b

Browse files
Replace PolygonOffsetter with PolygonStroker from AGG
1 parent 26ead24 commit 5b2179b

19 files changed

+493
-1310
lines changed

ImageSharp.Drawing.sln

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio Version 18
4-
VisualStudioVersion = 18.0.11123.170 d18.0
4+
VisualStudioVersion = 18.0.11123.170
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_root", "_root", "{C317F1B1-D75E-4C6D-83EB-80367343E0D7}"
77
ProjectSection(SolutionItems) = preProject
@@ -359,14 +359,6 @@ Global
359359
{5493F024-0A3F-420C-AC2D-05B77A36025B}.Debug|Any CPU.Build.0 = Debug|Any CPU
360360
{5493F024-0A3F-420C-AC2D-05B77A36025B}.Release|Any CPU.ActiveCfg = Release|Any CPU
361361
{5493F024-0A3F-420C-AC2D-05B77A36025B}.Release|Any CPU.Build.0 = Release|Any CPU
362-
{FCEDD229-22BC-4B82-87DE-786BBFC52EDE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
363-
{FCEDD229-22BC-4B82-87DE-786BBFC52EDE}.Debug|Any CPU.Build.0 = Debug|Any CPU
364-
{FCEDD229-22BC-4B82-87DE-786BBFC52EDE}.Release|Any CPU.ActiveCfg = Release|Any CPU
365-
{FCEDD229-22BC-4B82-87DE-786BBFC52EDE}.Release|Any CPU.Build.0 = Release|Any CPU
366-
{5490DFAF-0891-535F-08B4-2BF03C2BB778}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
367-
{5490DFAF-0891-535F-08B4-2BF03C2BB778}.Debug|Any CPU.Build.0 = Debug|Any CPU
368-
{5490DFAF-0891-535F-08B4-2BF03C2BB778}.Release|Any CPU.ActiveCfg = Release|Any CPU
369-
{5490DFAF-0891-535F-08B4-2BF03C2BB778}.Release|Any CPU.Build.0 = Release|Any CPU
370362
EndGlobalSection
371363
GlobalSection(SolutionProperties) = preSolution
372364
HideSolutionNode = FALSE

src/ImageSharp.Drawing/Shapes/ClipPathExtensions.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ public static class ClipPathExtensions
1717
/// <param name="subjectPath">The subject path.</param>
1818
/// <param name="clipPaths">The clipping paths.</param>
1919
/// <returns>The clipped <see cref="IPath"/>.</returns>
20-
/// <exception cref="ClipperException">Thrown when an error occurred while attempting to clip the polygon.</exception>
2120
public static IPath Clip(this IPath subjectPath, params IPath[] clipPaths)
2221
=> subjectPath.Clip((IEnumerable<IPath>)clipPaths);
2322

@@ -28,7 +27,6 @@ public static IPath Clip(this IPath subjectPath, params IPath[] clipPaths)
2827
/// <param name="options">The shape options.</param>
2928
/// <param name="clipPaths">The clipping paths.</param>
3029
/// <returns>The clipped <see cref="IPath"/>.</returns>
31-
/// <exception cref="ClipperException">Thrown when an error occurred while attempting to clip the polygon.</exception>
3230
public static IPath Clip(
3331
this IPath subjectPath,
3432
ShapeOptions options,
@@ -41,7 +39,6 @@ public static IPath Clip(
4139
/// <param name="subjectPath">The subject path.</param>
4240
/// <param name="clipPaths">The clipping paths.</param>
4341
/// <returns>The clipped <see cref="IPath"/>.</returns>
44-
/// <exception cref="ClipperException">Thrown when an error occurred while attempting to clip the polygon.</exception>
4542
public static IPath Clip(this IPath subjectPath, IEnumerable<IPath> clipPaths)
4643
=> subjectPath.Clip(new ShapeOptions(), clipPaths);
4744

@@ -52,13 +49,12 @@ public static IPath Clip(this IPath subjectPath, IEnumerable<IPath> clipPaths)
5249
/// <param name="options">The shape options.</param>
5350
/// <param name="clipPaths">The clipping paths.</param>
5451
/// <returns>The clipped <see cref="IPath"/>.</returns>
55-
/// <exception cref="ClipperException">Thrown when an error occurred while attempting to clip the polygon.</exception>
5652
public static IPath Clip(
5753
this IPath subjectPath,
5854
ShapeOptions options,
5955
IEnumerable<IPath> clipPaths)
6056
{
61-
Clipper clipper = new(options.IntersectionRule);
57+
ClippedShapeGenerator clipper = new(options.IntersectionRule);
6258

6359
clipper.AddPath(subjectPath, ClippingType.Subject);
6460
clipper.AddPaths(clipPaths, ClippingType.Clip);

src/ImageSharp.Drawing/Shapes/EndCapStyle.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,26 @@ public enum EndCapStyle
3434
Joined = 4
3535
}
3636

37+
/// <summary>
38+
/// Specifies the shape to be used at the ends of open lines or paths when stroking.
39+
/// </summary>
3740
internal enum LineCap
3841
{
42+
/// <summary>
43+
/// The stroke ends exactly at the endpoint.
44+
/// No extension is added beyond the path's end coordinates.
45+
/// </summary>
3946
Butt,
47+
48+
/// <summary>
49+
/// The stroke extends beyond the endpoint by half the line width,
50+
/// producing a square edge.
51+
/// </summary>
4052
Square,
53+
54+
/// <summary>
55+
/// The stroke ends with a semicircular cap,
56+
/// extending beyond the endpoint by half the line width.
57+
/// </summary>
4158
Round
4259
}

src/ImageSharp.Drawing/Shapes/IPath.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,29 +13,29 @@ public interface IPath
1313
/// <summary>
1414
/// Gets a value indicating whether this instance is closed, open or a composite path with a mixture of open and closed figures.
1515
/// </summary>
16-
PathTypes PathType { get; }
16+
public PathTypes PathType { get; }
1717

1818
/// <summary>
1919
/// Gets the bounds enclosing the path.
2020
/// </summary>
21-
RectangleF Bounds { get; }
21+
public RectangleF Bounds { get; }
2222

2323
/// <summary>
2424
/// Converts the <see cref="IPath" /> into a simple linear path.
2525
/// </summary>
2626
/// <returns>Returns the current <see cref="IPath" /> as simple linear path.</returns>
27-
IEnumerable<ISimplePath> Flatten();
27+
public IEnumerable<ISimplePath> Flatten();
2828

2929
/// <summary>
3030
/// Transforms the path using the specified matrix.
3131
/// </summary>
3232
/// <param name="matrix">The matrix.</param>
3333
/// <returns>A new path with the matrix applied to it.</returns>
34-
IPath Transform(Matrix3x2 matrix);
34+
public IPath Transform(Matrix3x2 matrix);
3535

3636
/// <summary>
3737
/// Returns this path with all figures closed.
3838
/// </summary>
3939
/// <returns>A new close <see cref="IPath"/>.</returns>
40-
IPath AsClosedPath();
40+
public IPath AsClosedPath();
4141
}

src/ImageSharp.Drawing/Shapes/JointStyle.cs

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,72 @@ public enum JointStyle
2424
Miter = 2
2525
}
2626

27+
/// <summary>
28+
/// Specifies how the connection between two consecutive line segments (a join)
29+
/// is rendered when stroking paths or polygons.
30+
/// </summary>
2731
internal enum LineJoin
2832
{
33+
/// <summary>
34+
/// Joins lines by extending their outer edges until they meet at a sharp corner.
35+
/// The miter length is limited by the miter limit; if exceeded, the join may fall back to a bevel.
36+
/// </summary>
2937
MiterJoin = 0,
38+
39+
/// <summary>
40+
/// Joins lines by extending their outer edges to form a miter,
41+
/// but if the miter length exceeds the miter limit, the join is truncated
42+
/// at the limit distance rather than falling back to a bevel.
43+
/// </summary>
3044
MiterJoinRevert = 1,
45+
46+
/// <summary>
47+
/// Joins lines by connecting them with a circular arc centered at the join point,
48+
/// producing a smooth, rounded corner.
49+
/// </summary>
3150
RoundJoin = 2,
51+
52+
/// <summary>
53+
/// Joins lines by connecting the outer corners directly with a straight line,
54+
/// forming a flat edge at the join point.
55+
/// </summary>
3256
BevelJoin = 3,
57+
58+
/// <summary>
59+
/// Joins lines by forming a miter, but if the miter limit is exceeded,
60+
/// the join falls back to a round join instead of a bevel.
61+
/// </summary>
3362
MiterJoinRound = 4
3463
}
3564

65+
/// <summary>
66+
/// Specifies how inner corners of a stroked path or polygon are rendered
67+
/// when the path turns sharply inward. These settings control how the interior
68+
/// edge of the stroke is joined at such corners.
69+
/// </summary>
3670
internal enum InnerJoin
3771
{
72+
/// <summary>
73+
/// Joins inner corners by connecting the edges with a straight line,
74+
/// producing a flat, beveled appearance.
75+
/// </summary>
3876
InnerBevel,
77+
78+
/// <summary>
79+
/// Joins inner corners by extending the inner edges until they meet at a sharp point.
80+
/// This can create long, narrow joins for acute angles.
81+
/// </summary>
3982
InnerMiter,
83+
84+
/// <summary>
85+
/// Joins inner corners with a notched appearance,
86+
/// forming a small cut or indentation at the join.
87+
/// </summary>
4088
InnerJag,
89+
90+
/// <summary>
91+
/// Joins inner corners using a circular arc between the edges,
92+
/// creating a smooth, rounded interior transition.
93+
/// </summary>
4194
InnerRound
4295
}

0 commit comments

Comments
 (0)