// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using System;
using SixLabors.ImageSharp.Drawing;
using SixLabors.ImageSharp.Drawing.Brushes;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.Shapes;
namespace SixLabors.ImageSharp
{
///
/// 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 graphics options.
/// The .
public static IImageProcessingContext Fill(this IImageProcessingContext source, IBrush brush, Action path, GraphicsOptions options)
where TPixel : struct, IPixel
{
var pb = new PathBuilder();
path(pb);
return source.Fill(brush, pb.Build(), 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 path.
/// The .
public static IImageProcessingContext Fill(this IImageProcessingContext source, IBrush brush, Action path)
where TPixel : struct, IPixel
{
return source.Fill(brush, path, GraphicsOptions.Default);
}
///
/// 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 path.
/// The options.
/// The .
public static IImageProcessingContext Fill(this IImageProcessingContext source, TPixel color, Action path, GraphicsOptions options)
where TPixel : struct, IPixel
{
return source.Fill(new SolidBrush(color), path, 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 path.
/// The .
public static IImageProcessingContext Fill(this IImageProcessingContext source, TPixel color, Action path)
where TPixel : struct, IPixel
{
return source.Fill(new SolidBrush(color), path);
}
}
}