// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using SixLabors.Fonts;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing.Processors.Text;
using SixLabors.Primitives;
namespace SixLabors.ImageSharp.Processing
{
///
/// Adds extensions that allow the drawing of text to the type.
///
public static class DrawTextExtensions
{
///
/// Draws the text onto the the image filled via the brush.
///
/// The type of the color.
/// The image this method extends.
/// The text.
/// The font.
/// The color.
/// The location.
///
/// The .
///
public static IImageProcessingContext DrawText(this IImageProcessingContext source, string text, Font font, TPixel color, PointF location)
where TPixel : struct, IPixel
=> source.DrawText(TextGraphicsOptions.Default, text, font, color, location);
///
/// Draws the text onto the the image filled via the brush.
///
/// The type of the color.
/// The image this method extends.
/// The options.
/// The text.
/// The font.
/// The color.
/// The location.
///
/// The .
///
public static IImageProcessingContext DrawText(this IImageProcessingContext source, TextGraphicsOptions options, string text, Font font, TPixel color, PointF location)
where TPixel : struct, IPixel
=> source.DrawText(options, text, font, Brushes.Solid(color), null, location);
///
/// Draws the text onto the the image filled via the brush.
///
/// The type of the color.
/// The image this method extends.
/// The text.
/// The font.
/// The brush.
/// The location.
///
/// The .
///
public static IImageProcessingContext DrawText(this IImageProcessingContext source, string text, Font font, IBrush brush, PointF location)
where TPixel : struct, IPixel
=> source.DrawText(TextGraphicsOptions.Default, text, font, brush, location);
///
/// Draws the text onto the the image filled via the brush.
///
/// The type of the color.
/// The image this method extends.
/// The options.
/// The text.
/// The font.
/// The brush.
/// The location.
///
/// The .
///
public static IImageProcessingContext DrawText(this IImageProcessingContext source, TextGraphicsOptions options, string text, Font font, IBrush brush, PointF location)
where TPixel : struct, IPixel
=> source.DrawText(options, text, font, brush, null, location);
///
/// Draws the text onto the the image outlined via the pen.
///
/// The type of the color.
/// The image this method extends.
/// The text.
/// The font.
/// The pen.
/// The location.
///
/// The .
///
public static IImageProcessingContext DrawText(this IImageProcessingContext source, string text, Font font, IPen pen, PointF location)
where TPixel : struct, IPixel
=> source.DrawText(TextGraphicsOptions.Default, text, font, pen, location);
///
/// Draws the text onto the the image outlined via the pen.
///
/// The type of the color.
/// The image this method extends.
/// The options.
/// The text.
/// The font.
/// The pen.
/// The location.
///
/// The .
///
public static IImageProcessingContext DrawText(this IImageProcessingContext source, TextGraphicsOptions options, string text, Font font, IPen pen, PointF location)
where TPixel : struct, IPixel
=> source.DrawText(options, text, font, null, pen, location);
///
/// Draws the text onto the the image filled via the brush then outlined via the pen.
///
/// The type of the color.
/// The image this method extends.
/// The text.
/// The font.
/// The brush.
/// The pen.
/// The location.
///
/// The .
///
public static IImageProcessingContext DrawText(this IImageProcessingContext source, string text, Font font, IBrush brush, IPen pen, PointF location)
where TPixel : struct, IPixel
=> source.DrawText(TextGraphicsOptions.Default, text, font, brush, pen, location);
///
/// Draws the text using the default resolution of 72dpi onto the the image filled via the brush then outlined via the pen.
///
/// The type of the color.
/// The image this method extends.
/// The options.
/// The text.
/// The font.
/// The brush.
/// The pen.
/// The location.
///
/// The .
///
public static IImageProcessingContext DrawText(this IImageProcessingContext source, TextGraphicsOptions options, string text, Font font, IBrush brush, IPen pen, PointF location)
where TPixel : struct, IPixel
=> source.ApplyProcessor(new DrawTextProcessor(options, text, font, brush, pen, location));
}
}