/
ClearRegionExtensions.cs
64 lines (59 loc) · 3.11 KB
/
ClearRegionExtensions.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.Drawing.Processing.Processors.Drawing;
using SixLabors.ImageSharp.Processing;
namespace SixLabors.ImageSharp.Drawing.Processing
{
/// <summary>
/// Adds extensions that allow the filling of regions with various brushes to the <see cref="Image{TPixel}"/> type.
/// </summary>
public static class ClearRegionExtensions
{
/// <summary>
/// Flood fills the image with in the region with the specified brush without any blending.
/// </summary>
/// <param name="source">The image this method extends.</param>
/// <param name="brush">The brush.</param>
/// <param name="region">The region.</param>
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
public static IImageProcessingContext Clear(this IImageProcessingContext source, IBrush brush, Region region) =>
source.Clear(source.GetDrawingOptions(), brush, region);
/// <summary>
/// Flood fills the image with in the region with the specified brush without any blending.
/// </summary>
/// <param name="source">The image this method extends.</param>
/// <param name="options">The graphics options.</param>
/// <param name="brush">The brush.</param>
/// <param name="region">The region.</param>
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
public static IImageProcessingContext Clear(
this IImageProcessingContext source,
DrawingOptions options,
IBrush brush,
Region region) =>
source.Fill(options.CloneForClearOperation(), brush, region);
/// <summary>
/// Flood fills the image with in the region with the specified color without any blending.
/// </summary>
/// <param name="source">The image this method extends.</param>
/// <param name="options">The options.</param>
/// <param name="color">The color.</param>
/// <param name="region">The region.</param>
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
public static IImageProcessingContext Clear(
this IImageProcessingContext source,
DrawingOptions options,
Color color,
Region region) =>
source.Clear(options, new SolidBrush(color), region);
/// <summary>
/// Flood fills the image with in the region with the specified color without any blending.
/// </summary>
/// <param name="source">The image this method extends.</param>
/// <param name="color">The color.</param>
/// <param name="region">The region.</param>
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
public static IImageProcessingContext Clear(this IImageProcessingContext source, Color color, Region region) =>
source.Clear(new SolidBrush(color), region);
}
}