Browse Source

Brush & Pen instead of Brush<T> & Pen<T>

af/merge-core
Scott Williams 9 years ago
parent
commit
65ecb53b6b
  1. 66
      src/ImageSharp.Drawing/Brushes/Brushes.cs
  2. 46
      src/ImageSharp.Drawing/Pens/Pens.cs
  3. 2
      src/ImageSharp.Drawing/Text/DrawText.cs
  4. 3
      tests/ImageSharp.Benchmarks/Drawing/FillWithPattern.cs
  5. 28
      tests/ImageSharp.Tests/Drawing/FillPatternTests.cs
  6. 2
      tests/ImageSharp.Tests/Drawing/LineComplexPolygonTests.cs
  7. 8
      tests/ImageSharp.Tests/Drawing/LineTests.cs
  8. 2
      tests/ImageSharp.Tests/Drawing/Paths/DrawBeziersTests.cs
  9. 2
      tests/ImageSharp.Tests/Drawing/Paths/DrawLinesTests.cs
  10. 2
      tests/ImageSharp.Tests/Drawing/Paths/DrawPath.cs
  11. 2
      tests/ImageSharp.Tests/Drawing/Paths/DrawPolygon.cs
  12. 2
      tests/ImageSharp.Tests/Drawing/Paths/DrawRectangle.cs
  13. 2
      tests/ImageSharp.Tests/Drawing/Paths/FillPath.cs
  14. 2
      tests/ImageSharp.Tests/Drawing/Paths/FillPolygon.cs
  15. 2
      tests/ImageSharp.Tests/Drawing/Paths/FillRectangle.cs
  16. 2
      tests/ImageSharp.Tests/Drawing/SolidPolygonTests.cs
  17. 34
      tests/ImageSharp.Tests/Drawing/Text/DrawText.cs

66
src/ImageSharp.Drawing/Brushes/Brushes{TPixel}.cs → src/ImageSharp.Drawing/Brushes/Brushes.cs

