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.
110 lines
4.6 KiB
110 lines
4.6 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 drawing of collections of polygon outlines to the <see cref="Image{TPixel}"/> type.
|
|
/// </summary>
|
|
public static class DrawPathCollectionExtensions
|
|
{
|
|
/// <summary>
|
|
/// Draws the outline of the polygon with the provided pen.
|
|
/// </summary>
|
|
/// <param name="source">The image this method extends.</param>
|
|
/// <param name="options">The options.</param>
|
|
/// <param name="pen">The pen.</param>
|
|
/// <param name="paths">The paths.</param>
|
|
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
|
|
public static IImageProcessingContext Draw(
|
|
this IImageProcessingContext source,
|
|
GraphicsOptions options,
|
|
IPen pen,
|
|
IPathCollection paths)
|
|
{
|
|
foreach (IPath path in paths)
|
|
{
|
|
source.Draw(options, pen, path);
|
|
}
|
|
|
|
return source;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Draws the outline of the polygon with the provided pen.
|
|
/// </summary>
|
|
/// <param name="source">The image this method extends.</param>
|
|
/// <param name="pen">The pen.</param>
|
|
/// <param name="paths">The paths.</param>
|
|
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
|
|
public static IImageProcessingContext
|
|
Draw(this IImageProcessingContext source, IPen pen, IPathCollection paths) =>
|
|
source.Draw(new GraphicsOptions(), pen, paths);
|
|
|
|
/// <summary>
|
|
/// Draws the outline of the polygon with the provided brush at the provided thickness.
|
|
/// </summary>
|
|
/// <param name="source">The image this method extends.</param>
|
|
/// <param name="options">The options.</param>
|
|
/// <param name="brush">The brush.</param>
|
|
/// <param name="thickness">The thickness.</param>
|
|
/// <param name="paths">The shapes.</param>
|
|
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
|
|
public static IImageProcessingContext Draw(
|
|
this IImageProcessingContext source,
|
|
GraphicsOptions options,
|
|
IBrush brush,
|
|
float thickness,
|
|
IPathCollection paths) =>
|
|
source.Draw(options, new Pen(brush, thickness), paths);
|
|
|
|
/// <summary>
|
|
/// Draws the outline of the polygon with the provided brush at the provided thickness.
|
|
/// </summary>
|
|
/// <param name="source">The image this method extends.</param>
|
|
/// <param name="brush">The brush.</param>
|
|
/// <param name="thickness">The thickness.</param>
|
|
/// <param name="paths">The paths.</param>
|
|
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
|
|
public static IImageProcessingContext Draw(
|
|
this IImageProcessingContext source,
|
|
IBrush brush,
|
|
float thickness,
|
|
IPathCollection paths) =>
|
|
source.Draw(new Pen(brush, thickness), paths);
|
|
|
|
/// <summary>
|
|
/// Draws the outline of the polygon with the provided brush at the provided thickness.
|
|
/// </summary>
|
|
/// <param name="source">The image this method extends.</param>
|
|
/// <param name="options">The options.</param>
|
|
/// <param name="color">The color.</param>
|
|
/// <param name="thickness">The thickness.</param>
|
|
/// <param name="paths">The paths.</param>
|
|
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
|
|
public static IImageProcessingContext Draw(
|
|
this IImageProcessingContext source,
|
|
GraphicsOptions options,
|
|
Color color,
|
|
float thickness,
|
|
IPathCollection paths) =>
|
|
source.Draw(options, new SolidBrush(color), thickness, paths);
|
|
|
|
/// <summary>
|
|
/// Draws the outline of the polygon with the provided brush at the provided thickness.
|
|
/// </summary>
|
|
/// <param name="source">The image this method extends.</param>
|
|
/// <param name="color">The color.</param>
|
|
/// <param name="thickness">The thickness.</param>
|
|
/// <param name="paths">The paths.</param>
|
|
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
|
|
public static IImageProcessingContext Draw(
|
|
this IImageProcessingContext source,
|
|
Color color,
|
|
float thickness,
|
|
IPathCollection paths) =>
|
|
source.Draw(new SolidBrush(color), thickness, paths);
|
|
}
|
|
}
|