Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions ImageSharp.Drawing.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 18
VisualStudioVersion = 18.0.11123.170 d18.0
VisualStudioVersion = 18.0.11123.170
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_root", "_root", "{C317F1B1-D75E-4C6D-83EB-80367343E0D7}"
ProjectSection(SolutionItems) = preProject
Expand Down Expand Up @@ -359,14 +359,6 @@ Global
{5493F024-0A3F-420C-AC2D-05B77A36025B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5493F024-0A3F-420C-AC2D-05B77A36025B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5493F024-0A3F-420C-AC2D-05B77A36025B}.Release|Any CPU.Build.0 = Release|Any CPU
{FCEDD229-22BC-4B82-87DE-786BBFC52EDE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FCEDD229-22BC-4B82-87DE-786BBFC52EDE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FCEDD229-22BC-4B82-87DE-786BBFC52EDE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FCEDD229-22BC-4B82-87DE-786BBFC52EDE}.Release|Any CPU.Build.0 = Release|Any CPU
{5490DFAF-0891-535F-08B4-2BF03C2BB778}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5490DFAF-0891-535F-08B4-2BF03C2BB778}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5490DFAF-0891-535F-08B4-2BF03C2BB778}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5490DFAF-0891-535F-08B4-2BF03C2BB778}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
1 change: 1 addition & 0 deletions src/ImageSharp.Drawing/ImageSharp.Drawing.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
<ItemGroup>
<PackageReference Include="SixLabors.Fonts" Version="3.0.0-alpha.0.1" />
<PackageReference Include="SixLabors.ImageSharp" Version="4.0.0-alpha.0.44" />
<PackageReference Include="SixLabors.PolygonClipper" Version="1.0.0-alpha.0.48" />
</ItemGroup>
<Import Project="..\..\shared-infrastructure\src\SharedInfrastructure\SharedInfrastructure.projitems" Label="Shared" />
</Project>
6 changes: 4 additions & 2 deletions src/ImageSharp.Drawing/Processing/ShapeOptions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.

using SixLabors.PolygonClipper;

namespace SixLabors.ImageSharp.Drawing.Processing;

/// <summary>
Expand All @@ -24,9 +26,9 @@ private ShapeOptions(ShapeOptions source)
/// <summary>
/// Gets or sets the clipping operation.
/// <para/>
/// Defaults to <see cref="ClippingOperation.Difference"/>.
/// Defaults to <see cref="BooleanOperation.Difference"/>.
/// </summary>
public ClippingOperation ClippingOperation { get; set; } = ClippingOperation.Difference;
public BooleanOperation ClippingOperation { get; set; } = BooleanOperation.Difference;

/// <summary>
/// Gets or sets the rule for calculating intersection points.
Expand Down
10 changes: 3 additions & 7 deletions src/ImageSharp.Drawing/Shapes/ClipPathExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the Six Labors Split License.

using SixLabors.ImageSharp.Drawing.Processing;
using SixLabors.ImageSharp.Drawing.Shapes.PolygonClipper;
using SixLabors.ImageSharp.Drawing.Shapes.PolygonGeometry;

namespace SixLabors.ImageSharp.Drawing;

Expand All @@ -17,7 +17,6 @@ public static class ClipPathExtensions
/// <param name="subjectPath">The subject path.</param>
/// <param name="clipPaths">The clipping paths.</param>
/// <returns>The clipped <see cref="IPath"/>.</returns>
/// <exception cref="ClipperException">Thrown when an error occurred while attempting to clip the polygon.</exception>
public static IPath Clip(this IPath subjectPath, params IPath[] clipPaths)
=> subjectPath.Clip((IEnumerable<IPath>)clipPaths);

