// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.Primitives;
using SixLabors.Shapes;
namespace SixLabors.ImageSharp.Processing
{
///
/// Adds extensions that allow the filling of rectangles to the type.
///
public static class FillRectangleExtensions
{
///
/// Flood fills the image in the shape of the provided rectangle with the specified brush.
///
/// The type of the color.
/// The image this method extends.
/// The options.
/// The brush.
/// The shape.
/// The .
public static IImageProcessingContext Fill(this IImageProcessingContext source, GraphicsOptions options, IBrush brush, RectangleF shape)
where TPixel : struct, IPixel
=> source.Fill(options, brush, new RectangularPolygon(shape.X, shape.Y, shape.Width, shape.Height));
///
/// Flood fills the image in the shape of the provided rectangle 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
=> source.Fill(brush, new RectangularPolygon(shape.X, shape.Y, shape.Width, shape.Height));
///
/// Flood fills the image in the shape of the provided rectangle with the specified brush.
///
/// The type of the color.
/// The image this method extends.
/// The options.
/// The color.
/// The shape.
/// The .
public static IImageProcessingContext Fill(this IImageProcessingContext source, GraphicsOptions options, TPixel color, RectangleF shape)
where TPixel : struct, IPixel
=> source.Fill(options, new SolidBrush(color), shape);
///
/// Flood fills the image in the shape of the provided rectangle 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
=> source.Fill(new SolidBrush(color), shape);
}
}