// 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.Primitives; using SixLabors.Shapes; namespace SixLabors.ImageSharp.Processing.Drawing { /// /// Adds extensions that allow the filling of closed linear polygons to the type. /// public static class FillPolygonExtensions { /// /// Flood fills the image in the shape of a Linear polygon described by the points /// /// The type of the color. /// The image this method extends. /// The brush. /// The points. /// The options. /// The . public static IImageProcessingContext FillPolygon(this IImageProcessingContext source, IBrush brush, PointF[] points, GraphicsOptions options) where TPixel : struct, IPixel => source.Fill(brush, new Polygon(new LinearLineSegment(points)), options); /// /// Flood fills the image in the shape of a Linear polygon described by the points /// /// The type of the color. /// The image this method extends. /// The brush. /// The points. /// The . public static IImageProcessingContext FillPolygon(this IImageProcessingContext source, IBrush brush, PointF[] points) where TPixel : struct, IPixel => source.Fill(brush, new Polygon(new LinearLineSegment(points))); /// /// Flood fills the image in the shape of a Linear polygon described by the points /// /// The type of the color. /// The image this method extends. /// The color. /// The points. /// The options. /// The . public static IImageProcessingContext FillPolygon(this IImageProcessingContext source, TPixel color, PointF[] points, GraphicsOptions options) where TPixel : struct, IPixel => source.Fill(new SolidBrush(color), new Polygon(new LinearLineSegment(points)), options); /// /// Flood fills the image in the shape of a Linear polygon described by the points /// /// The type of the color. /// The image this method extends. /// The color. /// The points. /// The . public static IImageProcessingContext FillPolygon(this IImageProcessingContext source, TPixel color, PointF[] points) where TPixel : struct, IPixel => source.Fill(new SolidBrush(color), new Polygon(new LinearLineSegment(points))); } }