// 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.Drawing.Brushes; using SixLabors.ImageSharp.Processing.Drawing.Processors; namespace SixLabors.ImageSharp.Processing.Drawing { /// /// 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(brush, GraphicsOptions.Default); /// /// 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(brush, region, GraphicsOptions.Default); /// /// 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 options. /// The . public static IImageProcessingContext Fill(this IImageProcessingContext source, TPixel color, Region region, GraphicsOptions options) where TPixel : struct, IPixel => source.Fill(new SolidBrush(color), region, options); /// /// 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 brush. /// The region. /// The graphics options. /// The . public static IImageProcessingContext Fill(this IImageProcessingContext source, IBrush brush, Region region, GraphicsOptions options) 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 details how to fill the region of interest. /// The graphics options. /// The . public static IImageProcessingContext Fill(this IImageProcessingContext source, IBrush brush, GraphicsOptions options) where TPixel : struct, IPixel => source.ApplyProcessor(new FillProcessor(brush, options)); } }