66namespace SixLabors . ImageSharp ;
77
88/// <summary>
9- /// Options for influencing the drawing functions.
9+ /// Provides configuration for controlling how graphics operations are rendered,
10+ /// including antialiasing, pixel blending, alpha composition, and coverage thresholding.
1011/// </summary>
1112public class GraphicsOptions : IDeepCloneable < GraphicsOptions >
1213{
13- private int antialiasSubpixelDepth = 16 ;
14+ private float antialiasThreshold = .5F ;
1415 private float blendPercentage = 1F ;
1516
1617 /// <summary>
@@ -24,61 +25,62 @@ private GraphicsOptions(GraphicsOptions source)
2425 {
2526 this . AlphaCompositionMode = source . AlphaCompositionMode ;
2627 this . Antialias = source . Antialias ;
27- this . AntialiasSubpixelDepth = source . AntialiasSubpixelDepth ;
28+ this . AntialiasThreshold = source . AntialiasThreshold ;
2829 this . BlendPercentage = source . BlendPercentage ;
2930 this . ColorBlendingMode = source . ColorBlendingMode ;
3031 }
3132
3233 /// <summary>
3334 /// Gets or sets a value indicating whether antialiasing should be applied.
34- /// Defaults to true.
35+ /// When <see langword="true"/>, edges are rendered with smooth sub-pixel coverage.
36+ /// When <see langword="false"/>, coverage is snapped to binary (fully opaque or fully transparent)
37+ /// using <see cref="AntialiasThreshold"/> as the cutoff.
38+ /// Defaults to <see langword="true"/>.
3539 /// </summary>
3640 public bool Antialias { get ; set ; } = true ;
3741
3842 /// <summary>
39- /// Gets or sets a value indicating the number of subpixels to use while rendering with antialiasing enabled.
40- /// Defaults to 16.
43+ /// Gets or sets the coverage threshold used when <see cref="Antialias"/> is <see langword="false"/>.
44+ /// Pixels with antialiased coverage above this value are rendered as fully opaque;
45+ /// pixels below are discarded. Valid range is 0 to 1. Lower values preserve more
46+ /// thin features at small sizes. Defaults to <c>0.5F</c>.
4147 /// </summary>
42- public int AntialiasSubpixelDepth
48+ public float AntialiasThreshold
4349 {
44- get
45- {
46- return this . antialiasSubpixelDepth ;
47- }
50+ get => this . antialiasThreshold ;
4851
4952 set
5053 {
51- Guard . MustBeGreaterThanOrEqualTo ( value , 0 , nameof ( this . AntialiasSubpixelDepth ) ) ;
52- this . antialiasSubpixelDepth = value ;
54+ Guard . MustBeBetweenOrEqualTo ( value , 0F , 1F , nameof ( this . AntialiasThreshold ) ) ;
55+ this . antialiasThreshold = value ;
5356 }
5457 }
5558
5659 /// <summary>
57- /// Gets or sets a value between indicating the blending percentage to apply to the drawing operation.
58- /// Range 0..1; Defaults to 1.
60+ /// Gets or sets the blending percentage applied to the drawing operation.
61+ /// A value of <c>1.0</c> applies the operation at full strength; <c>0.0</c> makes it invisible.
62+ /// Valid range is 0 to 1. Defaults to <c>1.0F</c>.
5963 /// </summary>
6064 public float BlendPercentage
6165 {
62- get
63- {
64- return this . blendPercentage ;
65- }
66+ get => this . blendPercentage ;
6667
6768 set
6869 {
69- Guard . MustBeBetweenOrEqualTo ( value , 0 , 1F , nameof ( this . BlendPercentage ) ) ;
70+ Guard . MustBeBetweenOrEqualTo ( value , 0F , 1F , nameof ( this . BlendPercentage ) ) ;
7071 this . blendPercentage = value ;
7172 }
7273 }
7374
7475 /// <summary>
75- /// Gets or sets a value indicating the color blending mode to apply to the drawing operation .
76+ /// Gets or sets the color blending mode used to combine source and destination pixel colors .
7677 /// Defaults to <see cref="PixelColorBlendingMode.Normal"/>.
7778 /// </summary>
7879 public PixelColorBlendingMode ColorBlendingMode { get ; set ; } = PixelColorBlendingMode . Normal ;
7980
8081 /// <summary>
81- /// Gets or sets a value indicating the alpha composition mode to apply to the drawing operation
82+ /// Gets or sets the alpha composition mode that determines how source and destination alpha
83+ /// channels are combined using Porter-Duff operators.
8284 /// Defaults to <see cref="PixelAlphaCompositionMode.SrcOver"/>.
8385 /// </summary>
8486 public PixelAlphaCompositionMode AlphaCompositionMode { get ; set ; } = PixelAlphaCompositionMode . SrcOver ;
0 commit comments