@ -1,4 +1,4 @@
// <copyright file="Brushes{TPixel}.cs" company="James Jackson-South">
// <copyright file="Brushes.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
@ -10,10 +10,8 @@ namespace ImageSharp.Drawing.Brushes
/// <summary>
/// A collection of methods for creating generic brushes.
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>A New <see cref="PatternBrush{TPixel}"/></returns>
public class Brushes<TPixel>
where TPixel : struct, IPixel<TPixel>
public static class Brushes
{
/// <summary>
/// Percent10 Hatch Pattern
@ -98,16 +96,20 @@ namespace ImageSharp.Drawing.Brushes
/// Create as brush that will paint a solid color
/// </summary>
/// <param name="color">The color.</param>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>A New <see cref="PatternBrush{TPixel}"/></returns>
public static SolidBrush<TPixel> Solid(TPixel color)
public static SolidBrush<TPixel> Solid<TPixel>(TPixel color)
where TPixel : struct, IPixel<TPixel>
=> new SolidBrush<TPixel>(color);
/// <summary>
/// Create as brush that will paint a Percent10 Hatch Pattern with the specified colors
/// </summary>
/// <param name="foreColor">Color of the foreground.</param>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>A New <see cref="PatternBrush{TPixel}"/></returns>
public static PatternBrush<TPixel> Percent10(TPixel foreColor)
public static PatternBrush<TPixel> Percent10<TPixel>(TPixel foreColor)
where TPixel : struct, IPixel<TPixel>
=> new PatternBrush<TPixel>(foreColor, NamedColors<TPixel>.Transparent, Percent10Pattern);
/// <summary>
@ -115,8 +117,10 @@ namespace ImageSharp.Drawing.Brushes
/// </summary>
/// <param name="foreColor">Color of the foreground.</param>
/// <param name="backColor">Color of the background.</param>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>A New <see cref="PatternBrush{TPixel}"/></returns>
public static PatternBrush<TPixel> Percent10(TPixel foreColor, TPixel backColor)
public static PatternBrush<TPixel> Percent10<TPixel>(TPixel foreColor, TPixel backColor)
where TPixel : struct, IPixel<TPixel>
=> new PatternBrush<TPixel>(foreColor, backColor, Percent10Pattern);
/// <summary>
@ -124,8 +128,10 @@ namespace ImageSharp.Drawing.Brushes
/// transparent background.
/// </summary>
/// <param name="foreColor">Color of the foreground.</param>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>A New <see cref="PatternBrush{TPixel}"/></returns>
public static PatternBrush<TPixel> Percent20(TPixel foreColor)
public static PatternBrush<TPixel> Percent20<TPixel>(TPixel foreColor)
where TPixel : struct, IPixel<TPixel>
=> new PatternBrush<TPixel>(foreColor, NamedColors<TPixel>.Transparent, Percent20Pattern);
/// <summary>
@ -133,8 +139,10 @@ namespace ImageSharp.Drawing.Brushes
/// </summary>
/// <param name="foreColor">Color of the foreground.</param>
/// <param name="backColor">Color of the background.</param>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>A New <see cref="PatternBrush{TPixel}"/></returns>
public static PatternBrush<TPixel> Percent20(TPixel foreColor, TPixel backColor)
public static PatternBrush<TPixel> Percent20<TPixel>(TPixel foreColor, TPixel backColor)
where TPixel : struct, IPixel<TPixel>
=> new PatternBrush<TPixel>(foreColor, backColor, Percent20Pattern);
/// <summary>
@ -142,8 +150,10 @@ namespace ImageSharp.Drawing.Brushes
/// transparent background.
/// </summary>
/// <param name="foreColor">Color of the foreground.</param>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>A New <see cref="PatternBrush{TPixel}"/></returns>
public static PatternBrush<TPixel> Horizontal(TPixel foreColor)
public static PatternBrush<TPixel> Horizontal<TPixel>(TPixel foreColor)
where TPixel : struct, IPixel<TPixel>
=> new PatternBrush<TPixel>(foreColor, NamedColors<TPixel>.Transparent, HorizontalPattern);
/// <summary>
@ -151,8 +161,10 @@ namespace ImageSharp.Drawing.Brushes
/// </summary>
/// <param name="foreColor">Color of the foreground.</param>
/// <param name="backColor">Color of the background.</param>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>A New <see cref="PatternBrush{TPixel}"/></returns>
public static PatternBrush<TPixel> Horizontal(TPixel foreColor, TPixel backColor)
public static PatternBrush<TPixel> Horizontal<TPixel>(TPixel foreColor, TPixel backColor)
where TPixel : struct, IPixel<TPixel>
=> new PatternBrush<TPixel>(foreColor, backColor, HorizontalPattern);
/// <summary>
@ -160,8 +172,10 @@ namespace ImageSharp.Drawing.Brushes
/// transparent background.
/// </summary>
/// <param name="foreColor">Color of the foreground.</param>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>A New <see cref="PatternBrush{TPixel}"/></returns>
public static PatternBrush<TPixel> Min(TPixel foreColor)
public static PatternBrush<TPixel> Min<TPixel>(TPixel foreColor)
where TPixel : struct, IPixel<TPixel>
=> new PatternBrush<TPixel>(foreColor, NamedColors<TPixel>.Transparent, MinPattern);
/// <summary>
@ -169,8 +183,10 @@ namespace ImageSharp.Drawing.Brushes
/// </summary>
/// <param name="foreColor">Color of the foreground.</param>
/// <param name="backColor">Color of the background.</param>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>A New <see cref="PatternBrush{TPixel}"/></returns>
public static PatternBrush<TPixel> Min(TPixel foreColor, TPixel backColor)
public static PatternBrush<TPixel> Min<TPixel>(TPixel foreColor, TPixel backColor)
where TPixel : struct, IPixel<TPixel>
=> new PatternBrush<TPixel>(foreColor, backColor, MinPattern);
/// <summary>
@ -178,8 +194,10 @@ namespace ImageSharp.Drawing.Brushes
/// transparent background.
/// </summary>
/// <param name="foreColor">Color of the foreground.</param>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>A New <see cref="PatternBrush{TPixel}"/></returns>
public static PatternBrush<TPixel> Vertical(TPixel foreColor)
public static PatternBrush<TPixel> Vertical<TPixel>(TPixel foreColor)
where TPixel : struct, IPixel<TPixel>
=> new PatternBrush<TPixel>(foreColor, NamedColors<TPixel>.Transparent, VerticalPattern);
/// <summary>
@ -187,8 +205,10 @@ namespace ImageSharp.Drawing.Brushes
/// </summary>
/// <param name="foreColor">Color of the foreground.</param>
/// <param name="backColor">Color of the background.</param>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>A New <see cref="PatternBrush{TPixel}"/></returns>
public static PatternBrush<TPixel> Vertical(TPixel foreColor, TPixel backColor)
public static PatternBrush<TPixel> Vertical<TPixel>(TPixel foreColor, TPixel backColor)
where TPixel : struct, IPixel<TPixel>
=> new PatternBrush<TPixel>(foreColor, backColor, VerticalPattern);
/// <summary>
@ -196,8 +216,10 @@ namespace ImageSharp.Drawing.Brushes
/// transparent background.
/// </summary>
/// <param name="foreColor">Color of the foreground.</param>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>A New <see cref="PatternBrush{TPixel}"/></returns>
public static PatternBrush<TPixel> ForwardDiagonal(TPixel foreColor)
public static PatternBrush<TPixel> ForwardDiagonal<TPixel>(TPixel foreColor)
where TPixel : struct, IPixel<TPixel>
=> new PatternBrush<TPixel>(foreColor, NamedColors<TPixel>.Transparent, ForwardDiagonalPattern);
/// <summary>
@ -205,8 +227,10 @@ namespace ImageSharp.Drawing.Brushes
/// </summary>
/// <param name="foreColor">Color of the foreground.</param>
/// <param name="backColor">Color of the background.</param>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>A New <see cref="PatternBrush{TPixel}"/></returns>
public static PatternBrush<TPixel> ForwardDiagonal(TPixel foreColor, TPixel backColor)
public static PatternBrush<TPixel> ForwardDiagonal<TPixel>(TPixel foreColor, TPixel backColor)
where TPixel : struct, IPixel<TPixel>
=> new PatternBrush<TPixel>(foreColor, backColor, ForwardDiagonalPattern);
/// <summary>
@ -214,8 +238,10 @@ namespace ImageSharp.Drawing.Brushes
/// transparent background.
/// </summary>
/// <param name="foreColor">Color of the foreground.</param>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>A New <see cref="PatternBrush{TPixel}"/></returns>
public static PatternBrush<TPixel> BackwardDiagonal(TPixel foreColor)
public static PatternBrush<TPixel> BackwardDiagonal<TPixel>(TPixel foreColor)
where TPixel : struct, IPixel<TPixel>
=> new PatternBrush<TPixel>(foreColor, NamedColors<TPixel>.Transparent, BackwardDiagonalPattern);
/// <summary>
@ -223,8 +249,10 @@ namespace ImageSharp.Drawing.Brushes
/// </summary>
/// <param name="foreColor">Color of the foreground.</param>
/// <param name="backColor">Color of the background.</param>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>A New <see cref="PatternBrush{TPixel}"/></returns>
public static PatternBrush<TPixel> BackwardDiagonal(TPixel foreColor, TPixel backColor)
public static PatternBrush<TPixel> BackwardDiagonal<TPixel>(TPixel foreColor, TPixel backColor)
where TPixel : struct, IPixel<TPixel>
=> new PatternBrush<TPixel>(foreColor, backColor, BackwardDiagonalPattern);
}
}

