// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
namespace SixLabors.ImageSharp.Processing
{
///
/// A collection of methods for creating generic brushes.
///
/// A New
public static class Brushes
{
///
/// Percent10 Hatch Pattern
///
/// ---> x axis
/// ^
/// | y - 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, false, false },
{ false, false, true, false },
{ true, false, false, false },
{ false, false, true, 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 =
{
{ false, false, false, true },
{ false, false, true, false },
{ false, true, false, false },
{ true, false, false, false }
};
///
/// Backward Diagonal Pattern
///
private static readonly bool[,] BackwardDiagonalPattern =
{
{ true, false, false, false },
{ false, true, false, false },
{ false, false, true, false },
{ false, false, false, true }
};
///
/// Create as brush that will paint a solid color
///
/// The color.
/// The pixel format.
/// A New
public static SolidBrush Solid(TPixel color)
where TPixel : struct, IPixel
=> new SolidBrush(color);
///
/// Create as brush that will paint a Percent10 Hatch Pattern with the specified colors
///
/// Color of the foreground.
/// The pixel format.
/// A New
public static PatternBrush Percent10(TPixel foreColor)
where TPixel : struct, IPixel
=> new PatternBrush(foreColor, NamedColors.Transparent, Percent10Pattern);
///
/// Create as brush that will paint a Percent10 Hatch Pattern with the specified colors
///
/// Color of the foreground.
/// Color of the background.
/// The pixel format.
/// A New
public static PatternBrush Percent10(TPixel foreColor, TPixel backColor)
where TPixel : struct, IPixel
=> new PatternBrush(foreColor, backColor, Percent10Pattern);
///
/// Create as brush that will paint a Percent20 Hatch Pattern with the specified foreground color and a
/// transparent background.
///
/// Color of the foreground.
/// The pixel format.
/// A New
public static PatternBrush Percent20(TPixel foreColor)
where TPixel : struct, IPixel
=> new PatternBrush(foreColor, NamedColors.Transparent, Percent20Pattern);
///
/// Create as brush that will paint a Percent20 Hatch Pattern with the specified colors
///
/// Color of the foreground.
/// Color of the background.
/// The pixel format.
/// A New
public static PatternBrush Percent20(TPixel foreColor, TPixel backColor)
where TPixel : struct, IPixel
=> new PatternBrush(foreColor, backColor, Percent20Pattern);
///
/// Create as brush that will paint a Horizontal Hatch Pattern with the specified foreground color and a
/// transparent background.
///
/// Color of the foreground.
/// The pixel format.
/// A New
public static PatternBrush Horizontal(TPixel foreColor)
where TPixel : struct, IPixel
=> new PatternBrush(foreColor, NamedColors.Transparent, HorizontalPattern);
///
/// Create as brush that will paint a Horizontal Hatch Pattern with the specified colors
///
/// Color of the foreground.
/// Color of the background.
/// The pixel format.
/// A New
public static PatternBrush Horizontal(TPixel foreColor, TPixel backColor)
where TPixel : struct, IPixel
=> new PatternBrush(foreColor, backColor, HorizontalPattern);
///
/// Create as brush that will paint a Min Hatch Pattern with the specified foreground color and a
/// transparent background.
///
/// Color of the foreground.
/// The pixel format.
/// A New
public static PatternBrush Min(TPixel foreColor)
where TPixel : struct, IPixel
=> new PatternBrush(foreColor, NamedColors.Transparent, MinPattern);
///
/// Create as brush that will paint a Min Hatch Pattern with the specified colors
///
/// Color of the foreground.
/// Color of the background.
/// The pixel format.
/// A New
public static PatternBrush Min(TPixel foreColor, TPixel backColor)
where TPixel : struct, IPixel
=> new PatternBrush(foreColor, backColor, MinPattern);
///
/// Create as brush that will paint a Vertical Hatch Pattern with the specified foreground color and a
/// transparent background.
///
/// Color of the foreground.
/// The pixel format.
/// A New
public static PatternBrush Vertical(TPixel foreColor)
where TPixel : struct, IPixel
=> new PatternBrush(foreColor, NamedColors.Transparent, VerticalPattern);
///
/// Create as brush that will paint a Vertical Hatch Pattern with the specified colors
///
/// Color of the foreground.
/// Color of the background.
/// The pixel format.
/// A New
public static PatternBrush Vertical(TPixel foreColor, TPixel backColor)
where TPixel : struct, IPixel
=> new PatternBrush(foreColor, backColor, VerticalPattern);
///
/// Create as brush that will paint a Forward Diagonal Hatch Pattern with the specified foreground color and a
/// transparent background.
///
/// Color of the foreground.
/// The pixel format.
/// A New
public static PatternBrush ForwardDiagonal(TPixel foreColor)
where TPixel : struct, IPixel
=> new PatternBrush(foreColor, NamedColors.Transparent, ForwardDiagonalPattern);
///
/// Create as brush that will paint a Forward Diagonal Hatch Pattern with the specified colors
///
/// Color of the foreground.
/// Color of the background.
/// The pixel format.
/// A New
public static PatternBrush ForwardDiagonal(TPixel foreColor, TPixel backColor)
where TPixel : struct, IPixel
=> new PatternBrush(foreColor, backColor, ForwardDiagonalPattern);
///
/// Create as brush that will paint a Backward Diagonal Hatch Pattern with the specified foreground color and a
/// transparent background.
///
/// Color of the foreground.
/// The pixel format.
/// A New
public static PatternBrush BackwardDiagonal(TPixel foreColor)
where TPixel : struct, IPixel
=> new PatternBrush(foreColor, NamedColors.Transparent, BackwardDiagonalPattern);
///
/// Create as brush that will paint a Backward Diagonal Hatch Pattern with the specified colors
///
/// Color of the foreground.
/// Color of the background.
/// The pixel format.
/// A New
public static PatternBrush BackwardDiagonal(TPixel foreColor, TPixel backColor)
where TPixel : struct, IPixel
=> new PatternBrush(foreColor, backColor, BackwardDiagonalPattern);
}
}