Expand All @@ -28,7 +27,6 @@ public static IPath Clip(this IPath subjectPath, params IPath[] clipPaths)
/// <param name="options">The shape options.</param>
/// <param name="clipPaths">The clipping paths.</param>
/// <returns>The clipped <see cref="IPath"/>.</returns>
/// <exception cref="ClipperException">Thrown when an error occurred while attempting to clip the polygon.</exception>
public static IPath Clip(
this IPath subjectPath,
ShapeOptions options,
Expand All @@ -41,7 +39,6 @@ public static IPath Clip(
/// <param name="subjectPath">The subject path.</param>
/// <param name="clipPaths">The clipping paths.</param>
/// <returns>The clipped <see cref="IPath"/>.</returns>
/// <exception cref="ClipperException">Thrown when an error occurred while attempting to clip the polygon.</exception>
public static IPath Clip(this IPath subjectPath, IEnumerable<IPath> clipPaths)
=> subjectPath.Clip(new ShapeOptions(), clipPaths);

Expand All @@ -52,18 +49,17 @@ public static IPath Clip(this IPath subjectPath, IEnumerable<IPath> clipPaths)
/// <param name="options">The shape options.</param>
/// <param name="clipPaths">The clipping paths.</param>
/// <returns>The clipped <see cref="IPath"/>.</returns>
/// <exception cref="ClipperException">Thrown when an error occurred while attempting to clip the polygon.</exception>
public static IPath Clip(
this IPath subjectPath,
ShapeOptions options,
IEnumerable<IPath> clipPaths)
{
Clipper clipper = new();
ClippedShapeGenerator clipper = new(options.IntersectionRule);

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

IPath[] result = clipper.GenerateClippedShapes(options.ClippingOperation, options.IntersectionRule);
IPath[] result = clipper.GenerateClippedShapes(options.ClippingOperation);

return new ComplexPolygon(result);
}
Expand Down
38 changes: 0 additions & 38 deletions src/ImageSharp.Drawing/Shapes/ClippingOperation.cs

This file was deleted.

17 changes: 17 additions & 0 deletions src/ImageSharp.Drawing/Shapes/EndCapStyle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,26 @@ public enum EndCapStyle
Joined = 4
}

/// <summary>
/// Specifies the shape to be used at the ends of open lines or paths when stroking.
/// </summary>
internal enum LineCap
{
/// <summary>
/// The stroke ends exactly at the endpoint.
/// No extension is added beyond the path's end coordinates.
/// </summary>
Butt,

/// <summary>
/// The stroke extends beyond the endpoint by half the line width,
/// producing a square edge.
/// </summary>
Square,

/// <summary>
/// The stroke ends with a semicircular cap,
/// extending beyond the endpoint by half the line width.
/// </summary>
Round
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;

namespace SixLabors.ImageSharp.Drawing.Shapes.PolygonClipper;
namespace SixLabors.ImageSharp.Drawing.Shapes.Helpers;

/// <summary>
/// A helper type for avoiding allocations while building arrays.
Expand Down
10 changes: 5 additions & 5 deletions src/ImageSharp.Drawing/Shapes/IPath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,29 @@ public interface IPath
/// <summary>
/// Gets a value indicating whether this instance is closed, open or a composite path with a mixture of open and closed figures.
/// </summary>
PathTypes PathType { get; }
public PathTypes PathType { get; }

/// <summary>
/// Gets the bounds enclosing the path.
/// </summary>
RectangleF Bounds { get; }
public RectangleF Bounds { get; }

/// <summary>
/// Converts the <see cref="IPath" /> into a simple linear path.
/// </summary>
/// <returns>Returns the current <see cref="IPath" /> as simple linear path.</returns>
IEnumerable<ISimplePath> Flatten();
public IEnumerable<ISimplePath> Flatten();

/// <summary>
/// Transforms the path using the specified matrix.
/// </summary>
/// <param name="matrix">The matrix.</param>
/// <returns>A new path with the matrix applied to it.</returns>
IPath Transform(Matrix3x2 matrix);
public IPath Transform(Matrix3x2 matrix);

/// <summary>
/// Returns this path with all figures closed.
/// </summary>
/// <returns>A new close <see cref="IPath"/>.</returns>
IPath AsClosedPath();
public IPath AsClosedPath();
}
4 changes: 2 additions & 2 deletions src/ImageSharp.Drawing/Shapes/ISimplePath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ public interface ISimplePath
/// <summary>
/// Gets a value indicating whether this instance is a closed path.
/// </summary>
bool IsClosed { get; }
public bool IsClosed { get; }

/// <summary>
/// Gets the points that make this up as a simple linear path.
/// </summary>
ReadOnlyMemory<PointF> Points { get; }
public ReadOnlyMemory<PointF> Points { get; }
}
53 changes: 53 additions & 0 deletions src/ImageSharp.Drawing/Shapes/JointStyle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,72 @@ public enum JointStyle
Miter = 2
}

/// <summary>
/// Specifies how the connection between two consecutive line segments (a join)
/// is rendered when stroking paths or polygons.
/// </summary>
internal enum LineJoin
{
/// <summary>
/// Joins lines by extending their outer edges until they meet at a sharp corner.
/// The miter length is limited by the miter limit; if exceeded, the join may fall back to a bevel.
/// </summary>
MiterJoin = 0,

/// <summary>
/// Joins lines by extending their outer edges to form a miter,
/// but if the miter length exceeds the miter limit, the join is truncated
/// at the limit distance rather than falling back to a bevel.
/// </summary>
MiterJoinRevert = 1,

/// <summary>
/// Joins lines by connecting them with a circular arc centered at the join point,
/// producing a smooth, rounded corner.
/// </summary>
RoundJoin = 2,

/// <summary>
/// Joins lines by connecting the outer corners directly with a straight line,
/// forming a flat edge at the join point.
/// </summary>
BevelJoin = 3,

/// <summary>
/// Joins lines by forming a miter, but if the miter limit is exceeded,
/// the join falls back to a round join instead of a bevel.
/// </summary>
MiterJoinRound = 4
}

/// <summary>
/// Specifies how inner corners of a stroked path or polygon are rendered
/// when the path turns sharply inward. These settings control how the interior
/// edge of the stroke is joined at such corners.
/// </summary>
internal enum InnerJoin
{
/// <summary>
/// Joins inner corners by connecting the edges with a straight line,
/// producing a flat, beveled appearance.
/// </summary>
InnerBevel,

/// <summary>
/// Joins inner corners by extending the inner edges until they meet at a sharp point.
/// This can create long, narrow joins for acute angles.
/// </summary>
InnerMiter,

/// <summary>
/// Joins inner corners with a notched appearance,
/// forming a small cut or indentation at the join.
/// </summary>
InnerJag,

/// <summary>
/// Joins inner corners using a circular arc between the edges,
/// creating a smooth, rounded interior transition.
/// </summary>
InnerRound
}
Loading
Loading