46
src/ImageSharp.Drawing/Pens/Pens{TPixel}.cs → src/ImageSharp.Drawing/Pens/Pens.cs

@ -1,4 +1,4 @@
// <copyright file="Pens{TPixel}.cs" company="James Jackson-South">
// <copyright file="Pens.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
@ -10,9 +10,7 @@ namespace ImageSharp.Drawing.Pens
/// <summary>
/// Common Pen styles
/// </summary>
/// <typeparam name="TPixel">The type of the color.</typeparam>
public class Pens<TPixel>
where TPixel : struct, IPixel<TPixel>
public static class Pens
{
private static readonly float[] DashDotPattern = new[] { 3f, 1f, 1f, 1f };
private static readonly float[] DashDotDotPattern = new[] { 3f, 1f, 1f, 1f, 1f, 1f };
@ -24,8 +22,10 @@ namespace ImageSharp.Drawing.Pens
/// </summary>
/// <param name="color">The color.</param>
/// <param name="width">The width.</param>
/// <typeparam name="TPixel">The type of the color.</typeparam>
/// <returns>The Pen</returns>
public static Pen<TPixel> Solid(TPixel color, float width)
public static Pen<TPixel> Solid<TPixel>(TPixel color, float width)
where TPixel : struct, IPixel<TPixel>
=> new Pen<TPixel>(color, width);
/// <summary>
@ -33,8 +33,10 @@ namespace ImageSharp.Drawing.Pens
/// </summary>
/// <param name="brush">The brush.</param>
/// <param name="width">The width.</param>
/// <typeparam name="TPixel">The type of the color.</typeparam>
/// <returns>The Pen</returns>
public static Pen<TPixel> Solid(IBrush<TPixel> brush, float width)
public static Pen<TPixel> Solid<TPixel>(IBrush<TPixel> brush, float width)
where TPixel : struct, IPixel<TPixel>
=> new Pen<TPixel>(brush, width);
/// <summary>
@ -42,8 +44,10 @@ namespace ImageSharp.Drawing.Pens
/// </summary>
/// <param name="color">The color.</param>
/// <param name="width">The width.</param>
/// <typeparam name="TPixel">The type of the color.</typeparam>
/// <returns>The Pen</returns>
public static Pen<TPixel> Dash(TPixel color, float width)
public static Pen<TPixel> Dash<TPixel>(TPixel color, float width)
where TPixel : struct, IPixel<TPixel>
=> new Pen<TPixel>(color, width, DashedPattern);
/// <summary>
@ -51,8 +55,10 @@ namespace ImageSharp.Drawing.Pens
/// </summary>
/// <param name="brush">The brush.</param>
/// <param name="width">The width.</param>
/// <typeparam name="TPixel">The type of the color.</typeparam>
/// <returns>The Pen</returns>
public static Pen<TPixel> Dash(IBrush<TPixel> brush, float width)
public static Pen<TPixel> Dash<TPixel>(IBrush<TPixel> brush, float width)
where TPixel : struct, IPixel<TPixel>
=> new Pen<TPixel>(brush, width, DashedPattern);
/// <summary>
@ -60,8 +66,10 @@ namespace ImageSharp.Drawing.Pens
/// </summary>
/// <param name="color">The color.</param>
/// <param name="width">The width.</param>
/// <typeparam name="TPixel">The type of the color.</typeparam>
/// <returns>The Pen</returns>
public static Pen<TPixel> Dot(TPixel color, float width)
public static Pen<TPixel> Dot<TPixel>(TPixel color, float width)
where TPixel : struct, IPixel<TPixel>
=> new Pen<TPixel>(color, width, DottedPattern);
/// <summary>
@ -69,8 +77,10 @@ namespace ImageSharp.Drawing.Pens
/// </summary>
/// <param name="brush">The brush.</param>
/// <param name="width">The width.</param>
/// <typeparam name="TPixel">The type of the color.</typeparam>
/// <returns>The Pen</returns>
public static Pen<TPixel> Dot(IBrush<TPixel> brush, float width)
public static Pen<TPixel> Dot<TPixel>(IBrush<TPixel> brush, float width)
where TPixel : struct, IPixel<TPixel>
=> new Pen<TPixel>(brush, width, DottedPattern);
/// <summary>
@ -78,8 +88,10 @@ namespace ImageSharp.Drawing.Pens
/// </summary>
/// <param name="color">The color.</param>
/// <param name="width">The width.</param>
/// <typeparam name="TPixel">The type of the color.</typeparam>
/// <returns>The Pen</returns>
public static Pen<TPixel> DashDot(TPixel color, float width)
public static Pen<TPixel> DashDot<TPixel>(TPixel color, float width)
where TPixel : struct, IPixel<TPixel>
=> new Pen<TPixel>(color, width, DashDotPattern);
/// <summary>
@ -87,8 +99,10 @@ namespace ImageSharp.Drawing.Pens
/// </summary>
/// <param name="brush">The brush.</param>
/// <param name="width">The width.</param>
/// <typeparam name="TPixel">The type of the color.</typeparam>
/// <returns>The Pen</returns>
public static Pen<TPixel> DashDot(IBrush<TPixel> brush, float width)
public static Pen<TPixel> DashDot<TPixel>(IBrush<TPixel> brush, float width)
where TPixel : struct, IPixel<TPixel>
=> new Pen<TPixel>(brush, width, DashDotPattern);
/// <summary>
@ -96,8 +110,10 @@ namespace ImageSharp.Drawing.Pens
/// </summary>
/// <param name="color">The color.</param>
/// <param name="width">The width.</param>
/// <typeparam name="TPixel">The type of the color.</typeparam>
/// <returns>The Pen</returns>
public static Pen<TPixel> DashDotDot(TPixel color, float width)
public static Pen<TPixel> DashDotDot<TPixel>(TPixel color, float width)
where TPixel : struct, IPixel<TPixel>
=> new Pen<TPixel>(color, width, DashDotDotPattern);
/// <summary>
@ -105,8 +121,10 @@ namespace ImageSharp.Drawing.Pens
/// </summary>
/// <param name="brush">The brush.</param>
/// <param name="width">The width.</param>
/// <typeparam name="TPixel">The type of the color.</typeparam>
/// <returns>The Pen</returns>
public static Pen<TPixel> DashDotDot(IBrush<TPixel> brush, float width)
public static Pen<TPixel> DashDotDot<TPixel>(IBrush<TPixel> brush, float width)
where TPixel : struct, IPixel<TPixel>
=> new Pen<TPixel>(brush, width, DashDotDotPattern);
}
}

