Skip to content

Commit dfba96f

Browse files
Rip out region.
1 parent a1ca308 commit dfba96f

37 files changed

Lines changed: 304 additions & 824 deletions

src/ImageSharp.Drawing/Primitives/Region.cs

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/ImageSharp.Drawing/Primitives/ShapePath.cs

Lines changed: 0 additions & 23 deletions
This file was deleted.

src/ImageSharp.Drawing/Primitives/ShapeRegion.cs

Lines changed: 0 additions & 38 deletions
This file was deleted.
Lines changed: 44 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,84 @@
11
// Copyright (c) Six Labors.
22
// Licensed under the Apache License, Version 2.0.
33

4-
using SixLabors.ImageSharp.Drawing.Processing.Processors.Drawing;
54
using SixLabors.ImageSharp.Processing;
65

76
namespace SixLabors.ImageSharp.Drawing.Processing
87
{
98
/// <summary>
10-
/// Adds extensions that allow the filling of polygon outlines to the <see cref="Image{TPixel}"/> type.
9+
/// Adds extensions that allow the flood filling of polygon outlines without blending.
1110
/// </summary>
1211
public static class ClearPathExtensions
1312
{
1413
/// <summary>
15-
/// Clones the shape graphic options and applies changes required to force clearing.
14+
/// Flood fills the image in the path of the provided polygon with the specified brush without any blending.
1615
/// </summary>
17-
/// <param name="shapeOptions">The options to clone</param>
18-
/// <returns>A clone of shapeOptions with ColorBlendingMode, AlphaCompositionMode, and BlendPercentage set</returns>
19-
internal static DrawingOptions CloneForClearOperation(this DrawingOptions shapeOptions)
20-
{
21-
GraphicsOptions options = shapeOptions.GraphicsOptions.DeepClone();
22-
options.ColorBlendingMode = PixelFormats.PixelColorBlendingMode.Normal;
23-
options.AlphaCompositionMode = PixelFormats.PixelAlphaCompositionMode.Src;
24-
options.BlendPercentage = 1;
25-
26-
return new DrawingOptions(options, shapeOptions.ShapeOptions, shapeOptions.TextOptions, shapeOptions.Transform);
27-
}
16+
/// <param name="source">The image processing context.</param>
17+
/// <param name="color">The color.</param>
18+
/// <param name="path">The logic path.</param>
19+
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
20+
public static IImageProcessingContext Clear(
21+
this IImageProcessingContext source,
22+
Color color,
23+
IPath path) =>
24+
source.Clear(new SolidBrush(color), path);
2825

2926
/// <summary>
30-
/// Flood fills the image in the shape of the provided polygon with the specified brush without any blending.
27+
/// Flood fills the image in the path of the provided polygon with the specified brush without any blending.
3128
/// </summary>
32-
/// <param name="source">The image this method extends.</param>
33-
/// <param name="options">The graphics options.</param>
34-
/// <param name="brush">The brush.</param>
35-
/// <param name="path">The shape.</param>
29+
/// <param name="source">The image processing context.</param>
30+
/// <param name="options">The drawing options.</param>
31+
/// <param name="color">The color.</param>
32+
/// <param name="path">The logic path.</param>
3633
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
3734
public static IImageProcessingContext Clear(
3835
this IImageProcessingContext source,
3936
DrawingOptions options,
40-
IBrush brush,
37+
Color color,
4138
IPath path) =>
42-
source.Fill(options.CloneForClearOperation(), brush, path);
39+
source.Clear(options, new SolidBrush(color), path);
4340

4441
/// <summary>
45-
/// Flood fills the image in the shape of the provided polygon with the specified brush without any blending.
42+
/// Flood fills the image in the path of the provided polygon with the specified brush without any blending.
4643
/// </summary>
47-
/// <param name="source">The image this method extends.</param>
44+
/// <param name="source">The image processing context.</param>
4845
/// <param name="brush">The brush.</param>
49-
/// <param name="path">The path.</param>
46+
/// <param name="path">The logic path.</param>
5047
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
51-
public static IImageProcessingContext Clear(this IImageProcessingContext source, IBrush brush, IPath path) =>
48+
public static IImageProcessingContext Clear(
49+
this IImageProcessingContext source,
50+
IBrush brush,
51+
IPath path) =>
5252
source.Clear(source.GetDrawingOptions(), brush, path);
5353

5454
/// <summary>
55-
/// Flood fills the image in the shape of the provided polygon with the specified brush without any blending.
55+
/// Flood fills the image in the path of the provided polygon with the specified brush without any blending.
5656
/// </summary>
57-
/// <param name="source">The image this method extends.</param>
58-
/// <param name="options">The options.</param>
59-
/// <param name="color">The color.</param>
60-
/// <param name="path">The path.</param>
57+
/// <param name="source">The image processing context.</param>
58+
/// <param name="options">The drawing options.</param>
59+
/// <param name="brush">The brush.</param>
60+
/// <param name="path">The logic path.</param>
6161
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
6262
public static IImageProcessingContext Clear(
6363
this IImageProcessingContext source,
6464
DrawingOptions options,
65-
Color color,
65+
IBrush brush,
6666
IPath path) =>
67-
source.Clear(options, new SolidBrush(color), path);
67+
source.Fill(options.CloneForClearOperation(), brush, path);
6868

6969
/// <summary>
70-
/// Flood fills the image in the shape of the provided polygon with the specified brush without any blending.
70+
/// Clones the path graphic options and applies changes required to force clearing.
7171
/// </summary>
72-
/// <param name="source">The image this method extends.</param>
73-
/// <param name="color">The color.</param>
74-
/// <param name="path">The path.</param>
75-
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
76-
public static IImageProcessingContext Clear(this IImageProcessingContext source, Color color, IPath path) =>
77-
source.Clear(new SolidBrush(color), path);
72+
/// <param name="shapeOptions">The drawing options to clone</param>
73+
/// <returns>A clone of shapeOptions with ColorBlendingMode, AlphaCompositionMode, and BlendPercentage set</returns>
74+
internal static DrawingOptions CloneForClearOperation(this DrawingOptions shapeOptions)
75+
{
76+
GraphicsOptions options = shapeOptions.GraphicsOptions.DeepClone();
77+
options.ColorBlendingMode = PixelFormats.PixelColorBlendingMode.Normal;
78+
options.AlphaCompositionMode = PixelFormats.PixelAlphaCompositionMode.Src;
79+
options.BlendPercentage = 1F;
80+
81+
return new DrawingOptions(options, shapeOptions.ShapeOptions, shapeOptions.TextOptions, shapeOptions.Transform);
82+
}
7883
}
7984
}

