// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using SixLabors.ImageSharp.Drawing; using SixLabors.ImageSharp.Drawing.Brushes; using SixLabors.ImageSharp.Drawing.Processors; using SixLabors.ImageSharp.PixelFormats; namespace SixLabors.ImageSharp { /// /// Extension methods for the type. /// public static partial class ImageExtensions { /// /// 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 { return source.ApplyProcessor(new FillProcessor(brush, 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 . public static IImageProcessingContext Fill(this IImageProcessingContext source, IBrush brush) where TPixel : struct, IPixel { return 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 { return 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 graphics options. /// The . public static IImageProcessingContext Fill(this IImageProcessingContext source, IBrush brush, Region region, GraphicsOptions options) where TPixel : struct, IPixel { return source.ApplyProcessor(new FillRegionProcessor(brush, region, options)); } /// /// 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 { return 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 { return 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 { return source.Fill(new SolidBrush(color), region); } } }