2
src/ImageSharp.Drawing/Text/DrawText.cs

@ -54,7 +54,7 @@ namespace ImageSharp
public static Image<TPixel> DrawText<TPixel>(this Image<TPixel> source, string text, Font font, TPixel color, Vector2 location, TextGraphicsOptions options)
where TPixel : struct, IPixel<TPixel>
{
return source.DrawText(text, font, Brushes<TPixel>.Solid(color), null, location, options);
return source.DrawText(text, font, Brushes.Solid(color), null, location, options);
}
/// <summary>

3
tests/ImageSharp.Benchmarks/Drawing/FillWithPattern.cs

@ -12,6 +12,7 @@ namespace ImageSharp.Benchmarks
using BenchmarkDotNet.Attributes;
using ImageSharp.Drawing.Brushes;
using CoreBrushes = ImageSharp.Drawing.Brushes.Brushes;
using ImageSharp.PixelFormats;
public class FillWithPattern
@ -39,7 +40,7 @@ namespace ImageSharp.Benchmarks
{
using (Image<Rgba32> image = new Image<Rgba32>(800, 800))
{
image.Fill(Brushes<Rgba32>.BackwardDiagonal(Rgba32.HotPink));
image.Fill(CoreBrushes.BackwardDiagonal(Rgba32.HotPink));
using (MemoryStream ms = new MemoryStream())
{

28
tests/ImageSharp.Tests/Drawing/FillPatternTests.cs

@ -63,7 +63,7 @@ namespace ImageSharp.Tests.Drawing
[Fact]
public void ImageShouldBeFloodFilledWithPercent10()
{
this.Test("Percent10", Rgba32.Blue, Brushes<Rgba32>.Percent10(Rgba32.HotPink, Rgba32.LimeGreen),
this.Test("Percent10", Rgba32.Blue, Brushes.Percent10(Rgba32.HotPink, Rgba32.LimeGreen),
new[,]
{
{ Rgba32.HotPink , Rgba32.LimeGreen, Rgba32.LimeGreen, Rgba32.LimeGreen},
@ -76,7 +76,7 @@ namespace ImageSharp.Tests.Drawing
[Fact]
public void ImageShouldBeFloodFilledWithPercent10Transparent()
{
Test("Percent10_Transparent", Rgba32.Blue, Brushes<Rgba32>.Percent10(Rgba32.HotPink),
Test("Percent10_Transparent", Rgba32.Blue, Brushes.Percent10(Rgba32.HotPink),
new Rgba32[,] {
{ Rgba32.HotPink , Rgba32.Blue, Rgba32.Blue, Rgba32.Blue},
{ Rgba32.Blue, Rgba32.Blue, Rgba32.Blue, Rgba32.Blue},
@ -88,7 +88,7 @@ namespace ImageSharp.Tests.Drawing
[Fact]
public void ImageShouldBeFloodFilledWithPercent20()
{
Test("Percent20", Rgba32.Blue, Brushes<Rgba32>.Percent20(Rgba32.HotPink, Rgba32.LimeGreen),
Test("Percent20", Rgba32.Blue, Brushes.Percent20(Rgba32.HotPink, Rgba32.LimeGreen),
new Rgba32[,] {
{ Rgba32.HotPink , Rgba32.LimeGreen, Rgba32.LimeGreen, Rgba32.LimeGreen},
{ Rgba32.LimeGreen, Rgba32.LimeGreen, Rgba32.HotPink , Rgba32.LimeGreen},
@ -100,7 +100,7 @@ namespace ImageSharp.Tests.Drawing
[Fact]
public void ImageShouldBeFloodFilledWithPercent20_transparent()
{
Test("Percent20_Transparent", Rgba32.Blue, Brushes<Rgba32>.Percent20(Rgba32.HotPink),
Test("Percent20_Transparent", Rgba32.Blue, Brushes.Percent20(Rgba32.HotPink),
new Rgba32[,] {
{ Rgba32.HotPink , Rgba32.Blue, Rgba32.Blue, Rgba32.Blue},
{ Rgba32.Blue, Rgba32.Blue, Rgba32.HotPink , Rgba32.Blue},
@ -112,7 +112,7 @@ namespace ImageSharp.Tests.Drawing
[Fact]
public void ImageShouldBeFloodFilledWithHorizontal()
{
Test("Horizontal", Rgba32.Blue, Brushes<Rgba32>.Horizontal(Rgba32.HotPink, Rgba32.LimeGreen),
Test("Horizontal", Rgba32.Blue, Brushes.Horizontal(Rgba32.HotPink, Rgba32.LimeGreen),
new Rgba32[,] {
{ Rgba32.LimeGreen , Rgba32.LimeGreen, Rgba32.LimeGreen, Rgba32.LimeGreen},
{ Rgba32.HotPink, Rgba32.HotPink, Rgba32.HotPink , Rgba32.HotPink},
@ -124,7 +124,7 @@ namespace ImageSharp.Tests.Drawing
[Fact]
public void ImageShouldBeFloodFilledWithHorizontal_transparent()
{
Test("Horizontal_Transparent", Rgba32.Blue, Brushes<Rgba32>.Horizontal(Rgba32.HotPink),
Test("Horizontal_Transparent", Rgba32.Blue, Brushes.Horizontal(Rgba32.HotPink),
new Rgba32[,] {
{ Rgba32.Blue , Rgba32.Blue, Rgba32.Blue, Rgba32.Blue},
{ Rgba32.HotPink, Rgba32.HotPink, Rgba32.HotPink , Rgba32.HotPink},
@ -138,7 +138,7 @@ namespace ImageSharp.Tests.Drawing
[Fact]
public void ImageShouldBeFloodFilledWithMin()
{
Test("Min", Rgba32.Blue, Brushes<Rgba32>.Min(Rgba32.HotPink, Rgba32.LimeGreen),
Test("Min", Rgba32.Blue, Brushes.Min(Rgba32.HotPink, Rgba32.LimeGreen),
new Rgba32[,] {
{ Rgba32.LimeGreen , Rgba32.LimeGreen, Rgba32.LimeGreen, Rgba32.LimeGreen},
{ Rgba32.LimeGreen , Rgba32.LimeGreen, Rgba32.LimeGreen, Rgba32.LimeGreen},
@ -150,7 +150,7 @@ namespace ImageSharp.Tests.Drawing
[Fact]
public void ImageShouldBeFloodFilledWithMin_transparent()
{
Test("Min_Transparent", Rgba32.Blue, Brushes<Rgba32>.Min(Rgba32.HotPink),
Test("Min_Transparent", Rgba32.Blue, Brushes.Min(Rgba32.HotPink),
new Rgba32[,] {
{ Rgba32.Blue , Rgba32.Blue, Rgba32.Blue, Rgba32.Blue},
{ Rgba32.Blue , Rgba32.Blue, Rgba32.Blue, Rgba32.Blue},
@ -162,7 +162,7 @@ namespace ImageSharp.Tests.Drawing
[Fact]
public void ImageShouldBeFloodFilledWithVertical()
{
Test("Vertical", Rgba32.Blue, Brushes<Rgba32>.Vertical(Rgba32.HotPink, Rgba32.LimeGreen),
Test("Vertical", Rgba32.Blue, Brushes.Vertical(Rgba32.HotPink, Rgba32.LimeGreen),
new Rgba32[,] {
{ Rgba32.LimeGreen, Rgba32.HotPink, Rgba32.LimeGreen, Rgba32.LimeGreen},
{ Rgba32.LimeGreen, Rgba32.HotPink, Rgba32.LimeGreen, Rgba32.LimeGreen},
@ -174,7 +174,7 @@ namespace ImageSharp.Tests.Drawing
[Fact]
public void ImageShouldBeFloodFilledWithVertical_transparent()
{
Test("Vertical_Transparent", Rgba32.Blue, Brushes<Rgba32>.Vertical(Rgba32.HotPink),
Test("Vertical_Transparent", Rgba32.Blue, Brushes.Vertical(Rgba32.HotPink),
new Rgba32[,] {
{ Rgba32.Blue, Rgba32.HotPink, Rgba32.Blue, Rgba32.Blue},
{ Rgba32.Blue, Rgba32.HotPink, Rgba32.Blue, Rgba32.Blue},
@ -186,7 +186,7 @@ namespace ImageSharp.Tests.Drawing
[Fact]
public void ImageShouldBeFloodFilledWithForwardDiagonal()
{
Test("ForwardDiagonal", Rgba32.Blue, Brushes<Rgba32>.ForwardDiagonal(Rgba32.HotPink, Rgba32.LimeGreen),
Test("ForwardDiagonal", Rgba32.Blue, Brushes.ForwardDiagonal(Rgba32.HotPink, Rgba32.LimeGreen),
new Rgba32[,] {
{ Rgba32.LimeGreen, Rgba32.LimeGreen, Rgba32.LimeGreen, Rgba32.HotPink},
{ Rgba32.LimeGreen, Rgba32.LimeGreen, Rgba32.HotPink, Rgba32.LimeGreen},
@ -198,7 +198,7 @@ namespace ImageSharp.Tests.Drawing
[Fact]
public void ImageShouldBeFloodFilledWithForwardDiagonal_transparent()
{
Test("ForwardDiagonal_Transparent", Rgba32.Blue, Brushes<Rgba32>.ForwardDiagonal(Rgba32.HotPink),
Test("ForwardDiagonal_Transparent", Rgba32.Blue, Brushes.ForwardDiagonal(Rgba32.HotPink),
new Rgba32[,] {
{ Rgba32.Blue, Rgba32.Blue, Rgba32.Blue, Rgba32.HotPink},
{ Rgba32.Blue, Rgba32.Blue, Rgba32.HotPink, Rgba32.Blue},
@ -210,7 +210,7 @@ namespace ImageSharp.Tests.Drawing
[Fact]
public void ImageShouldBeFloodFilledWithBackwardDiagonal()
{
Test("BackwardDiagonal", Rgba32.Blue, Brushes<Rgba32>.BackwardDiagonal(Rgba32.HotPink, Rgba32.LimeGreen),
Test("BackwardDiagonal", Rgba32.Blue, Brushes.BackwardDiagonal(Rgba32.HotPink, Rgba32.LimeGreen),
new Rgba32[,] {
{ Rgba32.HotPink, Rgba32.LimeGreen, Rgba32.LimeGreen, Rgba32.LimeGreen},
{ Rgba32.LimeGreen, Rgba32.HotPink, Rgba32.LimeGreen, Rgba32.LimeGreen},
@ -222,7 +222,7 @@ namespace ImageSharp.Tests.Drawing
[Fact]
public void ImageShouldBeFloodFilledWithBackwardDiagonal_transparent()
{
Test("BackwardDiagonal_Transparent", Rgba32.Blue, Brushes<Rgba32>.BackwardDiagonal(Rgba32.HotPink),
Test("BackwardDiagonal_Transparent", Rgba32.Blue, Brushes.BackwardDiagonal(Rgba32.HotPink),
new Rgba32[,] {
{ Rgba32.HotPink, Rgba32.Blue, Rgba32.Blue, Rgba32.Blue},
{ Rgba32.Blue, Rgba32.HotPink, Rgba32.Blue, Rgba32.Blue},

2
tests/ImageSharp.Tests/Drawing/LineComplexPolygonTests.cs

@ -185,7 +185,7 @@ namespace ImageSharp.Tests.Drawing
{
image
.BackgroundColor(Rgba32.Blue)
.Draw(Pens<Rgba32>.Dash(Rgba32.HotPink, 5), simplePath.Clip(hole1))
.Draw(Pens.Dash(Rgba32.HotPink, 5), simplePath.Clip(hole1))
.Save(output);
}
}

8
tests/ImageSharp.Tests/Drawing/LineTests.cs

@ -88,7 +88,7 @@ namespace ImageSharp.Tests.Drawing
{
image
.BackgroundColor(Rgba32.Blue)
.DrawLines(Pens<Rgba32>.Dash(Rgba32.HotPink, 5),
.DrawLines(Pens.Dash(Rgba32.HotPink, 5),
new[] {
new Vector2(10, 10),
new Vector2(200, 150),
@ -109,7 +109,7 @@ namespace ImageSharp.Tests.Drawing
{
image
.BackgroundColor(Rgba32.Blue)
.DrawLines(Pens<Rgba32>.Dot(Rgba32.HotPink, 5),
.DrawLines(Pens.Dot(Rgba32.HotPink, 5),
new[] {
new Vector2(10, 10),
new Vector2(200, 150),
@ -130,7 +130,7 @@ namespace ImageSharp.Tests.Drawing
{
image
.BackgroundColor(Rgba32.Blue)
.DrawLines(Pens<Rgba32>.DashDot(Rgba32.HotPink, 5),
.DrawLines(Pens.DashDot(Rgba32.HotPink, 5),
new[] {
new Vector2(10, 10),
new Vector2(200, 150),
@ -151,7 +151,7 @@ namespace ImageSharp.Tests.Drawing
{
image
.BackgroundColor(Rgba32.Blue)
.DrawLines(Pens<Rgba32>.DashDotDot(Rgba32.HotPink, 5), new[] {
.DrawLines(Pens.DashDotDot(Rgba32.HotPink, 5), new[] {
new Vector2(10, 10),
new Vector2(200, 150),
new Vector2(50, 300)

2
tests/ImageSharp.Tests/Drawing/Paths/DrawBeziersTests.cs

@ -18,7 +18,7 @@ namespace ImageSharp.Tests.Drawing.Paths
float thickness = 7.2f;
GraphicsOptions noneDefault = new GraphicsOptions();
Rgba32 color = Rgba32.HotPink;
SolidBrush<Rgba32> brush = Brushes<Rgba32>.Solid(Rgba32.HotPink);
SolidBrush<Rgba32> brush = Brushes.Solid(Rgba32.HotPink);
Pen<Rgba32> pen = new Pen<Rgba32>(Rgba32.Firebrick, 99.9f);
Vector2[] points = new Vector2[] {
new Vector2(10,10),

2
tests/ImageSharp.Tests/Drawing/Paths/DrawLinesTests.cs

@ -17,7 +17,7 @@ namespace ImageSharp.Tests.Drawing.Paths
float thickness = 7.2f;
GraphicsOptions noneDefault = new GraphicsOptions();
Rgba32 color = Rgba32.HotPink;
SolidBrush<Rgba32> brush = Brushes<Rgba32>.Solid(Rgba32.HotPink);
SolidBrush<Rgba32> brush = Brushes.Solid(Rgba32.HotPink);
Pen<Rgba32> pen = new Pen<Rgba32>(Rgba32.Gray, 99.9f);
Vector2[] points = new Vector2[] {
new Vector2(10,10),

2
tests/ImageSharp.Tests/Drawing/Paths/DrawPath.cs

@ -18,7 +18,7 @@ namespace ImageSharp.Tests.Drawing.Paths
float thickness = 7.2f;
GraphicsOptions noneDefault = new GraphicsOptions();
Rgba32 color = Rgba32.HotPink;
SolidBrush<Rgba32> brush = Brushes<Rgba32>.Solid(Rgba32.HotPink);
SolidBrush<Rgba32> brush = Brushes.Solid(Rgba32.HotPink);
Pen<Rgba32> pen = new Pen<Rgba32>(Rgba32.Gray, 99.9f);
IPath path = new SixLabors.Shapes.Path(new LinearLineSegment(new Vector2[] {
new Vector2(10,10),

2
tests/ImageSharp.Tests/Drawing/Paths/DrawPolygon.cs

@ -18,7 +18,7 @@ namespace ImageSharp.Tests.Drawing.Paths
float thickness = 7.2f;
GraphicsOptions noneDefault = new GraphicsOptions();
Rgba32 color = Rgba32.HotPink;
SolidBrush<Rgba32> brush = Brushes<Rgba32>.Solid(Rgba32.HotPink);
SolidBrush<Rgba32> brush = Brushes.Solid(Rgba32.HotPink);
Pen<Rgba32> pen = new Pen<Rgba32>(Rgba32.Gray, 99.9f);
Vector2[] points = new Vector2[] {
new Vector2(10,10),

2
tests/ImageSharp.Tests/Drawing/Paths/DrawRectangle.cs

@ -15,7 +15,7 @@ namespace ImageSharp.Tests.Drawing.Paths
float thickness = 7.2f;
GraphicsOptions noneDefault = new GraphicsOptions();
Rgba32 color = Rgba32.HotPink;
SolidBrush<Rgba32> brush = Brushes<Rgba32>.Solid(Rgba32.HotPink);
SolidBrush<Rgba32> brush = Brushes.Solid(Rgba32.HotPink);
Pen<Rgba32> pen = new Pen<Rgba32>(Rgba32.Gray, 99.9f);
ImageSharp.Rectangle rectangle = new ImageSharp.Rectangle(10, 10, 98, 324);

2
tests/ImageSharp.Tests/Drawing/Paths/FillPath.cs

@ -15,7 +15,7 @@ namespace ImageSharp.Tests.Drawing.Paths
{
GraphicsOptions noneDefault = new GraphicsOptions();
Rgba32 color = Rgba32.HotPink;
SolidBrush<Rgba32> brush = Brushes<Rgba32>.Solid(Rgba32.HotPink);
SolidBrush<Rgba32> brush = Brushes.Solid(Rgba32.HotPink);
IPath path = new SixLabors.Shapes.Path(new LinearLineSegment(new Vector2[] {
new Vector2(10,10),
new Vector2(20,10),

2
tests/ImageSharp.Tests/Drawing/Paths/FillPolygon.cs

@ -15,7 +15,7 @@ namespace ImageSharp.Tests.Drawing.Paths
{
GraphicsOptions noneDefault = new GraphicsOptions();
Rgba32 color = Rgba32.HotPink;
SolidBrush<Rgba32> brush = Brushes<Rgba32>.Solid(Rgba32.HotPink);
SolidBrush<Rgba32> brush = Brushes.Solid(Rgba32.HotPink);
Vector2[] path = new Vector2[] {
new Vector2(10,10),
new Vector2(20,10),

2
tests/ImageSharp.Tests/Drawing/Paths/FillRectangle.cs

@ -14,7 +14,7 @@ namespace ImageSharp.Tests.Drawing.Paths
{
GraphicsOptions noneDefault = new GraphicsOptions();
Rgba32 color = Rgba32.HotPink;
SolidBrush<Rgba32> brush = Brushes<Rgba32>.Solid(Rgba32.HotPink);
SolidBrush<Rgba32> brush = Brushes.Solid(Rgba32.HotPink);
ImageSharp.Rectangle rectangle = new ImageSharp.Rectangle(10, 10, 77, 76);
private ProcessorWatchingImage img;

2
tests/ImageSharp.Tests/Drawing/SolidPolygonTests.cs

@ -60,7 +60,7 @@ namespace ImageSharp.Tests.Drawing
using (FileStream output = File.OpenWrite($"{path}/Pattern.png"))
{
image
.FillPolygon(Brushes<Rgba32>.Horizontal(Rgba32.HotPink), simplePath, new GraphicsOptions(true))
.FillPolygon(Brushes.Horizontal(Rgba32.HotPink), simplePath, new GraphicsOptions(true))
.Save(output);
}

34
tests/ImageSharp.Tests/Drawing/Text/DrawText.cs

@ -24,7 +24,7 @@ namespace ImageSharp.Tests.Drawing.Text
{
Rgba32 color = Rgba32.HotPink;
SolidBrush<Rgba32> brush = Brushes<Rgba32>.Solid(Rgba32.HotPink);
SolidBrush<Rgba32> brush = Brushes.Solid(Rgba32.HotPink);
IPath path = new SixLabors.Shapes.Path(
new LinearLineSegment(
@ -54,7 +54,7 @@ namespace ImageSharp.Tests.Drawing.Text
this.img.DrawText(
"123",
this.Font,
Brushes<Rgba32>.Solid(Rgba32.Red),
Brushes.Solid(Rgba32.Red),
null,
Vector2.Zero,
new TextGraphicsOptions(true));
@ -67,7 +67,7 @@ namespace ImageSharp.Tests.Drawing.Text
[Fact]
public void FillsForEachACharachterWhenBrushSetAndNotPenDefaultOptions()
{
this.img.DrawText("123", this.Font, Brushes<Rgba32>.Solid(Rgba32.Red), null, Vector2.Zero);
this.img.DrawText("123", this.Font, Brushes.Solid(Rgba32.Red), null, Vector2.Zero);
Assert.NotEmpty(this.img.ProcessorApplications);
Assert.Equal(3, this.img.ProcessorApplications.Count); // 3 fills where applied
@ -77,7 +77,7 @@ namespace ImageSharp.Tests.Drawing.Text
[Fact]
public void FillsForEachACharachterWhenBrushSet()
{
this.img.DrawText("123", this.Font, Brushes<Rgba32>.Solid(Rgba32.Red), Vector2.Zero, new TextGraphicsOptions(true));
this.img.DrawText("123", this.Font, Brushes.Solid(Rgba32.Red), Vector2.Zero, new TextGraphicsOptions(true));
Assert.NotEmpty(this.img.ProcessorApplications);
Assert.Equal(3, this.img.ProcessorApplications.Count); // 3 fills where applied
@ -87,7 +87,7 @@ namespace ImageSharp.Tests.Drawing.Text
[Fact]
public void FillsForEachACharachterWhenBrushSetDefaultOptions()
{
this.img.DrawText("123", this.Font, Brushes<Rgba32>.Solid(Rgba32.Red), Vector2.Zero);
this.img.DrawText("123", this.Font, Brushes.Solid(Rgba32.Red), Vector2.Zero);
Assert.NotEmpty(this.img.ProcessorApplications);
Assert.Equal(3, this.img.ProcessorApplications.Count); // 3 fills where applied
@ -130,7 +130,7 @@ namespace ImageSharp.Tests.Drawing.Text
"123",
this.Font,
null,
Pens<Rgba32>.Dash(Rgba32.Red, 1),
Pens.Dash(Rgba32.Red, 1),
Vector2.Zero,
new TextGraphicsOptions(true));
@ -142,7 +142,7 @@ namespace ImageSharp.Tests.Drawing.Text
[Fact]
public void DrawForEachACharachterWhenPenSetAndNotBrushDefaultOptions()
{
this.img.DrawText("123", this.Font, null, Pens<Rgba32>.Dash(Rgba32.Red, 1), Vector2.Zero);
this.img.DrawText("123", this.Font, null, Pens.Dash(Rgba32.Red, 1), Vector2.Zero);
Assert.NotEmpty(this.img.ProcessorApplications);
Assert.Equal(3, this.img.ProcessorApplications.Count); // 3 fills where applied
@ -152,7 +152,7 @@ namespace ImageSharp.Tests.Drawing.Text
[Fact]
public void DrawForEachACharachterWhenPenSet()
{
this.img.DrawText("123", this.Font, Pens<Rgba32>.Dash(Rgba32.Red, 1), Vector2.Zero, new TextGraphicsOptions(true));
this.img.DrawText("123", this.Font, Pens.Dash(Rgba32.Red, 1), Vector2.Zero, new TextGraphicsOptions(true));
Assert.NotEmpty(this.img.ProcessorApplications);
Assert.Equal(3, this.img.ProcessorApplications.Count); // 3 fills where applied
@ -162,7 +162,7 @@ namespace ImageSharp.Tests.Drawing.Text
[Fact]
public void DrawForEachACharachterWhenPenSetDefaultOptions()
{
this.img.DrawText("123", this.Font, Pens<Rgba32>.Dash(Rgba32.Red, 1), Vector2.Zero);
this.img.DrawText("123", this.Font, Pens.Dash(Rgba32.Red, 1), Vector2.Zero);
Assert.NotEmpty(this.img.ProcessorApplications);
Assert.Equal(3, this.img.ProcessorApplications.Count); // 3 fills where applied
@ -175,8 +175,8 @@ namespace ImageSharp.Tests.Drawing.Text
this.img.DrawText(
"123",
this.Font,
Brushes<Rgba32>.Solid(Rgba32.Red),
Pens<Rgba32>.Dash(Rgba32.Red, 1),
Brushes.Solid(Rgba32.Red),
Pens.Dash(Rgba32.Red, 1),
Vector2.Zero,
new TextGraphicsOptions(true));
@ -187,7 +187,7 @@ namespace ImageSharp.Tests.Drawing.Text
[Fact]
public void DrawForEachACharachterWhenPenSetAndFillFroEachWhenBrushSetDefaultOptions()
{
this.img.DrawText("123", this.Font, Brushes<Rgba32>.Solid(Rgba32.Red), Pens<Rgba32>.Dash(Rgba32.Red, 1), Vector2.Zero);
this.img.DrawText("123", this.Font, Brushes.Solid(Rgba32.Red), Pens.Dash(Rgba32.Red, 1), Vector2.Zero);
Assert.NotEmpty(this.img.ProcessorApplications);
Assert.Equal(6, this.img.ProcessorApplications.Count);
@ -199,8 +199,8 @@ namespace ImageSharp.Tests.Drawing.Text
this.img.DrawText(
"1",
this.Font,
Brushes<Rgba32>.Solid(Rgba32.Red),
Pens<Rgba32>.Dash(Rgba32.Red, 1),
Brushes.Solid(Rgba32.Red),
Pens.Dash(Rgba32.Red, 1),
Vector2.Zero,
new TextGraphicsOptions(true));
@ -213,7 +213,7 @@ namespace ImageSharp.Tests.Drawing.Text
[Fact]
public void BrushAppliesBeforPenDefaultOptions()
{
this.img.DrawText("1", this.Font, Brushes<Rgba32>.Solid(Rgba32.Red), Pens<Rgba32>.Dash(Rgba32.Red, 1), Vector2.Zero);
this.img.DrawText("1", this.Font, Brushes.Solid(Rgba32.Red), Pens.Dash(Rgba32.Red, 1), Vector2.Zero);
Assert.NotEmpty(this.img.ProcessorApplications);
Assert.Equal(2, this.img.ProcessorApplications.Count);
@ -226,11 +226,11 @@ namespace ImageSharp.Tests.Drawing.Text
{
this.img.MetaData.VerticalResolution = 1;
this.img.MetaData.HorizontalResolution = 1;
this.img.DrawText("1", this.Font, Brushes<Rgba32>.Solid(Rgba32.Red), Vector2.Zero, new TextGraphicsOptions(true) {
this.img.DrawText("1", this.Font, Brushes.Solid(Rgba32.Red), Vector2.Zero, new TextGraphicsOptions(true) {
UseImageResolution = false
});
this.img.DrawText("1", this.Font, Brushes<Rgba32>.Solid(Rgba32.Red), Vector2.Zero, new TextGraphicsOptions(true)
this.img.DrawText("1", this.Font, Brushes.Solid(Rgba32.Red), Vector2.Zero, new TextGraphicsOptions(true)
{
UseImageResolution = true
});

Loading…
Cancel
Save