src/ImageSharp.Drawing/Processing/Extensions/ClearRegionExtensions.cs

Lines changed: 0 additions & 64 deletions
This file was deleted.

src/ImageSharp.Drawing/Processing/Extensions/FillPathExtensions.cs

Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,42 +7,30 @@
77
namespace SixLabors.ImageSharp.Drawing.Processing
88
{
99
/// <summary>
10-
/// Adds extensions that allow the filling of polygon outlines to the <see cref="Image{TPixel}"/> type.
10+
/// Adds extensions that allow the filling of polygon outlines.
1111
/// </summary>
1212
public static class FillPathExtensions
1313
{
1414
/// <summary>
15-
/// Flood fills the image in the shape of the provided polygon with the specified brush.
15+
/// Flood fills the image in the shape of the provided polygon with the specified brush..
1616
/// </summary>
17-
/// <param name="source">The image this method extends.</param>
18-
/// <param name="options">The graphics options.</param>
19-
/// <param name="brush">The brush.</param>
20-
/// <param name="path">The shape.</param>
17+
/// <param name="source">The image processing context.</param>
18+
/// <param name="color">The color.</param>
19+
/// <param name="path">The logic path.</param>
2120
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
2221
public static IImageProcessingContext Fill(
2322
this IImageProcessingContext source,
24-
DrawingOptions options,
25-
IBrush brush,
23+
Color color,
2624
IPath path) =>
27-
source.ApplyProcessor(new FillPathProcessor(options, brush, path));
28-
29-
/// <summary>
30-
/// Flood fills the image in the shape of the provided polygon with the specified brush.
31-
/// </summary>
32-
/// <param name="source">The image this method extends.</param>
33-
/// <param name="brush">The brush.</param>
34-
/// <param name="path">The path.</param>
35-
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
36-
public static IImageProcessingContext Fill(this IImageProcessingContext source, IBrush brush, IPath path) =>
37-
source.Fill(source.GetDrawingOptions(), brush, path);
25+
source.Fill(new SolidBrush(color), path);
3826

3927
/// <summary>
4028
/// Flood fills the image in the shape of the provided polygon with the specified brush..
4129
/// </summary>
42-
/// <param name="source">The image this method extends.</param>
43-
/// <param name="options">The options.</param>
30+
/// <param name="source">The image processing context.</param>
31+
/// <param name="options">The drawing options.</param>
4432
/// <param name="color">The color.</param>
45-
/// <param name="path">The path.</param>
33+
/// <param name="path">The logic path.</param>
4634
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
4735
public static IImageProcessingContext Fill(
4836
this IImageProcessingContext source,
@@ -52,13 +40,31 @@ public static IImageProcessingContext Fill(
5240
source.Fill(options, new SolidBrush(color), path);
5341

5442
/// <summary>
55-
/// Flood fills the image in the shape of the provided polygon with the specified brush..
43+
/// Flood fills the image in the shape of the provided polygon with the specified brush.
5644
/// </summary>
57-
/// <param name="source">The image this method extends.</param>
58-
/// <param name="color">The color.</param>
59-
/// <param name="path">The path.</param>
45+
/// <param name="source">The image processing context.</param>
46+
/// <param name="brush">The brush.</param>
47+
/// <param name="path">The logic path.</param>
6048
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
61-
public static IImageProcessingContext Fill(this IImageProcessingContext source, Color color, IPath path) =>
62-
source.Fill(new SolidBrush(color), path);
49+
public static IImageProcessingContext Fill(
50+
this IImageProcessingContext source,
51+
IBrush brush,
52+
IPath path) =>
53+
source.Fill(source.GetDrawingOptions(), brush, path);
54+
55+
/// <summary>
56+
/// Flood fills the image in the shape of the provided polygon with the specified brush.
57+
/// </summary>
58+
/// <param name="source">The image processing context.</param>
59+
/// <param name="options">The drawing options.</param>
60+
/// <param name="brush">The brush.</param>
61+
/// <param name="path">The shape.</param>
62+
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
63+
public static IImageProcessingContext Fill(
64+
this IImageProcessingContext source,
65+
DrawingOptions options,
66+
IBrush brush,
67+
IPath path) =>
68+
source.ApplyProcessor(new FillPathProcessor(options, brush, path));
6369
}
6470
}

0 commit comments

Comments
 (0)