// // Copyright (c) James Jackson-South and contributors. // Licensed under the Apache License, Version 2.0. // namespace ImageSharp { using System; using System.Numerics; using Drawing; using Drawing.Brushes; using Drawing.Paths; using Drawing.Processors; using Drawing.Shapes; /// /// Extension methods for the type. /// public static partial class ImageExtensions { /// /// Flood fills the image with the specified brush. /// /// The type of the color. /// The source. /// The brush. /// The Image public static Image Fill(this Image source, IBrush brush) where TColor : struct, IPackedPixel, IEquatable { return source.Apply(new FillProcessor(brush)); } /// /// Flood fills the image with the specified color. /// /// The type of the color. /// The source. /// The color. /// The Image public static Image Fill(this Image source, TColor color) where TColor : struct, IPackedPixel, IEquatable { return source.Fill(new SolidBrush(color)); } /// /// Flood fills the image in the shape o fhte provided polygon with the specified brush.. /// /// The type of the color. /// The source. /// The brush. /// The shape. /// The graphics options. /// The Image public static Image Fill(this Image source, IBrush brush, IShape shape, GraphicsOptions options) where TColor : struct, IPackedPixel, IEquatable { return source.Apply(new FillShapeProcessor(brush, shape, options)); } /// /// Flood fills the image in the shape of the provided polygon with the specified brush. /// /// The type of the color. /// The source. /// The brush. /// The shape. /// The Image public static Image Fill(this Image source, IBrush brush, IShape shape) where TColor : struct, IPackedPixel, IEquatable { return source.Apply(new FillShapeProcessor(brush, shape, GraphicsOptions.Default)); } /// /// Flood fills the image in the shape o fhte provided polygon with the specified brush.. /// /// The type of the color. /// The source. /// The color. /// The shape. /// The options. /// /// The Image /// public static Image Fill(this Image source, TColor color, IShape shape, GraphicsOptions options) where TColor : struct, IPackedPixel, IEquatable { return source.Fill(new SolidBrush(color), shape, options); } /// /// Flood fills the image in the shape o fhte provided polygon with the specified brush.. /// /// The type of the color. /// The source. /// The color. /// The shape. /// The Image public static Image Fill(this Image source, TColor color, IShape shape) where TColor : struct, IPackedPixel, IEquatable { return source.Fill(new SolidBrush(color), shape); } /// /// Flood fills the image in the shape of a Linear polygon described by the points /// /// The type of the color. /// The source. /// The brush. /// The points. /// The options. /// /// The Image /// public static Image FillPolygon(this Image source, IBrush brush, Vector2[] points, GraphicsOptions options) where TColor : struct, IPackedPixel, IEquatable { // using Polygon directly instead of LinearPolygon as its will have less indirection return 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 source. /// The brush. /// The points. /// The Image public static Image FillPolygon(this Image source, IBrush brush, Vector2[] points) where TColor : struct, IPackedPixel, IEquatable { // using Polygon directly instead of LinearPolygon as its will have less indirection return 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 source. /// The color. /// The points. /// The options. /// /// The Image /// public static Image FillPolygon(this Image source, TColor color, Vector2[] points, GraphicsOptions options) where TColor : struct, IPackedPixel, IEquatable { // using Polygon directly instead of LinearPolygon as its will have less indirection return 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 source. /// The color. /// The points. /// The Image public static Image FillPolygon(this Image source, TColor color, Vector2[] points) where TColor : struct, IPackedPixel, IEquatable { // using Polygon directly instead of LinearPolygon as its will have less indirection return source.Fill(new SolidBrush(color), new Polygon(new LinearLineSegment(points))); } } }