@@ -10,131 +10,57 @@ namespace SixLabors.ImageSharp.Drawing.Processing
1010 /// <summary>
1111 /// Options for influencing the drawing functions.
1212 /// </summary>
13- public class ShapeGraphicsOptions : IDeepCloneable < ShapeGraphicsOptions >
13+ public class ShapeGraphicsOptions
1414 {
15- private int antialiasSubpixelDepth = 16 ;
16- private float blendPercentage = 1F ;
15+ private GraphicsOptions graphicsOptions ;
16+ private ShapeOptions shapeOptions ;
1717
1818 /// <summary>
1919 /// Initializes a new instance of the <see cref="ShapeGraphicsOptions"/> class.
2020 /// </summary>
2121 public ShapeGraphicsOptions ( )
2222 {
23+ this . graphicsOptions = new GraphicsOptions ( ) ;
24+ this . shapeOptions = new ShapeOptions ( ) ;
2325 }
2426
2527 /// <summary>
2628 /// Initializes a new instance of the <see cref="ShapeGraphicsOptions"/> class.
2729 /// </summary>
28- /// <param name="source">The source to clone from.</param>
29- public ShapeGraphicsOptions ( GraphicsOptions source )
30+ /// <param name="graphicsOptions">The graphic options to use</param>
31+ /// <param name="shapeOptions">The text options to use</param>
32+ public ShapeGraphicsOptions ( GraphicsOptions graphicsOptions , ShapeOptions shapeOptions )
3033 {
31- this . AlphaCompositionMode = source . AlphaCompositionMode ;
32- this . Antialias = source . Antialias ;
33- this . AntialiasSubpixelDepth = source . AntialiasSubpixelDepth ;
34- this . BlendPercentage = source . BlendPercentage ;
35- this . ColorBlendingMode = source . ColorBlendingMode ;
34+ Guard . NotNull ( graphicsOptions , nameof ( graphicsOptions ) ) ;
35+ Guard . NotNull ( shapeOptions , nameof ( shapeOptions ) ) ;
36+ this . graphicsOptions = graphicsOptions ;
37+ this . shapeOptions = shapeOptions ;
3638 }
3739
38- private ShapeGraphicsOptions ( ShapeGraphicsOptions source )
39- {
40- this . AlphaCompositionMode = source . AlphaCompositionMode ;
41- this . Antialias = source . Antialias ;
42- this . AntialiasSubpixelDepth = source . AntialiasSubpixelDepth ;
43- this . BlendPercentage = source . BlendPercentage ;
44- this . ColorBlendingMode = source . ColorBlendingMode ;
45- this . IntersectionRule = source . IntersectionRule ;
46- }
47-
48- /// <summary>
49- /// Gets or sets a value indicating whether antialiasing should be applied.
50- /// Defaults to true.
51- /// </summary>
52- public IntersectionRule IntersectionRule { get ; set ; } = IntersectionRule . OddEven ;
53-
54- /// <summary>
55- /// Gets or sets a value indicating whether antialiasing should be applied.
56- /// Defaults to true.
57- /// </summary>
58- public bool Antialias { get ; set ; } = true ;
59-
6040 /// <summary>
61- /// Gets or sets a value indicating the number of subpixels to use while rendering with antialiasing enabled .
41+ /// Gets or sets the Graphics Options .
6242 /// </summary>
63- public int AntialiasSubpixelDepth
43+ public GraphicsOptions GraphicsOptions
6444 {
65- get
66- {
67- return this . antialiasSubpixelDepth ;
68- }
69-
45+ get => this . graphicsOptions ;
7046 set
7147 {
72- Guard . MustBeGreaterThanOrEqualTo ( value , 0 , nameof ( this . AntialiasSubpixelDepth ) ) ;
73- this . antialiasSubpixelDepth = value ;
48+ Guard . NotNull ( value , nameof ( this . GraphicsOptions ) ) ;
49+ this . graphicsOptions = value ;
7450 }
7551 }
7652
7753 /// <summary>
78- /// Gets or sets a value indicating the blending percentage to apply to the drawing operation .
54+ /// Gets or sets the Text Options .
7955 /// </summary>
80- public float BlendPercentage
56+ public ShapeOptions ShapeOptions
8157 {
82- get
83- {
84- return this . blendPercentage ;
85- }
86-
58+ get => this . shapeOptions ;
8759 set
8860 {
89- Guard . MustBeBetweenOrEqualTo ( value , 0 , 1F , nameof ( this . BlendPercentage ) ) ;
90- this . blendPercentage = value ;
61+ Guard . NotNull ( value , nameof ( this . ShapeOptions ) ) ;
62+ this . shapeOptions = value ;
9163 }
9264 }
93-
94- /// <summary>
95- /// Gets or sets a value indicating the color blending percentage to apply to the drawing operation.
96- /// Defaults to <see cref= "PixelColorBlendingMode.Normal" />.
97- /// </summary>
98- public PixelColorBlendingMode ColorBlendingMode { get ; set ; } = PixelColorBlendingMode . Normal ;
99-
100- /// <summary>
101- /// Gets or sets a value indicating the color blending percentage to apply to the drawing operation
102- /// Defaults to <see cref= "PixelAlphaCompositionMode.SrcOver" />.
103- /// </summary>
104- public PixelAlphaCompositionMode AlphaCompositionMode { get ; set ; } = PixelAlphaCompositionMode . SrcOver ;
105-
106- /// <summary>
107- /// Performs an implicit conversion from <see cref="GraphicsOptions"/> to <see cref="TextGraphicsOptions"/>.
108- /// </summary>
109- /// <param name="options">The options.</param>
110- /// <returns>
111- /// The result of the conversion.
112- /// </returns>
113- public static implicit operator ShapeGraphicsOptions ( GraphicsOptions options )
114- {
115- return new ShapeGraphicsOptions ( options ) ;
116- }
117-
118- /// <summary>
119- /// Performs an explicit conversion from <see cref="TextGraphicsOptions"/> to <see cref="GraphicsOptions"/>.
120- /// </summary>
121- /// <param name="options">The options.</param>
122- /// <returns>
123- /// The result of the conversion.
124- /// </returns>
125- public static explicit operator GraphicsOptions ( ShapeGraphicsOptions options )
126- {
127- return new GraphicsOptions ( )
128- {
129- Antialias = options . Antialias ,
130- AntialiasSubpixelDepth = options . AntialiasSubpixelDepth ,
131- ColorBlendingMode = options . ColorBlendingMode ,
132- AlphaCompositionMode = options . AlphaCompositionMode ,
133- BlendPercentage = options . BlendPercentage
134- } ;
135- }
136-
137- /// <inheritdoc/>
138- public ShapeGraphicsOptions DeepClone ( ) => new ShapeGraphicsOptions ( this ) ;
13965 }
14066}
0 commit comments