// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Primitives;
using SixLabors.ImageSharp.Processing.Processors.Drawing;
namespace SixLabors.ImageSharp.Processing
{
///
/// Adds extensions that allow the filling of regions with various brushes to the type.
///
public static class FillRegionExtensions
{
///
/// Flood fills the image with the specified brush.
///
/// The type of the color.
/// The image this method extends.
/// The details how to fill the region of interest.
/// The .
public static IImageProcessingContext Fill(this IImageProcessingContext source, IBrush brush)
where TPixel : struct, IPixel
=> source.Fill(GraphicsOptions.Default, brush);
///
/// Flood fills the image with the specified color.
///
/// The type of the color.
/// The image this method extends.
/// The color.
/// The .
public static IImageProcessingContext Fill(this IImageProcessingContext source, TPixel color)
where TPixel : struct, IPixel
=> source.Fill(new SolidBrush(color));
///
/// Flood fills the image with in the region with the specified brush.
///
/// The type of the color.
/// The image this method extends.
/// The brush.
/// The region.
/// The .
public static IImageProcessingContext Fill(this IImageProcessingContext source, IBrush brush, Region region)
where TPixel : struct, IPixel
=> source.Fill(GraphicsOptions.Default, brush, region);
///
/// Flood fills the image with in the region with the specified color.
///
/// The type of the color.
/// The image this method extends.
/// The options.
/// The color.
/// The region.
/// The .
public static IImageProcessingContext Fill(this IImageProcessingContext source, GraphicsOptions options, TPixel color, Region region)
where TPixel : struct, IPixel
=> source.Fill(options, new SolidBrush(color), region);
///
/// Flood fills the image with in the region with the specified color.
///
/// The type of the color.
/// The image this method extends.
/// The color.
/// The region.
/// The .
public static IImageProcessingContext Fill(this IImageProcessingContext source, TPixel color, Region region)
where TPixel : struct, IPixel
=> source.Fill(new SolidBrush(color), region);
///
/// Flood fills the image with in the region with the specified brush.
///
/// The type of the color.
/// The image this method extends.
/// The graphics options.
/// The brush.
/// The region.
/// The .
public static IImageProcessingContext Fill(this IImageProcessingContext source, GraphicsOptions options, IBrush brush, Region region)
where TPixel : struct, IPixel
=> source.ApplyProcessor(new FillRegionProcessor(brush, region, options));
///
/// Flood fills the image with the specified brush.
///
/// The type of the color.
/// The image this method extends.
/// The graphics options.
/// The details how to fill the region of interest.
/// The .
public static IImageProcessingContext Fill(this IImageProcessingContext source, GraphicsOptions options, IBrush brush)
where TPixel : struct, IPixel
=> source.ApplyProcessor(new FillProcessor(brush, options));
}
}