// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using SixLabors.ImageSharp.PixelFormats; using SixLabors.Primitives; using SixLabors.Shapes; namespace SixLabors.ImageSharp.Processing { /// /// 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 options. /// The brush. /// The thickness. /// The points. /// The . public static IImageProcessingContext DrawBeziers(this IImageProcessingContext source, GraphicsOptions options, IBrush brush, float thickness, params PointF[] points) where TPixel : struct, IPixel => source.Draw(options, 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 brush. /// The thickness. /// The points. /// The . public static IImageProcessingContext DrawBeziers(this IImageProcessingContext source, IBrush brush, float thickness, params 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, params 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 options. /// The color. /// The thickness. /// The points. /// The . public static IImageProcessingContext DrawBeziers(this IImageProcessingContext source, GraphicsOptions options, TPixel color, float thickness, params PointF[] points) where TPixel : struct, IPixel => source.DrawBeziers(options, new SolidBrush(color), thickness, points); /// /// Draws the provided points as an open Bezier path with the supplied pen /// /// The type of the color. /// The image this method extends. /// The options. /// The pen. /// The points. /// The . public static IImageProcessingContext DrawBeziers(this IImageProcessingContext source, GraphicsOptions options, IPen pen, params PointF[] points) where TPixel : struct, IPixel => source.Draw(options, pen, new Path(new CubicBezierLineSegment(points))); /// /// 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, params PointF[] points) where TPixel : struct, IPixel => source.Draw(pen, new Path(new CubicBezierLineSegment(points))); } }