mirror of https://github.com/SixLabors/ImageSharp
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
76 lines
3.0 KiB
76 lines
3.0 KiB
// Copyright (c) Six Labors and contributors.
|
|
// Licensed under the Apache License, Version 2.0.
|
|
|
|
using SixLabors.Shapes;
|
|
|
|
namespace SixLabors.ImageSharp.Processing
|
|
{
|
|
/// <summary>
|
|
/// Adds extensions that allow the filling of collections of polygon outlines to the <see cref="Image{TPixel}"/> type.
|
|
/// </summary>
|
|
public static class FillPathCollectionExtensions
|
|
{
|
|
/// <summary>
|
|
/// Flood fills the image in the shape of the provided polygon with the specified brush.
|
|
/// </summary>
|
|
/// <param name="source">The image this method extends.</param>
|
|
/// <param name="options">The graphics options.</param>
|
|
/// <param name="brush">The brush.</param>
|
|
/// <param name="paths">The shapes.</param>
|
|
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
|
|
public static IImageProcessingContext Fill(
|
|
this IImageProcessingContext source,
|
|
GraphicsOptions options,
|
|
IBrush brush,
|
|
IPathCollection paths)
|
|
{
|
|
foreach (IPath s in paths)
|
|
{
|
|
source.Fill(options, brush, s);
|
|
}
|
|
|
|
return source;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Flood fills the image in the shape of the provided polygon with the specified brush.
|
|
/// </summary>
|
|
/// <param name="source">The image this method extends.</param>
|
|
/// <param name="brush">The brush.</param>
|
|
/// <param name="paths">The paths.</param>
|
|
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
|
|
public static IImageProcessingContext Fill(
|
|
this IImageProcessingContext source,
|
|
IBrush brush,
|
|
IPathCollection paths) =>
|
|
source.Fill(new GraphicsOptions(), brush, paths);
|
|
|
|
/// <summary>
|
|
/// Flood fills the image in the shape of the provided polygon with the specified brush.
|
|
/// </summary>
|
|
/// <param name="source">The image this method extends.</param>
|
|
/// <param name="options">The options.</param>
|
|
/// <param name="color">The color.</param>
|
|
/// <param name="paths">The paths.</param>
|
|
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
|
|
public static IImageProcessingContext Fill(
|
|
this IImageProcessingContext source,
|
|
GraphicsOptions options,
|
|
Color color,
|
|
IPathCollection paths) =>
|
|
source.Fill(options, new SolidBrush(color), paths);
|
|
|
|
/// <summary>
|
|
/// Flood fills the image in the shape of the provided polygon with the specified brush.
|
|
/// </summary>
|
|
/// <param name="source">The image this method extends.</param>
|
|
/// <param name="color">The color.</param>
|
|
/// <param name="paths">The paths.</param>
|
|
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
|
|
public static IImageProcessingContext Fill(
|
|
this IImageProcessingContext source,
|
|
Color color,
|
|
IPathCollection paths) =>
|
|
source.Fill(new SolidBrush(color), paths);
|
|
}
|
|
}
|