// // Copyright (c) James Jackson-South and contributors. // Licensed under the Apache License, Version 2.0. // namespace ImageSharp.Drawing.Brushes { using System; /// /// A collection of methods for creating generic brushes. /// /// The pixel format. /// A Brush public class Brushes where TColor : struct, IPackedPixel, IEquatable { /// /// Percent10 Hatch Pattern /// /// note 2d arrays when configured using initalizer look inverted /// ---> Y axis /// ^ /// | X - axis /// | /// see PatternBrush for details about how to make new patterns work private static readonly bool[,] Percent10Pattern = { { true, false, false, false }, { false, false, false, false }, { false, false, true, false }, { false, false, false, false } }; /// /// Percent20 pattern. /// private static readonly bool[,] Percent20Pattern = { { true, false, true, false }, { false, false, false, false }, { false, true, false, true }, { false, false, false, false } }; /// /// Horizontal Hatch Pattern /// private static readonly bool[,] HorizontalPattern = { { false, true, false, false }, }; /// /// Min Pattern /// private static readonly bool[,] MinPattern = { { false, false, false, true }, }; /// /// Vertical Pattern /// private static readonly bool[,] VerticalPattern = { { false }, { true }, { false }, { false } }; /// /// Forward Diagonal Pattern /// private static readonly bool[,] ForwardDiagonalPattern = { { true, false, false, false }, { false, true, false, false }, { false, false, true, false }, { false, false, false, true } }; /// /// Backward Diagonal Pattern /// private static readonly bool[,] BackwardDiagonalPattern = { { false, false, false, true }, { false, false, true, false }, { false, true, false, false }, { true, false, false, false } }; /// /// Create as brush that will paint a solid color /// /// The color. /// A Brush public static SolidBrush Solid(TColor color) => new SolidBrush(color); /// /// Create as brush that will paint a Percent10 Hatch Pattern within the specified colors /// /// Color of the foreground. /// Color of the background. /// A Brush public static PatternBrush Percent10(TColor foreColor, TColor backColor) => new PatternBrush(foreColor, backColor, Percent10Pattern); /// /// Create as brush that will paint a Percent20 Hatch Pattern within the specified colors /// /// Color of the foreground. /// Color of the background. /// A Brush public static PatternBrush Percent20(TColor foreColor, TColor backColor) => new PatternBrush(foreColor, backColor, Percent20Pattern); /// /// Create as brush that will paint a Horizontal Hatch Pattern within the specified colors /// /// Color of the foreground. /// Color of the background. /// A Brush public static PatternBrush Horizontal(TColor foreColor, TColor backColor) => new PatternBrush(foreColor, backColor, HorizontalPattern); /// /// Create as brush that will paint a Min Hatch Pattern within the specified colors /// /// Color of the foreground. /// Color of the background. /// A Brush public static PatternBrush Min(TColor foreColor, TColor backColor) => new PatternBrush(foreColor, backColor, MinPattern); /// /// Create as brush that will paint a Vertical Hatch Pattern within the specified colors /// /// Color of the foreground. /// Color of the background. /// A Brush public static PatternBrush Vertical(TColor foreColor, TColor backColor) => new PatternBrush(foreColor, backColor, VerticalPattern); /// /// Create as brush that will paint a Forward Diagonal Hatch Pattern within the specified colors /// /// Color of the foreground. /// Color of the background. /// A Brush public static PatternBrush ForwardDiagonal(TColor foreColor, TColor backColor) => new PatternBrush(foreColor, backColor, ForwardDiagonalPattern); /// /// Create as brush that will paint a Backward Diagonal Hatch Pattern within the specified colors /// /// Color of the foreground. /// Color of the background. /// A Brush public static PatternBrush BackwardDiagonal(TColor foreColor, TColor backColor) => new PatternBrush(foreColor, backColor, BackwardDiagonalPattern); } }