// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing.Drawing.Brushes; using SixLabors.ImageSharp.Processing.Drawing.Pens; using SixLabors.Primitives; using SixLabors.Shapes; namespace SixLabors.ImageSharp.Processing.Drawing { /// /// Adds extensions that allow the drawing of Bezier paths to the type. /// public static class DrawBezierExtensions { /// /// Draws the provided points as an open Bezier path at the provided thickness with the supplied brush /// /// The type of the color. /// The image this method extends. /// The brush. /// The thickness. /// The points. /// The options. /// The . public static IImageProcessingContext DrawBeziers(this IImageProcessingContext source, IBrush brush, float thickness, PointF[] points, GraphicsOptions options) where TPixel : struct, IPixel => source.Draw(new Pen(brush, thickness), new Path(new CubicBezierLineSegment(points)), options); /// /// Draws the provided points as an open Bezier path at the provided thickness with the supplied brush /// /// The type of the color. /// The image this method extends. /// The brush. /// The thickness. /// The points. /// The . public static IImageProcessingContext DrawBeziers(this IImageProcessingContext source, IBrush brush, float thickness, PointF[] points) where TPixel : struct, IPixel => source.Draw(new Pen(brush, thickness), new Path(new CubicBezierLineSegment(points))); /// /// Draws the provided points as an open Bezier path at the provided thickness with the supplied brush /// /// The type of the color. /// The image this method extends. /// The color. /// The thickness. /// The points. /// The . public static IImageProcessingContext DrawBeziers(this IImageProcessingContext source, TPixel color, float thickness, PointF[] points) where TPixel : struct, IPixel => source.DrawBeziers(new SolidBrush(color), thickness, points); /// /// Draws the provided points as an open Bezier path at the provided thickness with the supplied brush /// /// The type of the color. /// The image this method extends. /// The color. /// The thickness. /// The points. /// The options. /// The . public static IImageProcessingContext DrawBeziers(this IImageProcessingContext source, TPixel color, float thickness, PointF[] points, GraphicsOptions options) where TPixel : struct, IPixel => source.DrawBeziers(new SolidBrush(color), thickness, points, options); /// /// Draws the provided points as an open Bezier path with the supplied pen /// /// The type of the color. /// The image this method extends. /// The pen. /// The points. /// The options. /// The . public static IImageProcessingContext DrawBeziers(this IImageProcessingContext source, IPen pen, PointF[] points, GraphicsOptions options) where TPixel : struct, IPixel => source.Draw(pen, new Path(new CubicBezierLineSegment(points)), options); /// /// Draws the provided points as an open Bezier path with the supplied pen /// /// The type of the color. /// The image this method extends. /// The pen. /// The points. /// The . public static IImageProcessingContext DrawBeziers(this IImageProcessingContext source, IPen pen, PointF[] points) where TPixel : struct, IPixel => source.Draw(pen, new Path(new CubicBezierLineSegment(points))); } }