// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using System;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.Shapes;
namespace SixLabors.ImageSharp.Processing
{
///
/// Adds extensions that allow the filling of polygons with various brushes to the type.
///
public static class FillPathBuilderExtensions
{
///
/// Flood fills the image in the shape of the provided polygon with the specified brush.
///
/// The image this method extends.
/// The graphics options.
/// The brush.
/// The shape.
/// The .
public static IImageProcessingContext Fill(
this IImageProcessingContext source,
GraphicsOptions options,
IBrush brush,
Action path)
{
var pb = new PathBuilder();
path(pb);
return source.Fill(options, brush, pb.Build());
}
///
/// Flood fills the image in the shape of the provided polygon with the specified brush.
///
/// The image this method extends.
/// The brush.
/// The path.
/// The .
public static IImageProcessingContext Fill(
this IImageProcessingContext source,
IBrush brush,
Action path) =>
source.Fill(GraphicsOptions.Default, brush, path);
///
/// Flood fills the image in the shape of the provided polygon with the specified brush.
///
/// The image this method extends.
/// The options.
/// The color.
/// The path.
/// The .
public static IImageProcessingContext Fill(
this IImageProcessingContext source,
GraphicsOptions options,
Color color,
Action path) =>
source.Fill(options, new SolidBrush(color), path);
///
/// Flood fills the image in the shape of the provided polygon with the specified brush.
///
/// The image this method extends.
/// The color.
/// The path.
/// The .
public static IImageProcessingContext Fill(
this IImageProcessingContext source,
Color color,
Action path) =>
source.Fill(new SolidBrush(color), path);
}
}