ImageSharp/PolygonClipper/StrokeOptions.cs
2026-08-03 22:31:27 +02:00

66 lines
2.3 KiB
C#

// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
using System;
namespace SixLabors.PolygonClipper {
/// <summary>
/// Provides configuration options for geometric stroke generation.
/// </summary>
public sealed class StrokeOptions : IEquatable<StrokeOptions?>
{
/// <summary>
/// Gets or sets a value indicating whether stroked contours should be normalized by
/// resolving self-intersections and overlaps before returning.
/// </summary>
/// <remarks>
/// Defaults to <see langword="false"/> for maximum throughput.
/// When disabled, callers should rasterize with a non-zero winding fill rule.
/// </remarks>
public bool NormalizeOutput { get; set; }
/// <summary>
/// Gets or sets the miter limit used to clamp outer miter joins.
/// </summary>
public double MiterLimit { get; set; } = 4D;
/// <summary>
/// Gets or sets the tessellation detail scale for round joins and round caps.
/// Higher values produce more vertices (smoother curves, more work).
/// Lower values produce fewer vertices.
/// </summary>
public double ArcDetailScale { get; set; } = 1D;
/// <summary>
/// Gets or sets the outer line join style used for stroking corners.
/// </summary>
public LineJoin LineJoin { get; set; } = LineJoin.Bevel;
/// <summary>
/// Gets or sets the line cap style used for open path ends.
/// </summary>
public LineCap LineCap { get; set; } = LineCap.Butt;
/// <inheritdoc/>
public override bool Equals(object? obj) => this.Equals(obj as StrokeOptions);
/// <inheritdoc/>
public bool Equals(StrokeOptions? other)
=> other is not null &&
this.NormalizeOutput == other.NormalizeOutput &&
this.MiterLimit == other.MiterLimit &&
this.ArcDetailScale == other.ArcDetailScale &&
this.LineJoin == other.LineJoin &&
this.LineCap == other.LineCap;
/// <inheritdoc/>
public override int GetHashCode()
=> HashCode.Combine(
this.NormalizeOutput,
this.MiterLimit,
this.ArcDetailScale,
this.LineJoin,
this.LineCap);
}
}