// // Copyright (c) James Jackson-South and contributors. // Licensed under the Apache License, Version 2.0. // namespace ImageSharp { using Drawing; using Drawing.Brushes; using ImageSharp.PixelFormats; using SixLabors.Primitives; /// /// Extension methods for the type. /// public static partial class ImageExtensions { /// /// Flood fills the image in the shape of the provided polygon with the specified brush.. /// /// The type of the color. /// The image this method extends. /// The brush. /// The shape. /// The options. /// The . public static IImageProcessingContext Fill(this IImageProcessingContext source, IBrush brush, RectangleF shape, GraphicsOptions options) where TPixel : struct, IPixel { return source.Fill(brush, new SixLabors.Shapes.RectangularePolygon(shape.X, shape.Y, shape.Width, shape.Height), options); } /// /// Flood fills the image in the shape of the provided polygon with the specified brush.. /// /// The type of the color. /// The image this method extends. /// The brush. /// The shape. /// The . public static IImageProcessingContext Fill(this IImageProcessingContext source, IBrush brush, RectangleF shape) where TPixel : struct, IPixel { return source.Fill(brush, new SixLabors.Shapes.RectangularePolygon(shape.X, shape.Y, shape.Width, shape.Height)); } /// /// Flood fills the image in the shape of the provided polygon with the specified brush.. /// /// The type of the color. /// The image this method extends. /// The color. /// The shape. /// The options. /// The . public static IImageProcessingContext Fill(this IImageProcessingContext source, TPixel color, RectangleF shape, GraphicsOptions options) where TPixel : struct, IPixel { return source.Fill(new SolidBrush(color), shape, options); } /// /// Flood fills the image in the shape of the provided polygon with the specified brush.. /// /// The type of the color. /// The image this method extends. /// The color. /// The shape. /// The . public static IImageProcessingContext Fill(this IImageProcessingContext source, TPixel color, RectangleF shape) where TPixel : struct, IPixel { return source.Fill(new SolidBrush(color), shape); } } }