Browse Source

Rename Color to Color32

pull/179/head
James Jackson-South 9 years ago
parent
commit
3c5e3a966e
  1. 60
      src/ImageSharp.Drawing/Brushes/Brushes.cs
  2. 6
      src/ImageSharp.Drawing/Brushes/ImageBrush.cs
  3. 8
      src/ImageSharp.Drawing/Brushes/PatternBrush.cs
  4. 4
      src/ImageSharp.Drawing/Brushes/RecolorBrush.cs
  5. 6
      src/ImageSharp.Drawing/Brushes/SolidBrush.cs
  6. 12
      src/ImageSharp.Drawing/Pens/Pen.cs
  7. 20
      src/ImageSharp.Drawing/Pens/Pens.cs
  8. 35
      src/ImageSharp/Colors/Color.BulkOperations.cs
  9. 66
      src/ImageSharp/Colors/Color32.Transforms.cs
  10. 62
      src/ImageSharp/Colors/Color32.cs
  11. 179
      src/ImageSharp/Colors/Color32Constants.cs
  12. 728
      src/ImageSharp/Colors/Color32Definitions.cs
  13. 179
      src/ImageSharp/Colors/ColorConstants.cs
  14. 728
      src/ImageSharp/Colors/ColorDefinitions.cs
  15. 60
      src/ImageSharp/Colors/ColorspaceTransforms.cs
  16. 8
      src/ImageSharp/Colors/ComponentOrder.cs
  17. 284
      src/ImageSharp/Colors/NamedColors{TColor}.cs
  18. 8
      src/ImageSharp/Colors/PackedPixel/IPixel.cs
  19. 2
      src/ImageSharp/Colors/PackedPixel/PackedPixelConverterHelper.cs
  20. 6
      src/ImageSharp/Colors/Spaces/Bgra32.cs
  21. 6
      src/ImageSharp/Colors/Spaces/CieLab.cs
  22. 6
      src/ImageSharp/Colors/Spaces/CieXyz.cs
  23. 4
      src/ImageSharp/Colors/Spaces/Cmyk.cs
  24. 6
      src/ImageSharp/Colors/Spaces/Hsl.cs
  25. 6
      src/ImageSharp/Colors/Spaces/Hsv.cs
  26. 6
      src/ImageSharp/Colors/Spaces/YCbCr.cs
  27. 2
      src/ImageSharp/Common/Extensions/Vector4Extensions.cs
  28. 6
      src/ImageSharp/Image.Create.cs
  29. 2
      src/ImageSharp/Image.FromFile.cs
  30. 4
      src/ImageSharp/Image.FromStream.cs
  31. 4
      src/ImageSharp/Image.cs
  32. 2
      src/ImageSharp/Processing/Processors/ColorMatrix/ColorMatrixProcessor.cs
  33. 2
      src/ImageSharp/Quantizers/PaletteQuantizer.cs
  34. 10
      tests/ImageSharp.Benchmarks/Color/Bulk/PackFromVector4ReferenceVsPointer.cs
  35. 4
      tests/ImageSharp.Benchmarks/Color/Bulk/PackFromXyzw.cs
  36. 2
      tests/ImageSharp.Benchmarks/Color/Bulk/ToVector4.cs
  37. 4
      tests/ImageSharp.Benchmarks/Color/Bulk/ToXyz.cs
  38. 4
      tests/ImageSharp.Benchmarks/Color/Bulk/ToXyzw.cs
  39. 2
      tests/ImageSharp.Benchmarks/Color/ColorEquality.cs
  40. 2
      tests/ImageSharp.Benchmarks/Drawing/DrawBeziers.cs
  41. 2
      tests/ImageSharp.Benchmarks/Drawing/DrawLines.cs
  42. 2
      tests/ImageSharp.Benchmarks/Drawing/DrawPolygon.cs
  43. 2
      tests/ImageSharp.Benchmarks/Drawing/FillPolygon.cs
  44. 2
      tests/ImageSharp.Benchmarks/Drawing/FillRectangle.cs
  45. 2
      tests/ImageSharp.Benchmarks/Drawing/FillWithPattern.cs
  46. 6
      tests/ImageSharp.Benchmarks/General/ClearBuffer.cs
  47. 2
      tests/ImageSharp.Benchmarks/Image/CopyPixels.cs
  48. 10
      tests/ImageSharp.Benchmarks/Image/EncodeIndexedPng.cs
  49. 8
      tests/ImageSharp.Benchmarks/Image/EncodePng.cs
  50. 2
      tests/ImageSharp.Benchmarks/Image/GetSetPixel.cs
  51. 12
      tests/ImageSharp.Tests/Colors/BulkPixelOperationsTests.cs
  52. 106
      tests/ImageSharp.Tests/Colors/ColorConversionTests.cs
  53. 10
      tests/ImageSharp.Tests/Colors/ColorDefinitionTests.cs
  54. 36
      tests/ImageSharp.Tests/Colors/ColorTests.cs
  55. 58
      tests/ImageSharp.Tests/Colors/ColorTransformTests.cs
  56. 6
      tests/ImageSharp.Tests/Common/BufferSpanTests.cs
  57. 8
      tests/ImageSharp.Tests/Common/PixelDataPoolTests.cs
  58. 32
      tests/ImageSharp.Tests/Drawing/BeziersTests.cs
  59. 22
      tests/ImageSharp.Tests/Drawing/DrawPathTests.cs
  60. 176
      tests/ImageSharp.Tests/Drawing/FillPatternTests.cs
  61. 4
      tests/ImageSharp.Tests/Drawing/FillRegionProcessorTests.cs
  62. 26
      tests/ImageSharp.Tests/Drawing/FillSolidBrushTests.cs
  63. 80
      tests/ImageSharp.Tests/Drawing/LineComplexPolygonTests.cs
  64. 64
      tests/ImageSharp.Tests/Drawing/LineTests.cs
  65. 30
      tests/ImageSharp.Tests/Drawing/Paths/DrawBeziersTests.cs
  66. 30
      tests/ImageSharp.Tests/Drawing/Paths/DrawLinesTests.cs
  67. 30
      tests/ImageSharp.Tests/Drawing/Paths/DrawPath.cs
  68. 30
      tests/ImageSharp.Tests/Drawing/Paths/DrawPolygon.cs
  69. 30
      tests/ImageSharp.Tests/Drawing/Paths/DrawRectangle.cs
  70. 16
      tests/ImageSharp.Tests/Drawing/Paths/FillPath.cs
  71. 16
      tests/ImageSharp.Tests/Drawing/Paths/FillPolygon.cs
  72. 16
      tests/ImageSharp.Tests/Drawing/Paths/FillRectangle.cs
  73. 8
      tests/ImageSharp.Tests/Drawing/Paths/ProcessorWatchingImage.cs
  74. 42
      tests/ImageSharp.Tests/Drawing/PolygonTests.cs
  75. 4
      tests/ImageSharp.Tests/Drawing/RecolorImageTest.cs
  76. 22
      tests/ImageSharp.Tests/Drawing/SolidBezierTests.cs
  77. 30
      tests/ImageSharp.Tests/Drawing/SolidComplexPolygonTests.cs
  78. 76
      tests/ImageSharp.Tests/Drawing/SolidPolygonTests.cs
  79. 86
      tests/ImageSharp.Tests/Drawing/Text/DrawText.cs
  80. 4
      tests/ImageSharp.Tests/Drawing/Text/OutputText.cs
  81. 6
      tests/ImageSharp.Tests/Formats/Jpg/JpegProfilingBenchmarks.cs
  82. 100
      tests/ImageSharp.Tests/Image/ImageLoadTests.cs
  83. 24
      tests/ImageSharp.Tests/Image/ImageSaveTests.cs
  84. 16
      tests/ImageSharp.Tests/Image/PixelAccessorTests.cs
  85. 2
      tests/ImageSharp.Tests/MetaData/Profiles/Exif/ExifProfileTests.cs
  86. 2
      tests/ImageSharp.Tests/Processors/Filters/BackgroundColorTest.cs
  87. 2
      tests/ImageSharp.Tests/Processors/Filters/GlowTest.cs
  88. 6
      tests/ImageSharp.Tests/Processors/Filters/ResizeProfilingBenchmarks.cs
  89. 2
      tests/ImageSharp.Tests/Processors/Filters/VignetteTest.cs
  90. 8
      tests/ImageSharp.Tests/TestUtilities/Factories/ImageFactory.cs
  91. 6
      tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestPatternProvider.cs
  92. 8
      tests/ImageSharp.Tests/TestUtilities/TestUtilityExtensions.cs
  93. 4
      tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs
  94. 18
      tests/ImageSharp.Tests/TestUtilities/Tests/TestUtilityExtensionsTests.cs

60
src/ImageSharp.Drawing/Brushes/Brushes.cs

@ -6,7 +6,7 @@
namespace ImageSharp.Drawing.Brushes
{
/// <summary>
/// A collection of methods for creating brushes. Brushes use <see cref="Color"/> for painting.
/// A collection of methods for creating brushes. Brushes use <see cref="Color32"/> for painting.
/// </summary>
public class Brushes
{
@ -15,7 +15,7 @@ namespace ImageSharp.Drawing.Brushes
/// </summary>
/// <param name="color">The color.</param>
/// <returns>A Brush</returns>
public static SolidBrush Solid(Color color)
public static SolidBrush Solid(Color32 color)
=> new SolidBrush(color);
/// <summary>
@ -24,8 +24,8 @@ namespace ImageSharp.Drawing.Brushes
/// </summary>
/// <param name="foreColor">Color of the foreground.</param>
/// <returns>A Brush</returns>
public static PatternBrush Percent10(Color foreColor)
=> new PatternBrush(Brushes<Color>.Percent10(foreColor, Color.Transparent));
public static PatternBrush Percent10(Color32 foreColor)
=> new PatternBrush(Brushes<Color32>.Percent10(foreColor, Color32.Transparent));
/// <summary>
/// Create as brush that will paint a Percent10 Hatch Pattern with
@ -34,8 +34,8 @@ namespace ImageSharp.Drawing.Brushes
/// <param name="foreColor">Color of the foreground.</param>
/// <param name="backColor">Color of the background.</param>
/// <returns>A Brush</returns>
public static PatternBrush Percent10(Color foreColor, Color backColor)
=> new PatternBrush(Brushes<Color>.Percent10(foreColor, backColor));
public static PatternBrush Percent10(Color32 foreColor, Color32 backColor)
=> new PatternBrush(Brushes<Color32>.Percent10(foreColor, backColor));
/// <summary>
/// Create as brush that will paint a Percent20 Hatch Pattern with
@ -43,8 +43,8 @@ namespace ImageSharp.Drawing.Brushes
/// </summary>
/// <param name="foreColor">Color of the foreground.</param>
/// <returns>A Brush</returns>
public static PatternBrush Percent20(Color foreColor)
=> new PatternBrush(Brushes<Color>.Percent20(foreColor, Color.Transparent));
public static PatternBrush Percent20(Color32 foreColor)
=> new PatternBrush(Brushes<Color32>.Percent20(foreColor, Color32.Transparent));
/// <summary>
/// Create as brush that will paint a Percent20 Hatch Pattern with
@ -53,8 +53,8 @@ namespace ImageSharp.Drawing.Brushes
/// <param name="foreColor">Color of the foreground.</param>
/// <param name="backColor">Color of the background.</param>
/// <returns>A Brush</returns>
public static PatternBrush Percent20(Color foreColor, Color backColor)
=> new PatternBrush(Brushes<Color>.Percent20(foreColor, backColor));
public static PatternBrush Percent20(Color32 foreColor, Color32 backColor)
=> new PatternBrush(Brushes<Color32>.Percent20(foreColor, backColor));
/// <summary>
/// Create as brush that will paint a Horizontal Hatch Pattern with
@ -62,8 +62,8 @@ namespace ImageSharp.Drawing.Brushes
/// </summary>
/// <param name="foreColor">Color of the foreground.</param>
/// <returns>A Brush</returns>
public static PatternBrush Horizontal(Color foreColor)
=> new PatternBrush(Brushes<Color>.Horizontal(foreColor, Color.Transparent));
public static PatternBrush Horizontal(Color32 foreColor)
=> new PatternBrush(Brushes<Color32>.Horizontal(foreColor, Color32.Transparent));
/// <summary>
/// Create as brush that will paint a Horizontal Hatch Pattern with
@ -72,8 +72,8 @@ namespace ImageSharp.Drawing.Brushes
/// <param name="foreColor">Color of the foreground.</param>
/// <param name="backColor">Color of the background.</param>
/// <returns>A Brush</returns>
public static PatternBrush Horizontal(Color foreColor, Color backColor)
=> new PatternBrush(Brushes<Color>.Horizontal(foreColor, backColor));
public static PatternBrush Horizontal(Color32 foreColor, Color32 backColor)
=> new PatternBrush(Brushes<Color32>.Horizontal(foreColor, backColor));
/// <summary>
/// Create as brush that will paint a Min Hatch Pattern with
@ -81,8 +81,8 @@ namespace ImageSharp.Drawing.Brushes
/// </summary>
/// <param name="foreColor">Color of the foreground.</param>
/// <returns>A Brush</returns>
public static PatternBrush Min(Color foreColor)
=> new PatternBrush(Brushes<Color>.Min(foreColor, Color.Transparent));
public static PatternBrush Min(Color32 foreColor)
=> new PatternBrush(Brushes<Color32>.Min(foreColor, Color32.Transparent));
/// <summary>
/// Create as brush that will paint a Min Hatch Pattern with
@ -91,8 +91,8 @@ namespace ImageSharp.Drawing.Brushes
/// <param name="foreColor">Color of the foreground.</param>
/// <param name="backColor">Color of the background.</param>
/// <returns>A Brush</returns>
public static PatternBrush Min(Color foreColor, Color backColor)
=> new PatternBrush(Brushes<Color>.Min(foreColor, backColor));
public static PatternBrush Min(Color32 foreColor, Color32 backColor)
=> new PatternBrush(Brushes<Color32>.Min(foreColor, backColor));
/// <summary>
/// Create as brush that will paint a Vertical Hatch Pattern with
@ -100,8 +100,8 @@ namespace ImageSharp.Drawing.Brushes
/// </summary>
/// <param name="foreColor">Color of the foreground.</param>
/// <returns>A Brush</returns>
public static PatternBrush Vertical(Color foreColor)
=> new PatternBrush(Brushes<Color>.Vertical(foreColor, Color.Transparent));
public static PatternBrush Vertical(Color32 foreColor)
=> new PatternBrush(Brushes<Color32>.Vertical(foreColor, Color32.Transparent));
/// <summary>
/// Create as brush that will paint a Vertical Hatch Pattern with
@ -110,8 +110,8 @@ namespace ImageSharp.Drawing.Brushes
/// <param name="foreColor">Color of the foreground.</param>
/// <param name="backColor">Color of the background.</param>
/// <returns>A Brush</returns>
public static PatternBrush Vertical(Color foreColor, Color backColor)
=> new PatternBrush(Brushes<Color>.Vertical(foreColor, backColor));
public static PatternBrush Vertical(Color32 foreColor, Color32 backColor)
=> new PatternBrush(Brushes<Color32>.Vertical(foreColor, backColor));
/// <summary>
/// Create as brush that will paint a Forward Diagonal Hatch Pattern with
@ -119,8 +119,8 @@ namespace ImageSharp.Drawing.Brushes
/// </summary>
/// <param name="foreColor">Color of the foreground.</param>
/// <returns>A Brush</returns>
public static PatternBrush ForwardDiagonal(Color foreColor)
=> new PatternBrush(Brushes<Color>.ForwardDiagonal(foreColor, Color.Transparent));
public static PatternBrush ForwardDiagonal(Color32 foreColor)
=> new PatternBrush(Brushes<Color32>.ForwardDiagonal(foreColor, Color32.Transparent));
/// <summary>
/// Create as brush that will paint a Forward Diagonal Hatch Pattern with
@ -129,8 +129,8 @@ namespace ImageSharp.Drawing.Brushes
/// <param name="foreColor">Color of the foreground.</param>
/// <param name="backColor">Color of the background.</param>
/// <returns>A Brush</returns>
public static PatternBrush ForwardDiagonal(Color foreColor, Color backColor)
=> new PatternBrush(Brushes<Color>.ForwardDiagonal(foreColor, backColor));
public static PatternBrush ForwardDiagonal(Color32 foreColor, Color32 backColor)
=> new PatternBrush(Brushes<Color32>.ForwardDiagonal(foreColor, backColor));
/// <summary>
/// Create as brush that will paint a Backward Diagonal Hatch Pattern with
@ -138,8 +138,8 @@ namespace ImageSharp.Drawing.Brushes
/// </summary>
/// <param name="foreColor">Color of the foreground.</param>
/// <returns>A Brush</returns>
public static PatternBrush BackwardDiagonal(Color foreColor)
=> new PatternBrush(Brushes<Color>.BackwardDiagonal(foreColor, Color.Transparent));
public static PatternBrush BackwardDiagonal(Color32 foreColor)
=> new PatternBrush(Brushes<Color32>.BackwardDiagonal(foreColor, Color32.Transparent));
/// <summary>
/// Create as brush that will paint a Backward Diagonal Hatch Pattern with
@ -148,7 +148,7 @@ namespace ImageSharp.Drawing.Brushes
/// <param name="foreColor">Color of the foreground.</param>
/// <param name="backColor">Color of the background.</param>
/// <returns>A Brush</returns>
public static PatternBrush BackwardDiagonal(Color foreColor, Color backColor)
=> new PatternBrush(Brushes<Color>.BackwardDiagonal(foreColor, backColor));
public static PatternBrush BackwardDiagonal(Color32 foreColor, Color32 backColor)
=> new PatternBrush(Brushes<Color32>.BackwardDiagonal(foreColor, backColor));
}
}

6
src/ImageSharp.Drawing/Brushes/ImageBrush.cs

@ -6,15 +6,15 @@
namespace ImageSharp.Drawing.Brushes
{
/// <summary>
/// Provides an implementation of a solid brush for painting with repeating images. The brush uses <see cref="Color"/> for painting.
/// Provides an implementation of a solid brush for painting with repeating images. The brush uses <see cref="Color32"/> for painting.
/// </summary>
public class ImageBrush : ImageBrush<Color>
public class ImageBrush : ImageBrush<Color32>
{
/// <summary>
/// Initializes a new instance of the <see cref="ImageBrush" /> class.
/// </summary>
/// <param name="image">The image to paint.</param>
public ImageBrush(IImageBase<Color> image)
public ImageBrush(IImageBase<Color32> image)
: base(image)
{
}

8
src/ImageSharp.Drawing/Brushes/PatternBrush.cs

@ -6,9 +6,9 @@
namespace ImageSharp.Drawing.Brushes
{
/// <summary>
/// Provides an implementation of a pattern brush for painting patterns. The brush use <see cref="Color"/> for painting.
/// Provides an implementation of a pattern brush for painting patterns. The brush use <see cref="Color32"/> for painting.
/// </summary>
public class PatternBrush : PatternBrush<Color>
public class PatternBrush : PatternBrush<Color32>
{
/// <summary>
/// Initializes a new instance of the <see cref="PatternBrush"/> class.
@ -16,7 +16,7 @@ namespace ImageSharp.Drawing.Brushes
/// <param name="foreColor">Color of the fore.</param>
/// <param name="backColor">Color of the back.</param>
/// <param name="pattern">The pattern.</param>
public PatternBrush(Color foreColor, Color backColor, bool[,] pattern)
public PatternBrush(Color32 foreColor, Color32 backColor, bool[,] pattern)
: base(foreColor, backColor, pattern)
{
}
@ -25,7 +25,7 @@ namespace ImageSharp.Drawing.Brushes
/// Initializes a new instance of the <see cref="PatternBrush"/> class.
/// </summary>
/// <param name="brush">The brush.</param>
internal PatternBrush(PatternBrush<Color> brush)
internal PatternBrush(PatternBrush<Color32> brush)
: base(brush)
{
}

4
src/ImageSharp.Drawing/Brushes/RecolorBrush.cs

@ -8,7 +8,7 @@ namespace ImageSharp.Drawing.Brushes
/// <summary>
/// Provides an implementation of a recolor brush for painting color changes.
/// </summary>
public class RecolorBrush : RecolorBrush<Color>
public class RecolorBrush : RecolorBrush<Color32>
{
/// <summary>
/// Initializes a new instance of the <see cref="RecolorBrush" /> class.
@ -16,7 +16,7 @@ namespace ImageSharp.Drawing.Brushes
/// <param name="sourceColor">Color of the source.</param>
/// <param name="targetColor">Color of the target.</param>
/// <param name="threshold">The threshold.</param>
public RecolorBrush(Color sourceColor, Color targetColor, float threshold)
public RecolorBrush(Color32 sourceColor, Color32 targetColor, float threshold)
: base(sourceColor, targetColor, threshold)
{
}

6
src/ImageSharp.Drawing/Brushes/SolidBrush.cs

@ -6,15 +6,15 @@
namespace ImageSharp.Drawing.Brushes
{
/// <summary>
/// Provides an implementation of a solid brush for painting solid color areas. The brush uses <see cref="Color"/> for painting.
/// Provides an implementation of a solid brush for painting solid color areas. The brush uses <see cref="Color32"/> for painting.
/// </summary>
public class SolidBrush : SolidBrush<Color>
public class SolidBrush : SolidBrush<Color32>
{
/// <summary>
/// Initializes a new instance of the <see cref="SolidBrush" /> class.
/// </summary>
/// <param name="color">The color.</param>
public SolidBrush(Color color)
public SolidBrush(Color32 color)
: base(color)
{
}

12
src/ImageSharp.Drawing/Pens/Pen.cs

@ -6,16 +6,16 @@
namespace ImageSharp.Drawing.Pens
{
/// <summary>
/// Represents a <see cref="Pen{TColor}"/> in the <see cref="Color"/> color space.
/// Represents a <see cref="Pen{TColor}"/> in the <see cref="Color32"/> color space.
/// </summary>
public class Pen : Pen<Color>
public class Pen : Pen<Color32>
{
/// <summary>
/// Initializes a new instance of the <see cref="Pen"/> class.
/// </summary>
/// <param name="color">The color.</param>
/// <param name="width">The width.</param>
public Pen(Color color, float width)
public Pen(Color32 color, float width)
: base(color, width)
{
}
@ -25,7 +25,7 @@ namespace ImageSharp.Drawing.Pens
/// </summary>
/// <param name="brush">The brush.</param>
/// <param name="width">The width.</param>
public Pen(IBrush<Color> brush, float width)
public Pen(IBrush<Color32> brush, float width)
: base(brush, width)
{
}
@ -36,7 +36,7 @@ namespace ImageSharp.Drawing.Pens
/// <param name="brush">The brush.</param>
/// <param name="width">The width.</param>
/// <param name="pattern">The pattern.</param>
public Pen(IBrush<Color> brush, float width, float[] pattern)
public Pen(IBrush<Color32> brush, float width, float[] pattern)
: base(brush, width, pattern)
{
}
@ -45,7 +45,7 @@ namespace ImageSharp.Drawing.Pens
/// Initializes a new instance of the <see cref="Pen"/> class.
/// </summary>
/// <param name="pen">The pen.</param>
internal Pen(Pen<Color> pen)
internal Pen(Pen<Color32> pen)
: base(pen)
{
}

20
src/ImageSharp.Drawing/Pens/Pens.cs

@ -16,7 +16,7 @@ namespace ImageSharp.Drawing.Pens
/// <param name="color">The color.</param>
/// <param name="width">The width.</param>
/// <returns>The Pen</returns>
public static Pen Solid(Color color, float width) => new Pen(color, width);
public static Pen Solid(Color32 color, float width) => new Pen(color, width);
/// <summary>
/// Create a solid pen with out any drawing patterns
@ -24,7 +24,7 @@ namespace ImageSharp.Drawing.Pens
/// <param name="brush">The brush.</param>
/// <param name="width">The width.</param>
/// <returns>The Pen</returns>
public static Pen Solid(IBrush<Color> brush, float width) => new Pen(brush, width);
public static Pen Solid(IBrush<Color32> brush, float width) => new Pen(brush, width);
/// <summary>
/// Create a pen with a 'Dash' drawing patterns
@ -32,7 +32,7 @@ namespace ImageSharp.Drawing.Pens
/// <param name="color">The color.</param>
/// <param name="width">The width.</param>
/// <returns>The Pen</returns>
public static Pen Dash(Color color, float width) => new Pen(Pens<Color>.Dash(color, width));
public static Pen Dash(Color32 color, float width) => new Pen(Pens<Color32>.Dash(color, width));
/// <summary>
/// Create a pen with a 'Dash' drawing patterns
@ -40,7 +40,7 @@ namespace ImageSharp.Drawing.Pens
/// <param name="brush">The brush.</param>
/// <param name="width">The width.</param>
/// <returns>The Pen</returns>
public static Pen Dash(IBrush<Color> brush, float width) => new Pen(Pens<Color>.Dash(brush, width));
public static Pen Dash(IBrush<Color32> brush, float width) => new Pen(Pens<Color32>.Dash(brush, width));
/// <summary>
/// Create a pen with a 'Dot' drawing patterns
@ -48,7 +48,7 @@ namespace ImageSharp.Drawing.Pens
/// <param name="color">The color.</param>
/// <param name="width">The width.</param>
/// <returns>The Pen</returns>
public static Pen Dot(Color color, float width) => new Pen(Pens<Color>.Dot(color, width));
public static Pen Dot(Color32 color, float width) => new Pen(Pens<Color32>.Dot(color, width));
/// <summary>
/// Create a pen with a 'Dot' drawing patterns
@ -56,7 +56,7 @@ namespace ImageSharp.Drawing.Pens
/// <param name="brush">The brush.</param>
/// <param name="width">The width.</param>
/// <returns>The Pen</returns>
public static Pen Dot(IBrush<Color> brush, float width) => new Pen(Pens<Color>.Dot(brush, width));
public static Pen Dot(IBrush<Color32> brush, float width) => new Pen(Pens<Color32>.Dot(brush, width));
/// <summary>
/// Create a pen with a 'Dash Dot' drawing patterns
@ -64,7 +64,7 @@ namespace ImageSharp.Drawing.Pens
/// <param name="color">The color.</param>
/// <param name="width">The width.</param>
/// <returns>The Pen</returns>
public static Pen DashDot(Color color, float width) => new Pen(Pens<Color>.DashDot(color, width));
public static Pen DashDot(Color32 color, float width) => new Pen(Pens<Color32>.DashDot(color, width));
/// <summary>
/// Create a pen with a 'Dash Dot' drawing patterns
@ -72,7 +72,7 @@ namespace ImageSharp.Drawing.Pens
/// <param name="brush">The brush.</param>
/// <param name="width">The width.</param>
/// <returns>The Pen</returns>
public static Pen DashDot(IBrush<Color> brush, float width) => new Pen(Pens<Color>.DashDot(brush, width));
public static Pen DashDot(IBrush<Color32> brush, float width) => new Pen(Pens<Color32>.DashDot(brush, width));
/// <summary>
/// Create a pen with a 'Dash Dot Dot' drawing patterns
@ -80,7 +80,7 @@ namespace ImageSharp.Drawing.Pens
/// <param name="color">The color.</param>
/// <param name="width">The width.</param>
/// <returns>The Pen</returns>
public static Pen DashDotDot(Color color, float width) => new Pen(Pens<Color>.DashDotDot(color, width));
public static Pen DashDotDot(Color32 color, float width) => new Pen(Pens<Color32>.DashDotDot(color, width));
/// <summary>
/// Create a pen with a 'Dash Dot Dot' drawing patterns
@ -88,6 +88,6 @@ namespace ImageSharp.Drawing.Pens
/// <param name="brush">The brush.</param>
/// <param name="width">The width.</param>
/// <returns>The Pen</returns>
public static Pen DashDotDot(IBrush<Color> brush, float width) => new Pen(Pens<Color>.DashDotDot(brush, width));
public static Pen DashDotDot(IBrush<Color32> brush, float width) => new Pen(Pens<Color32>.DashDotDot(brush, width));
}
}

35
src/ImageSharp/Colors/Color.BulkOperations.cs

@ -8,17 +8,16 @@ namespace ImageSharp
using System;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
/// <content>
/// Conains the definition of <see cref="BulkOperations"/>
/// </content>
public partial struct Color
public partial struct Color32
{
/// <summary>
/// <see cref="BulkPixelOperations{TColor}"/> implementation optimized for <see cref="Color"/>.
/// <see cref="BulkPixelOperations{TColor}"/> implementation optimized for <see cref="Color32"/>.
/// </summary>
internal class BulkOperations : BulkPixelOperations<Color>
internal class BulkOperations : BulkPixelOperations<Color32>
{
/// <summary>
/// SIMD optimized bulk implementation of <see cref="IPixel.PackFromVector4(Vector4)"/>
@ -38,7 +37,7 @@ namespace ImageSharp
/// </see>
/// </remarks>
internal static unsafe void ToVector4SimdAligned(
BufferSpan<Color> sourceColors,
BufferSpan<Color32> sourceColors,
BufferSpan<Vector4> destVectors,
int count)
{
@ -96,7 +95,7 @@ namespace ImageSharp
}
/// <inheritdoc />
internal override void ToVector4(BufferSpan<Color> sourceColors, BufferSpan<Vector4> destVectors, int count)
internal override void ToVector4(BufferSpan<Color32> sourceColors, BufferSpan<Vector4> destVectors, int count)
{
if (count < 256 || !Vector.IsHardwareAccelerated)
{
@ -123,7 +122,7 @@ namespace ImageSharp
}
/// <inheritdoc />
internal override unsafe void PackFromXyzBytes(BufferSpan<byte> sourceBytes, BufferSpan<Color> destColors, int count)
internal override unsafe void PackFromXyzBytes(BufferSpan<byte> sourceBytes, BufferSpan<Color32> destColors, int count)
{
byte* source = (byte*)sourceBytes;
byte* destination = (byte*)destColors;
@ -138,7 +137,7 @@ namespace ImageSharp
}
/// <inheritdoc />
internal override unsafe void ToXyzBytes(BufferSpan<Color> sourceColors, BufferSpan<byte> destBytes, int count)
internal override unsafe void ToXyzBytes(BufferSpan<Color32> sourceColors, BufferSpan<byte> destBytes, int count)
{
byte* source = (byte*)sourceColors;
byte* destination = (byte*)destBytes;
@ -155,19 +154,19 @@ namespace ImageSharp
}
/// <inheritdoc />
internal override void PackFromXyzwBytes(BufferSpan<byte> sourceBytes, BufferSpan<Color> destColors, int count)
internal override void PackFromXyzwBytes(BufferSpan<byte> sourceBytes, BufferSpan<Color32> destColors, int count)
{
BufferSpan.Copy(sourceBytes, destColors, count);
}
/// <inheritdoc />
internal override void ToXyzwBytes(BufferSpan<Color> sourceColors, BufferSpan<byte> destBytes, int count)
internal override void ToXyzwBytes(BufferSpan<Color32> sourceColors, BufferSpan<byte> destBytes, int count)
{
BufferSpan.Copy(sourceColors, destBytes, count);
}
/// <inheritdoc />
internal override unsafe void PackFromZyxBytes(BufferSpan<byte> sourceBytes, BufferSpan<Color> destColors, int count)
internal override unsafe void PackFromZyxBytes(BufferSpan<byte> sourceBytes, BufferSpan<Color32> destColors, int count)
{
byte* source = (byte*)sourceBytes;
byte* destination = (byte*)destColors;
@ -182,7 +181,7 @@ namespace ImageSharp
}
/// <inheritdoc />
internal override unsafe void ToZyxBytes(BufferSpan<Color> sourceColors, BufferSpan<byte> destBytes, int count)
internal override unsafe void ToZyxBytes(BufferSpan<Color32> sourceColors, BufferSpan<byte> destBytes, int count)
{
byte* source = (byte*)sourceColors;
byte* destination = (byte*)destBytes;
@ -199,7 +198,7 @@ namespace ImageSharp
}
/// <inheritdoc />
internal override unsafe void PackFromZyxwBytes(BufferSpan<byte> sourceBytes, BufferSpan<Color> destColors, int count)
internal override unsafe void PackFromZyxwBytes(BufferSpan<byte> sourceBytes, BufferSpan<Color32> destColors, int count)
{
byte* source = (byte*)sourceBytes;
byte* destination = (byte*)destColors;
@ -214,7 +213,7 @@ namespace ImageSharp
}
/// <inheritdoc />
internal override unsafe void ToZyxwBytes(BufferSpan<Color> sourceColors, BufferSpan<byte> destBytes, int count)
internal override unsafe void ToZyxwBytes(BufferSpan<Color32> sourceColors, BufferSpan<byte> destBytes, int count)
{
byte* source = (byte*)sourceColors;
byte* destination = (byte*)destBytes;
@ -232,7 +231,7 @@ namespace ImageSharp
}
/// <summary>
/// Value type to store <see cref="Color"/>-s unpacked into multiple <see cref="uint"/>-s.
/// Value type to store <see cref="Color32"/>-s unpacked into multiple <see cref="uint"/>-s.
/// </summary>
private struct UnpackedRGBA
{
@ -245,9 +244,9 @@ namespace ImageSharp
public void Load(uint p)
{
this.r = p;
this.g = p >> Color.GreenShift;
this.b = p >> Color.BlueShift;
this.a = p >> Color.AlphaShift;
this.g = p >> Color32.GreenShift;
this.b = p >> Color32.BlueShift;
this.a = p >> Color32.AlphaShift;
}
}
}

66
src/ImageSharp/Colors/ColorTransforms.cs → src/ImageSharp/Colors/Color32.Transforms.cs

@ -1,4 +1,4 @@
// <copyright file="ColorTransforms.cs" company="James Jackson-South">
// <copyright file="Color32.Transforms.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
@ -15,7 +15,7 @@ namespace ImageSharp
/// This struct is fully mutable. This is done (against the guidelines) for the sake of performance,
/// as it avoids the need to create new values for modification operations.
/// </remarks>
public partial struct Color
public partial struct Color32
{
/// <summary>
/// Adds the second color to the first.
@ -23,9 +23,9 @@ namespace ImageSharp
/// <param name="left">The first source color.</param>
/// <param name="right">The second source color.</param>
/// <returns>
/// The <see cref="Color"/>.
/// The <see cref="Color32"/>.
/// </returns>
public static Color operator +(Color left, Color right)
public static Color32 operator +(Color32 left, Color32 right)
{
Vector4 add = left.ToVector4() + right.ToVector4();
return Pack(ref add);
@ -37,9 +37,9 @@ namespace ImageSharp
/// <param name="left">The first source color.</param>
/// <param name="right">The second source color.</param>
/// <returns>
/// The <see cref="Color"/>.
/// The <see cref="Color32"/>.
/// </returns>
public static Color operator -(Color left, Color right)
public static Color32 operator -(Color32 left, Color32 right)
{
Vector4 sub = left.ToVector4() - right.ToVector4();
return Pack(ref sub);
@ -51,9 +51,9 @@ namespace ImageSharp
/// <param name="backdrop">The backdrop color.</param>
/// <param name="source">The source color.</param>
/// <returns>
/// The <see cref="Color"/>.
/// The <see cref="Color32"/>.
/// </returns>
public static Color Normal(Color backdrop, Color source)
public static Color32 Normal(Color32 backdrop, Color32 source)
{
Vector4 normal = Vector4BlendTransforms.Normal(backdrop.ToVector4(), source.ToVector4());
return Pack(ref normal);
@ -71,9 +71,9 @@ namespace ImageSharp
/// <param name="backdrop">The backdrop color.</param>
/// <param name="source">The source color.</param>
/// <returns>
/// The <see cref="Color"/>.
/// The <see cref="Color32"/>.
/// </returns>
public static Color Multiply(Color backdrop, Color source)
public static Color32 Multiply(Color32 backdrop, Color32 source)
{
Vector4 multiply = Vector4BlendTransforms.Multiply(backdrop.ToVector4(), source.ToVector4());
return Pack(ref multiply);
@ -90,9 +90,9 @@ namespace ImageSharp
/// <param name="backdrop">The backdrop color.</param>
/// <param name="source">The source color.</param>
/// <returns>
/// The <see cref="Color"/>.
/// The <see cref="Color32"/>.
/// </returns>
public static Color Screen(Color backdrop, Color source)
public static Color32 Screen(Color32 backdrop, Color32 source)
{
Vector4 subtract = Vector4BlendTransforms.Screen(backdrop.ToVector4(), source.ToVector4());
return Pack(ref subtract);
@ -105,9 +105,9 @@ namespace ImageSharp
/// <param name="backdrop">The backdrop color.</param>
/// <param name="source">The source color.</param>
/// <returns>
/// The <see cref="Color"/>.
/// The <see cref="Color32"/>.
/// </returns>
public static Color HardLight(Color backdrop, Color source)
public static Color32 HardLight(Color32 backdrop, Color32 source)
{
Vector4 hardlight = Vector4BlendTransforms.HardLight(backdrop.ToVector4(), source.ToVector4());
return Pack(ref hardlight);
@ -124,9 +124,9 @@ namespace ImageSharp
/// <param name="backdrop">The backdrop color.</param>
/// <param name="source">The source color.</param>
/// <returns>
/// The <see cref="Color"/>.
/// The <see cref="Color32"/>.
/// </returns>
public static Color Overlay(Color backdrop, Color source)
public static Color32 Overlay(Color32 backdrop, Color32 source)
{
Vector4 overlay = Vector4BlendTransforms.Overlay(backdrop.ToVector4(), source.ToVector4());
return Pack(ref overlay);
@ -139,9 +139,9 @@ namespace ImageSharp
/// <param name="backdrop">The backdrop color.</param>
/// <param name="source">The source color.</param>
/// <returns>
/// The <see cref="Color"/>.
/// The <see cref="Color32"/>.
/// </returns>
public static Color Darken(Color backdrop, Color source)
public static Color32 Darken(Color32 backdrop, Color32 source)
{
Vector4 darken = Vector4BlendTransforms.Darken(backdrop.ToVector4(), source.ToVector4());
return Pack(ref darken);
@ -154,9 +154,9 @@ namespace ImageSharp
/// <param name="backdrop">The backdrop color.</param>
/// <param name="source">The source color.</param>
/// <returns>
/// The <see cref="Color"/>.
/// The <see cref="Color32"/>.
/// </returns>
public static Color Lighten(Color backdrop, Color source)
public static Color32 Lighten(Color32 backdrop, Color32 source)
{
Vector4 lighten = Vector4BlendTransforms.Lighten(backdrop.ToVector4(), source.ToVector4());
return Pack(ref lighten);
@ -169,9 +169,9 @@ namespace ImageSharp
/// <param name="backdrop">The backdrop color.</param>
/// <param name="source">The source color.</param>
/// <returns>
/// The <see cref="Color"/>.
/// The <see cref="Color32"/>.
/// </returns>
public static Color SoftLight(Color backdrop, Color source)
public static Color32 SoftLight(Color32 backdrop, Color32 source)
{
Vector4 softlight = Vector4BlendTransforms.SoftLight(backdrop.ToVector4(), source.ToVector4());
return Pack(ref softlight);
@ -183,9 +183,9 @@ namespace ImageSharp
/// <param name="backdrop">The backdrop color.</param>
/// <param name="source">The source color.</param>
/// <returns>
/// The <see cref="Color"/>.
/// The <see cref="Color32"/>.
/// </returns>
public static Color ColorDodge(Color backdrop, Color source)
public static Color32 ColorDodge(Color32 backdrop, Color32 source)
{
Vector4 dodge = Vector4BlendTransforms.Dodge(backdrop.ToVector4(), source.ToVector4());
return Pack(ref dodge);
@ -197,9 +197,9 @@ namespace ImageSharp
/// <param name="backdrop">The backdrop color.</param>
/// <param name="source">The source color.</param>
/// <returns>
/// The <see cref="Color"/>.
/// The <see cref="Color32"/>.
/// </returns>
public static Color ColorBurn(Color backdrop, Color source)
public static Color32 ColorBurn(Color32 backdrop, Color32 source)
{
Vector4 burn = Vector4BlendTransforms.Burn(backdrop.ToVector4(), source.ToVector4());
return Pack(ref burn);
@ -212,9 +212,9 @@ namespace ImageSharp
/// <param name="backdrop">The backdrop color.</param>
/// <param name="source">The source color.</param>
/// <returns>
/// The <see cref="Color"/>.
/// The <see cref="Color32"/>.
/// </returns>
public static Color Difference(Color backdrop, Color source)
public static Color32 Difference(Color32 backdrop, Color32 source)
{
Vector4 difference = Vector4BlendTransforms.Difference(backdrop.ToVector4(), source.ToVector4());
return Pack(ref difference);
@ -227,9 +227,9 @@ namespace ImageSharp
/// <param name="backdrop">The backdrop color.</param>
/// <param name="source">The source color.</param>
/// <returns>
/// The <see cref="Color"/>.
/// The <see cref="Color32"/>.
/// </returns>
public static Color Exclusion(Color backdrop, Color source)
public static Color32 Exclusion(Color32 backdrop, Color32 source)
{
Vector4 exclusion = Vector4BlendTransforms.Exclusion(backdrop.ToVector4(), source.ToVector4());
return Pack(ref exclusion);
@ -245,11 +245,11 @@ namespace ImageSharp
/// At amount = 0, "from" is returned, at amount = 1, "to" is returned.
/// </param>
/// <returns>
/// The <see cref="Color"/>
/// The <see cref="Color32"/>
/// </returns>
public static Color Lerp(Color from, Color to, float amount)
public static Color32 Lerp(Color32 from, Color32 to, float amount)
{
return new Color(Vector4.Lerp(from.ToVector4(), to.ToVector4(), amount));
return new Color32(Vector4.Lerp(from.ToVector4(), to.ToVector4(), amount));
}
}
}

62
src/ImageSharp/Colors/Color.cs → src/ImageSharp/Colors/Color32.cs

@ -18,7 +18,7 @@ namespace ImageSharp
/// as it avoids the need to create new values for modification operations.
/// </remarks>
[StructLayout(LayoutKind.Explicit)]
public partial struct Color : IPixel<Color>
public partial struct Color32 : IPixel<Color32>
{
/// <summary>
/// Gets or sets the red component.
@ -75,13 +75,13 @@ namespace ImageSharp
private static readonly Vector4 Half = new Vector4(0.5F);
/// <summary>
/// Initializes a new instance of the <see cref="Color"/> struct.
/// Initializes a new instance of the <see cref="Color32"/> struct.
/// </summary>
/// <param name="r">The red component.</param>
/// <param name="g">The green component.</param>
/// <param name="b">The blue component.</param>
/// <param name="a">The alpha component.</param>
public Color(byte r, byte g, byte b, byte a = 255)
public Color32(byte r, byte g, byte b, byte a = 255)
: this()
{
this.R = r;
@ -91,56 +91,56 @@ namespace ImageSharp
}
/// <summary>
/// Initializes a new instance of the <see cref="Color"/> struct.
/// Initializes a new instance of the <see cref="Color32"/> struct.
/// </summary>
/// <param name="r">The red component.</param>
/// <param name="g">The green component.</param>
/// <param name="b">The blue component.</param>
/// <param name="a">The alpha component.</param>
public Color(float r, float g, float b, float a = 1)
public Color32(float r, float g, float b, float a = 1)
: this()
{
this = Pack(r, g, b, a);
}
/// <summary>
/// Initializes a new instance of the <see cref="Color"/> struct.
/// Initializes a new instance of the <see cref="Color32"/> struct.
/// </summary>
/// <param name="vector">
/// The vector containing the components for the packed vector.
/// </param>
public Color(Vector3 vector)
public Color32(Vector3 vector)
: this()
{
this = Pack(ref vector);
}
/// <summary>
/// Initializes a new instance of the <see cref="Color"/> struct.
/// Initializes a new instance of the <see cref="Color32"/> struct.
/// </summary>
/// <param name="vector">
/// The vector containing the components for the packed vector.
/// </param>
public Color(Vector4 vector)
public Color32(Vector4 vector)
: this()
{
this = Pack(ref vector);
}
/// <summary>
/// Compares two <see cref="Color"/> objects for equality.
/// Compares two <see cref="Color32"/> objects for equality.
/// </summary>
/// <param name="left">
/// The <see cref="Color"/> on the left side of the operand.
/// The <see cref="Color32"/> on the left side of the operand.
/// </param>
/// <param name="right">
/// The <see cref="Color"/> on the right side of the operand.
/// The <see cref="Color32"/> on the right side of the operand.
/// </param>
/// <returns>
/// True if the <paramref name="left"/> parameter is equal to the <paramref name="right"/> parameter; otherwise, false.
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator ==(Color left, Color right)
public static bool operator ==(Color32 left, Color32 right)
{
return left.R == right.R
&& left.G == right.G
@ -149,15 +149,15 @@ namespace ImageSharp
}
/// <summary>
/// Compares two <see cref="Color"/> objects for equality.
/// Compares two <see cref="Color32"/> objects for equality.
/// </summary>
/// <param name="left">The <see cref="Color"/> on the left side of the operand.</param>
/// <param name="right">The <see cref="Color"/> on the right side of the operand.</param>
/// <param name="left">The <see cref="Color32"/> on the left side of the operand.</param>
/// <param name="right">The <see cref="Color32"/> on the right side of the operand.</param>
/// <returns>
/// True if the <paramref name="left"/> parameter is not equal to the <paramref name="right"/> parameter; otherwise, false.
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator !=(Color left, Color right)
public static bool operator !=(Color32 left, Color32 right)
{
return left.R != right.R
&& left.G != right.G
@ -166,22 +166,22 @@ namespace ImageSharp
}
/// <summary>
/// Creates a new instance of the <see cref="Color"/> struct.
/// Creates a new instance of the <see cref="Color32"/> struct.
/// </summary>
/// <param name="hex">
/// The hexadecimal representation of the combined color components arranged
/// in rgb, rgba, rrggbb, or rrggbbaa format to match web syntax.
/// </param>
/// <returns>
/// The <see cref="Color"/>.
/// The <see cref="Color32"/>.
/// </returns>
public static Color FromHex(string hex)
public static Color32 FromHex(string hex)
{
return ColorBuilder<Color>.FromHex(hex);
return ColorBuilder<Color32>.FromHex(hex);
}
/// <inheritdoc />
public BulkPixelOperations<Color> CreateBulkOperations() => new BulkOperations();
public BulkPixelOperations<Color32> CreateBulkOperations() => new BulkOperations();
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@ -258,12 +258,12 @@ namespace ImageSharp
/// <inheritdoc/>
public override bool Equals(object obj)
{
return (obj is Color) && this.Equals((Color)obj);
return (obj is Color32) && this.Equals((Color32)obj);
}
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool Equals(Color other)
public bool Equals(Color32 other)
{
return this.R == other.R
&& this.G == other.G
@ -311,24 +311,24 @@ namespace ImageSharp
/// Packs a <see cref="Vector4"/> into a uint.
/// </summary>
/// <param name="vector">The vector containing the values to pack.</param>
/// <returns>The <see cref="Color"/></returns>
/// <returns>The <see cref="Color32"/></returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static Color Pack(ref Vector4 vector)
private static Color32 Pack(ref Vector4 vector)
{
vector *= MaxBytes;
vector += Half;
vector = Vector4.Clamp(vector, Vector4.Zero, MaxBytes);
return new Color((byte)vector.X, (byte)vector.Y, (byte)vector.Z, (byte)vector.W);
return new Color32((byte)vector.X, (byte)vector.Y, (byte)vector.Z, (byte)vector.W);
}
/// <summary>
/// Packs a <see cref="Vector3"/> into a uint.
/// </summary>
/// <param name="vector">The vector containing the values to pack.</param>
/// <returns>The <see cref="Color"/></returns>
/// <returns>The <see cref="Color32"/></returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static Color Pack(ref Vector3 vector)
private static Color32 Pack(ref Vector3 vector)
{
Vector4 value = new Vector4(vector, 1);
return Pack(ref value);
@ -341,9 +341,9 @@ namespace ImageSharp
/// <param name="y">The y-component</param>
/// <param name="z">The z-component</param>
/// <param name="w">The w-component</param>
/// <returns>The <see cref="Color"/></returns>
/// <returns>The <see cref="Color32"/></returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static Color Pack(float x, float y, float z, float w)
private static Color32 Pack(float x, float y, float z, float w)
{
Vector4 value = new Vector4(x, y, z, w);
return Pack(ref value);

179
src/ImageSharp/Colors/Color32Constants.cs

@ -0,0 +1,179 @@
// <copyright file="Color32Constants.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp
{
using System;
using System.Collections.Generic;
/// <summary>
/// Provides useful color definitions.
/// </summary>
public static class Color32Constants
{
/// <summary>
/// Provides a lazy, one time method of returning the colors.
/// </summary>
private static readonly Lazy<Color32[]> SafeColors = new Lazy<Color32[]>(GetWebSafeColors);
/// <summary>
/// Gets a collection of named, web safe, colors as defined in the CSS Color Module Level 4.
/// </summary>
public static Color32[] WebSafeColors => SafeColors.Value;
/// <summary>
/// Returns an array of web safe colors.
/// </summary>
/// <returns>The <see cref="T:Color[]"/></returns>
private static Color32[] GetWebSafeColors()
{
return new List<Color32>
{
Color32.AliceBlue,
Color32.AntiqueWhite,
Color32.Aqua,
Color32.Aquamarine,
Color32.Azure,
Color32.Beige,
Color32.Bisque,
Color32.Black,
Color32.BlanchedAlmond,
Color32.Blue,
Color32.BlueViolet,
Color32.Brown,
Color32.BurlyWood,
Color32.CadetBlue,
Color32.Chartreuse,
Color32.Chocolate,
Color32.Coral,
Color32.CornflowerBlue,
Color32.Cornsilk,
Color32.Crimson,
Color32.Cyan,
Color32.DarkBlue,
Color32.DarkCyan,
Color32.DarkGoldenrod,
Color32.DarkGray,
Color32.DarkGreen,
Color32.DarkKhaki,
Color32.DarkMagenta,
Color32.DarkOliveGreen,
Color32.DarkOrange,
Color32.DarkOrchid,
Color32.DarkRed,
Color32.DarkSalmon,
Color32.DarkSeaGreen,
Color32.DarkSlateBlue,
Color32.DarkSlateGray,
Color32.DarkTurquoise,
Color32.DarkViolet,
Color32.DeepPink,
Color32.DeepSkyBlue,
Color32.DimGray,
Color32.DodgerBlue,
Color32.Firebrick,
Color32.FloralWhite,
Color32.ForestGreen,
Color32.Fuchsia,
Color32.Gainsboro,
Color32.GhostWhite,
Color32.Gold,
Color32.Goldenrod,
Color32.Gray,
Color32.Green,
Color32.GreenYellow,
Color32.Honeydew,
Color32.HotPink,
Color32.IndianRed,
Color32.Indigo,
Color32.Ivory,
Color32.Khaki,
Color32.Lavender,
Color32.LavenderBlush,
Color32.LawnGreen,
Color32.LemonChiffon,
Color32.LightBlue,
Color32.LightCoral,
Color32.LightCyan,
Color32.LightGoldenrodYellow,
Color32.LightGray,
Color32.LightGreen,
Color32.LightPink,
Color32.LightSalmon,
Color32.LightSeaGreen,
Color32.LightSkyBlue,
Color32.LightSlateGray,
Color32.LightSteelBlue,
Color32.LightYellow,
Color32.Lime,
Color32.LimeGreen,
Color32.Linen,
Color32.Magenta,
Color32.Maroon,
Color32.MediumAquamarine,
Color32.MediumBlue,
Color32.MediumOrchid,
Color32.MediumPurple,
Color32.MediumSeaGreen,
Color32.MediumSlateBlue,
Color32.MediumSpringGreen,
Color32.MediumTurquoise,
Color32.MediumVioletRed,
Color32.MidnightBlue,
Color32.MintCream,
Color32.MistyRose,
Color32.Moccasin,
Color32.NavajoWhite,
Color32.Navy,
Color32.OldLace,
Color32.Olive,
Color32.OliveDrab,
Color32.Orange,
Color32.OrangeRed,
Color32.Orchid,
Color32.PaleGoldenrod,
Color32.PaleGreen,
Color32.PaleTurquoise,
Color32.PaleVioletRed,
Color32.PapayaWhip,
Color32.PeachPuff,
Color32.Peru,
Color32.Pink,
Color32.Plum,
Color32.PowderBlue,
Color32.Purple,
Color32.RebeccaPurple,
Color32.Red,
Color32.RosyBrown,
Color32.RoyalBlue,
Color32.SaddleBrown,
Color32.Salmon,
Color32.SandyBrown,
Color32.SeaGreen,
Color32.SeaShell,
Color32.Sienna,
Color32.Silver,
Color32.SkyBlue,
Color32.SlateBlue,
Color32.SlateGray,
Color32.Snow,
Color32.SpringGreen,
Color32.SteelBlue,
Color32.Tan,
Color32.Teal,
Color32.Thistle,
Color32.Tomato,
Color32.Transparent,
Color32.Turquoise,
Color32.Violet,
Color32.Wheat,
Color32.White,
Color32.WhiteSmoke,
Color32.Yellow,
Color32.YellowGreen
}.ToArray();
}
}
}

728
src/ImageSharp/Colors/Color32Definitions.cs

@ -0,0 +1,728 @@
// <copyright file="Color32Definitions.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp
{
/// <summary>
/// Packed vector type containing four 8-bit unsigned normalized values ranging from 0 to 255.
/// The color components are stored in red, green, blue, and alpha order.
/// </summary>
/// <remarks>
/// This struct is fully mutable. This is done (against the guidelines) for the sake of performance,
/// as it avoids the need to create new values for modification operations.
/// </remarks>
public partial struct Color32
{
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #F0F8FF.
/// </summary>
public static readonly Color32 AliceBlue = NamedColors<Color32>.AliceBlue;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #FAEBD7.
/// </summary>
public static readonly Color32 AntiqueWhite = NamedColors<Color32>.AntiqueWhite;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #00FFFF.
/// </summary>
public static readonly Color32 Aqua = NamedColors<Color32>.Aqua;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #7FFFD4.
/// </summary>
public static readonly Color32 Aquamarine = NamedColors<Color32>.Aquamarine;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #F0FFFF.
/// </summary>
public static readonly Color32 Azure = NamedColors<Color32>.Azure;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #F5F5DC.
/// </summary>
public static readonly Color32 Beige = NamedColors<Color32>.Beige;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #FFE4C4.
/// </summary>
public static readonly Color32 Bisque = NamedColors<Color32>.Bisque;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #000000.
/// </summary>
public static readonly Color32 Black = NamedColors<Color32>.Black;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #FFEBCD.
/// </summary>
public static readonly Color32 BlanchedAlmond = NamedColors<Color32>.BlanchedAlmond;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #0000FF.
/// </summary>
public static readonly Color32 Blue = NamedColors<Color32>.Blue;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #8A2BE2.
/// </summary>
public static readonly Color32 BlueViolet = NamedColors<Color32>.BlueViolet;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #A52A2A.
/// </summary>
public static readonly Color32 Brown = NamedColors<Color32>.Brown;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #DEB887.
/// </summary>
public static readonly Color32 BurlyWood = NamedColors<Color32>.BurlyWood;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #5F9EA0.
/// </summary>
public static readonly Color32 CadetBlue = NamedColors<Color32>.CadetBlue;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #7FFF00.
/// </summary>
public static readonly Color32 Chartreuse = NamedColors<Color32>.Chartreuse;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #D2691E.
/// </summary>
public static readonly Color32 Chocolate = NamedColors<Color32>.Chocolate;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #FF7F50.
/// </summary>
public static readonly Color32 Coral = NamedColors<Color32>.Coral;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #6495ED.
/// </summary>
public static readonly Color32 CornflowerBlue = NamedColors<Color32>.CornflowerBlue;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #FFF8DC.
/// </summary>
public static readonly Color32 Cornsilk = NamedColors<Color32>.Cornsilk;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #DC143C.
/// </summary>
public static readonly Color32 Crimson = NamedColors<Color32>.Crimson;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #00FFFF.
/// </summary>
public static readonly Color32 Cyan = NamedColors<Color32>.Cyan;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #00008B.
/// </summary>
public static readonly Color32 DarkBlue = NamedColors<Color32>.DarkBlue;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #008B8B.
/// </summary>
public static readonly Color32 DarkCyan = NamedColors<Color32>.DarkCyan;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #B8860B.
/// </summary>
public static readonly Color32 DarkGoldenrod = NamedColors<Color32>.DarkGoldenrod;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #A9A9A9.
/// </summary>
public static readonly Color32 DarkGray = NamedColors<Color32>.DarkGray;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #006400.
/// </summary>
public static readonly Color32 DarkGreen = NamedColors<Color32>.DarkGreen;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #BDB76B.
/// </summary>
public static readonly Color32 DarkKhaki = NamedColors<Color32>.DarkKhaki;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #8B008B.
/// </summary>
public static readonly Color32 DarkMagenta = NamedColors<Color32>.DarkMagenta;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #556B2F.
/// </summary>
public static readonly Color32 DarkOliveGreen = NamedColors<Color32>.DarkOliveGreen;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #FF8C00.
/// </summary>
public static readonly Color32 DarkOrange = NamedColors<Color32>.DarkOrange;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #9932CC.
/// </summary>
public static readonly Color32 DarkOrchid = NamedColors<Color32>.DarkOrchid;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #8B0000.
/// </summary>
public static readonly Color32 DarkRed = NamedColors<Color32>.DarkRed;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #E9967A.
/// </summary>
public static readonly Color32 DarkSalmon = NamedColors<Color32>.DarkSalmon;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #8FBC8B.
/// </summary>
public static readonly Color32 DarkSeaGreen = NamedColors<Color32>.DarkSeaGreen;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #483D8B.
/// </summary>
public static readonly Color32 DarkSlateBlue = NamedColors<Color32>.DarkSlateBlue;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #2F4F4F.
/// </summary>
public static readonly Color32 DarkSlateGray = NamedColors<Color32>.DarkSlateGray;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #00CED1.
/// </summary>
public static readonly Color32 DarkTurquoise = NamedColors<Color32>.DarkTurquoise;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #9400D3.
/// </summary>
public static readonly Color32 DarkViolet = NamedColors<Color32>.DarkViolet;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #FF1493.
/// </summary>
public static readonly Color32 DeepPink = NamedColors<Color32>.DeepPink;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #00BFFF.
/// </summary>
public static readonly Color32 DeepSkyBlue = NamedColors<Color32>.DeepSkyBlue;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #696969.
/// </summary>
public static readonly Color32 DimGray = NamedColors<Color32>.DimGray;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #1E90FF.
/// </summary>
public static readonly Color32 DodgerBlue = NamedColors<Color32>.DodgerBlue;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #B22222.
/// </summary>
public static readonly Color32 Firebrick = NamedColors<Color32>.Firebrick;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #FFFAF0.
/// </summary>
public static readonly Color32 FloralWhite = NamedColors<Color32>.FloralWhite;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #228B22.
/// </summary>
public static readonly Color32 ForestGreen = NamedColors<Color32>.ForestGreen;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #FF00FF.
/// </summary>
public static readonly Color32 Fuchsia = NamedColors<Color32>.Fuchsia;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #DCDCDC.
/// </summary>
public static readonly Color32 Gainsboro = NamedColors<Color32>.Gainsboro;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #F8F8FF.
/// </summary>
public static readonly Color32 GhostWhite = NamedColors<Color32>.GhostWhite;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #FFD700.
/// </summary>
public static readonly Color32 Gold = NamedColors<Color32>.Gold;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #DAA520.
/// </summary>
public static readonly Color32 Goldenrod = NamedColors<Color32>.Goldenrod;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #808080.
/// </summary>
public static readonly Color32 Gray = NamedColors<Color32>.Gray;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #008000.
/// </summary>
public static readonly Color32 Green = NamedColors<Color32>.Green;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #ADFF2F.
/// </summary>
public static readonly Color32 GreenYellow = NamedColors<Color32>.GreenYellow;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #F0FFF0.
/// </summary>
public static readonly Color32 Honeydew = NamedColors<Color32>.Honeydew;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #FF69B4.
/// </summary>
public static readonly Color32 HotPink = NamedColors<Color32>.HotPink;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #CD5C5C.
/// </summary>
public static readonly Color32 IndianRed = NamedColors<Color32>.IndianRed;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #4B0082.
/// </summary>
public static readonly Color32 Indigo = NamedColors<Color32>.Indigo;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #FFFFF0.
/// </summary>
public static readonly Color32 Ivory = NamedColors<Color32>.Ivory;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #F0E68C.
/// </summary>
public static readonly Color32 Khaki = NamedColors<Color32>.Khaki;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #E6E6FA.
/// </summary>
public static readonly Color32 Lavender = NamedColors<Color32>.Lavender;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #FFF0F5.
/// </summary>
public static readonly Color32 LavenderBlush = NamedColors<Color32>.LavenderBlush;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #7CFC00.
/// </summary>
public static readonly Color32 LawnGreen = NamedColors<Color32>.LawnGreen;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #FFFACD.
/// </summary>
public static readonly Color32 LemonChiffon = NamedColors<Color32>.LemonChiffon;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #ADD8E6.
/// </summary>
public static readonly Color32 LightBlue = NamedColors<Color32>.LightBlue;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #F08080.
/// </summary>
public static readonly Color32 LightCoral = NamedColors<Color32>.LightCoral;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #E0FFFF.
/// </summary>
public static readonly Color32 LightCyan = NamedColors<Color32>.LightCyan;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #FAFAD2.
/// </summary>
public static readonly Color32 LightGoldenrodYellow = NamedColors<Color32>.LightGoldenrodYellow;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #D3D3D3.
/// </summary>
public static readonly Color32 LightGray = NamedColors<Color32>.LightGray;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #90EE90.
/// </summary>
public static readonly Color32 LightGreen = NamedColors<Color32>.LightGreen;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #FFB6C1.
/// </summary>
public static readonly Color32 LightPink = NamedColors<Color32>.LightPink;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #FFA07A.
/// </summary>
public static readonly Color32 LightSalmon = NamedColors<Color32>.LightSalmon;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #20B2AA.
/// </summary>
public static readonly Color32 LightSeaGreen = NamedColors<Color32>.LightSeaGreen;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #87CEFA.
/// </summary>
public static readonly Color32 LightSkyBlue = NamedColors<Color32>.LightSkyBlue;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #778899.
/// </summary>
public static readonly Color32 LightSlateGray = NamedColors<Color32>.LightSlateGray;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #B0C4DE.
/// </summary>
public static readonly Color32 LightSteelBlue = NamedColors<Color32>.LightSteelBlue;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #FFFFE0.
/// </summary>
public static readonly Color32 LightYellow = NamedColors<Color32>.LightYellow;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #00FF00.
/// </summary>
public static readonly Color32 Lime = NamedColors<Color32>.Lime;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #32CD32.
/// </summary>
public static readonly Color32 LimeGreen = NamedColors<Color32>.LimeGreen;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #FAF0E6.
/// </summary>
public static readonly Color32 Linen = NamedColors<Color32>.Linen;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #FF00FF.
/// </summary>
public static readonly Color32 Magenta = NamedColors<Color32>.Magenta;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #800000.
/// </summary>
public static readonly Color32 Maroon = NamedColors<Color32>.Maroon;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #66CDAA.
/// </summary>
public static readonly Color32 MediumAquamarine = NamedColors<Color32>.MediumAquamarine;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #0000CD.
/// </summary>
public static readonly Color32 MediumBlue = NamedColors<Color32>.MediumBlue;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #BA55D3.
/// </summary>
public static readonly Color32 MediumOrchid = NamedColors<Color32>.MediumOrchid;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #9370DB.
/// </summary>
public static readonly Color32 MediumPurple = NamedColors<Color32>.MediumPurple;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #3CB371.
/// </summary>
public static readonly Color32 MediumSeaGreen = NamedColors<Color32>.MediumSeaGreen;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #7B68EE.
/// </summary>
public static readonly Color32 MediumSlateBlue = NamedColors<Color32>.MediumSlateBlue;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #00FA9A.
/// </summary>
public static readonly Color32 MediumSpringGreen = NamedColors<Color32>.MediumSpringGreen;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #48D1CC.
/// </summary>
public static readonly Color32 MediumTurquoise = NamedColors<Color32>.MediumTurquoise;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #C71585.
/// </summary>
public static readonly Color32 MediumVioletRed = NamedColors<Color32>.MediumVioletRed;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #191970.
/// </summary>
public static readonly Color32 MidnightBlue = NamedColors<Color32>.MidnightBlue;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #F5FFFA.
/// </summary>
public static readonly Color32 MintCream = NamedColors<Color32>.MintCream;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #FFE4E1.
/// </summary>
public static readonly Color32 MistyRose = NamedColors<Color32>.MistyRose;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #FFE4B5.
/// </summary>
public static readonly Color32 Moccasin = NamedColors<Color32>.Moccasin;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #FFDEAD.
/// </summary>
public static readonly Color32 NavajoWhite = NamedColors<Color32>.NavajoWhite;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #000080.
/// </summary>
public static readonly Color32 Navy = NamedColors<Color32>.Navy;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #FDF5E6.
/// </summary>
public static readonly Color32 OldLace = NamedColors<Color32>.OldLace;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #808000.
/// </summary>
public static readonly Color32 Olive = NamedColors<Color32>.Olive;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #6B8E23.
/// </summary>
public static readonly Color32 OliveDrab = NamedColors<Color32>.OliveDrab;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #FFA500.
/// </summary>
public static readonly Color32 Orange = NamedColors<Color32>.Orange;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #FF4500.
/// </summary>
public static readonly Color32 OrangeRed = NamedColors<Color32>.OrangeRed;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #DA70D6.
/// </summary>
public static readonly Color32 Orchid = NamedColors<Color32>.Orchid;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #EEE8AA.
/// </summary>
public static readonly Color32 PaleGoldenrod = NamedColors<Color32>.PaleGoldenrod;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #98FB98.
/// </summary>
public static readonly Color32 PaleGreen = NamedColors<Color32>.PaleGreen;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #AFEEEE.
/// </summary>
public static readonly Color32 PaleTurquoise = NamedColors<Color32>.PaleTurquoise;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #DB7093.
/// </summary>
public static readonly Color32 PaleVioletRed = NamedColors<Color32>.PaleVioletRed;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #FFEFD5.
/// </summary>
public static readonly Color32 PapayaWhip = NamedColors<Color32>.PapayaWhip;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #FFDAB9.
/// </summary>
public static readonly Color32 PeachPuff = NamedColors<Color32>.PeachPuff;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #CD853F.
/// </summary>
public static readonly Color32 Peru = NamedColors<Color32>.Peru;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #FFC0CB.
/// </summary>
public static readonly Color32 Pink = NamedColors<Color32>.Pink;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #DDA0DD.
/// </summary>
public static readonly Color32 Plum = NamedColors<Color32>.Plum;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #B0E0E6.
/// </summary>
public static readonly Color32 PowderBlue = NamedColors<Color32>.PowderBlue;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #800080.
/// </summary>
public static readonly Color32 Purple = NamedColors<Color32>.Purple;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #663399.
/// </summary>
public static readonly Color32 RebeccaPurple = NamedColors<Color32>.RebeccaPurple;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #FF0000.
/// </summary>
public static readonly Color32 Red = NamedColors<Color32>.Red;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #BC8F8F.
/// </summary>
public static readonly Color32 RosyBrown = NamedColors<Color32>.RosyBrown;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #4169E1.
/// </summary>
public static readonly Color32 RoyalBlue = NamedColors<Color32>.RoyalBlue;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #8B4513.
/// </summary>
public static readonly Color32 SaddleBrown = NamedColors<Color32>.SaddleBrown;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #FA8072.
/// </summary>
public static readonly Color32 Salmon = NamedColors<Color32>.Salmon;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #F4A460.
/// </summary>
public static readonly Color32 SandyBrown = NamedColors<Color32>.SandyBrown;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #2E8B57.
/// </summary>
public static readonly Color32 SeaGreen = NamedColors<Color32>.SeaGreen;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #FFF5EE.
/// </summary>
public static readonly Color32 SeaShell = NamedColors<Color32>.SeaShell;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #A0522D.
/// </summary>
public static readonly Color32 Sienna = NamedColors<Color32>.Sienna;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #C0C0C0.
/// </summary>
public static readonly Color32 Silver = NamedColors<Color32>.Silver;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #87CEEB.
/// </summary>
public static readonly Color32 SkyBlue = NamedColors<Color32>.SkyBlue;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #6A5ACD.
/// </summary>
public static readonly Color32 SlateBlue = NamedColors<Color32>.SlateBlue;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #708090.
/// </summary>
public static readonly Color32 SlateGray = NamedColors<Color32>.SlateGray;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #FFFAFA.
/// </summary>
public static readonly Color32 Snow = NamedColors<Color32>.Snow;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #00FF7F.
/// </summary>
public static readonly Color32 SpringGreen = NamedColors<Color32>.SpringGreen;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #4682B4.
/// </summary>
public static readonly Color32 SteelBlue = NamedColors<Color32>.SteelBlue;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #D2B48C.
/// </summary>
public static readonly Color32 Tan = NamedColors<Color32>.Tan;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #008080.
/// </summary>
public static readonly Color32 Teal = NamedColors<Color32>.Teal;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #D8BFD8.
/// </summary>
public static readonly Color32 Thistle = NamedColors<Color32>.Thistle;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #FF6347.
/// </summary>
public static readonly Color32 Tomato = NamedColors<Color32>.Tomato;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #FFFFFF.
/// </summary>
public static readonly Color32 Transparent = NamedColors<Color32>.Transparent;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #40E0D0.
/// </summary>
public static readonly Color32 Turquoise = NamedColors<Color32>.Turquoise;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #EE82EE.
/// </summary>
public static readonly Color32 Violet = NamedColors<Color32>.Violet;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #F5DEB3.
/// </summary>
public static readonly Color32 Wheat = NamedColors<Color32>.Wheat;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #FFFFFF.
/// </summary>
public static readonly Color32 White = NamedColors<Color32>.White;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #F5F5F5.
/// </summary>
public static readonly Color32 WhiteSmoke = NamedColors<Color32>.WhiteSmoke;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #FFFF00.
/// </summary>
public static readonly Color32 Yellow = NamedColors<Color32>.Yellow;
/// <summary>
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #9ACD32.
/// </summary>
public static readonly Color32 YellowGreen = NamedColors<Color32>.YellowGreen;
}
}

179
src/ImageSharp/Colors/ColorConstants.cs

@ -1,179 +0,0 @@
// <copyright file="ColorConstants.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp
{
using System;
using System.Collections.Generic;
/// <summary>
/// Provides useful color definitions.
/// </summary>
public static class ColorConstants
{
/// <summary>
/// Provides a lazy, one time method of returning the colors.
/// </summary>
private static readonly Lazy<Color[]> SafeColors = new Lazy<Color[]>(GetWebSafeColors);
/// <summary>
/// Gets a collection of named, web safe, colors as defined in the CSS Color Module Level 4.
/// </summary>
public static Color[] WebSafeColors => SafeColors.Value;
/// <summary>
/// Returns an array of web safe colors.
/// </summary>
/// <returns>The <see cref="T:Color[]"/></returns>
private static Color[] GetWebSafeColors()
{
return new List<Color>
{
Color.AliceBlue,
Color.AntiqueWhite,
Color.Aqua,
Color.Aquamarine,
Color.Azure,
Color.Beige,
Color.Bisque,
Color.Black,
Color.BlanchedAlmond,
Color.Blue,
Color.BlueViolet,
Color.Brown,
Color.BurlyWood,
Color.CadetBlue,
Color.Chartreuse,
Color.Chocolate,
Color.Coral,
Color.CornflowerBlue,
Color.Cornsilk,
Color.Crimson,
Color.Cyan,
Color.DarkBlue,
Color.DarkCyan,
Color.DarkGoldenrod,
Color.DarkGray,
Color.DarkGreen,
Color.DarkKhaki,
Color.DarkMagenta,
Color.DarkOliveGreen,
Color.DarkOrange,
Color.DarkOrchid,
Color.DarkRed,
Color.DarkSalmon,
Color.DarkSeaGreen,
Color.DarkSlateBlue,
Color.DarkSlateGray,
Color.DarkTurquoise,
Color.DarkViolet,
Color.DeepPink,
Color.DeepSkyBlue,
Color.DimGray,
Color.DodgerBlue,
Color.Firebrick,
Color.FloralWhite,
Color.ForestGreen,
Color.Fuchsia,
Color.Gainsboro,
Color.GhostWhite,
Color.Gold,
Color.Goldenrod,
Color.Gray,
Color.Green,
Color.GreenYellow,
Color.Honeydew,
Color.HotPink,
Color.IndianRed,
Color.Indigo,
Color.Ivory,
Color.Khaki,
Color.Lavender,
Color.LavenderBlush,
Color.LawnGreen,
Color.LemonChiffon,
Color.LightBlue,
Color.LightCoral,
Color.LightCyan,
Color.LightGoldenrodYellow,
Color.LightGray,
Color.LightGreen,
Color.LightPink,
Color.LightSalmon,
Color.LightSeaGreen,
Color.LightSkyBlue,
Color.LightSlateGray,
Color.LightSteelBlue,
Color.LightYellow,
Color.Lime,
Color.LimeGreen,
Color.Linen,
Color.Magenta,
Color.Maroon,
Color.MediumAquamarine,
Color.MediumBlue,
Color.MediumOrchid,
Color.MediumPurple,
Color.MediumSeaGreen,
Color.MediumSlateBlue,
Color.MediumSpringGreen,
Color.MediumTurquoise,
Color.MediumVioletRed,
Color.MidnightBlue,
Color.MintCream,
Color.MistyRose,
Color.Moccasin,
Color.NavajoWhite,
Color.Navy,
Color.OldLace,
Color.Olive,
Color.OliveDrab,
Color.Orange,
Color.OrangeRed,
Color.Orchid,
Color.PaleGoldenrod,
Color.PaleGreen,
Color.PaleTurquoise,
Color.PaleVioletRed,
Color.PapayaWhip,
Color.PeachPuff,
Color.Peru,
Color.Pink,
Color.Plum,
Color.PowderBlue,
Color.Purple,
Color.RebeccaPurple,
Color.Red,
Color.RosyBrown,
Color.RoyalBlue,
Color.SaddleBrown,
Color.Salmon,
Color.SandyBrown,
Color.SeaGreen,
Color.SeaShell,
Color.Sienna,
Color.Silver,
Color.SkyBlue,
Color.SlateBlue,
Color.SlateGray,
Color.Snow,
Color.SpringGreen,
Color.SteelBlue,
Color.Tan,
Color.Teal,
Color.Thistle,
Color.Tomato,
Color.Transparent,
Color.Turquoise,
Color.Violet,
Color.Wheat,
Color.White,
Color.WhiteSmoke,
Color.Yellow,
Color.YellowGreen
}.ToArray();
}
}
}

728
src/ImageSharp/Colors/ColorDefinitions.cs

@ -1,728 +0,0 @@
// <copyright file="ColorDefinitions.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp
{
/// <summary>
/// Packed vector type containing four 8-bit unsigned normalized values ranging from 0 to 255.
/// The color components are stored in red, green, blue, and alpha order.
/// </summary>
/// <remarks>
/// This struct is fully mutable. This is done (against the guidelines) for the sake of performance,
/// as it avoids the need to create new values for modification operations.
/// </remarks>
public partial struct Color
{
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #F0F8FF.
/// </summary>
public static readonly Color AliceBlue = NamedColors<Color>.AliceBlue;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #FAEBD7.
/// </summary>
public static readonly Color AntiqueWhite = NamedColors<Color>.AntiqueWhite;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #00FFFF.
/// </summary>
public static readonly Color Aqua = NamedColors<Color>.Aqua;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #7FFFD4.
/// </summary>
public static readonly Color Aquamarine = NamedColors<Color>.Aquamarine;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #F0FFFF.
/// </summary>
public static readonly Color Azure = NamedColors<Color>.Azure;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #F5F5DC.
/// </summary>
public static readonly Color Beige = NamedColors<Color>.Beige;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #FFE4C4.
/// </summary>
public static readonly Color Bisque = NamedColors<Color>.Bisque;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #000000.
/// </summary>
public static readonly Color Black = NamedColors<Color>.Black;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #FFEBCD.
/// </summary>
public static readonly Color BlanchedAlmond = NamedColors<Color>.BlanchedAlmond;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #0000FF.
/// </summary>
public static readonly Color Blue = NamedColors<Color>.Blue;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #8A2BE2.
/// </summary>
public static readonly Color BlueViolet = NamedColors<Color>.BlueViolet;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #A52A2A.
/// </summary>
public static readonly Color Brown = NamedColors<Color>.Brown;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #DEB887.
/// </summary>
public static readonly Color BurlyWood = NamedColors<Color>.BurlyWood;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #5F9EA0.
/// </summary>
public static readonly Color CadetBlue = NamedColors<Color>.CadetBlue;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #7FFF00.
/// </summary>
public static readonly Color Chartreuse = NamedColors<Color>.Chartreuse;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #D2691E.
/// </summary>
public static readonly Color Chocolate = NamedColors<Color>.Chocolate;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #FF7F50.
/// </summary>
public static readonly Color Coral = NamedColors<Color>.Coral;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #6495ED.
/// </summary>
public static readonly Color CornflowerBlue = NamedColors<Color>.CornflowerBlue;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #FFF8DC.
/// </summary>
public static readonly Color Cornsilk = NamedColors<Color>.Cornsilk;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #DC143C.
/// </summary>
public static readonly Color Crimson = NamedColors<Color>.Crimson;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #00FFFF.
/// </summary>
public static readonly Color Cyan = NamedColors<Color>.Cyan;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #00008B.
/// </summary>
public static readonly Color DarkBlue = NamedColors<Color>.DarkBlue;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #008B8B.
/// </summary>
public static readonly Color DarkCyan = NamedColors<Color>.DarkCyan;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #B8860B.
/// </summary>
public static readonly Color DarkGoldenrod = NamedColors<Color>.DarkGoldenrod;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #A9A9A9.
/// </summary>
public static readonly Color DarkGray = NamedColors<Color>.DarkGray;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #006400.
/// </summary>
public static readonly Color DarkGreen = NamedColors<Color>.DarkGreen;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #BDB76B.
/// </summary>
public static readonly Color DarkKhaki = NamedColors<Color>.DarkKhaki;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #8B008B.
/// </summary>
public static readonly Color DarkMagenta = NamedColors<Color>.DarkMagenta;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #556B2F.
/// </summary>
public static readonly Color DarkOliveGreen = NamedColors<Color>.DarkOliveGreen;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #FF8C00.
/// </summary>
public static readonly Color DarkOrange = NamedColors<Color>.DarkOrange;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #9932CC.
/// </summary>
public static readonly Color DarkOrchid = NamedColors<Color>.DarkOrchid;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #8B0000.
/// </summary>
public static readonly Color DarkRed = NamedColors<Color>.DarkRed;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #E9967A.
/// </summary>
public static readonly Color DarkSalmon = NamedColors<Color>.DarkSalmon;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #8FBC8B.
/// </summary>
public static readonly Color DarkSeaGreen = NamedColors<Color>.DarkSeaGreen;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #483D8B.
/// </summary>
public static readonly Color DarkSlateBlue = NamedColors<Color>.DarkSlateBlue;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #2F4F4F.
/// </summary>
public static readonly Color DarkSlateGray = NamedColors<Color>.DarkSlateGray;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #00CED1.
/// </summary>
public static readonly Color DarkTurquoise = NamedColors<Color>.DarkTurquoise;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #9400D3.
/// </summary>
public static readonly Color DarkViolet = NamedColors<Color>.DarkViolet;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #FF1493.
/// </summary>
public static readonly Color DeepPink = NamedColors<Color>.DeepPink;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #00BFFF.
/// </summary>
public static readonly Color DeepSkyBlue = NamedColors<Color>.DeepSkyBlue;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #696969.
/// </summary>
public static readonly Color DimGray = NamedColors<Color>.DimGray;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #1E90FF.
/// </summary>
public static readonly Color DodgerBlue = NamedColors<Color>.DodgerBlue;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #B22222.
/// </summary>
public static readonly Color Firebrick = NamedColors<Color>.Firebrick;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #FFFAF0.
/// </summary>
public static readonly Color FloralWhite = NamedColors<Color>.FloralWhite;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #228B22.
/// </summary>
public static readonly Color ForestGreen = NamedColors<Color>.ForestGreen;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #FF00FF.
/// </summary>
public static readonly Color Fuchsia = NamedColors<Color>.Fuchsia;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #DCDCDC.
/// </summary>
public static readonly Color Gainsboro = NamedColors<Color>.Gainsboro;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #F8F8FF.
/// </summary>
public static readonly Color GhostWhite = NamedColors<Color>.GhostWhite;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #FFD700.
/// </summary>
public static readonly Color Gold = NamedColors<Color>.Gold;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #DAA520.
/// </summary>
public static readonly Color Goldenrod = NamedColors<Color>.Goldenrod;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #808080.
/// </summary>
public static readonly Color Gray = NamedColors<Color>.Gray;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #008000.
/// </summary>
public static readonly Color Green = NamedColors<Color>.Green;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #ADFF2F.
/// </summary>
public static readonly Color GreenYellow = NamedColors<Color>.GreenYellow;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #F0FFF0.
/// </summary>
public static readonly Color Honeydew = NamedColors<Color>.Honeydew;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #FF69B4.
/// </summary>
public static readonly Color HotPink = NamedColors<Color>.HotPink;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #CD5C5C.
/// </summary>
public static readonly Color IndianRed = NamedColors<Color>.IndianRed;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #4B0082.
/// </summary>
public static readonly Color Indigo = NamedColors<Color>.Indigo;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #FFFFF0.
/// </summary>
public static readonly Color Ivory = NamedColors<Color>.Ivory;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #F0E68C.
/// </summary>
public static readonly Color Khaki = NamedColors<Color>.Khaki;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #E6E6FA.
/// </summary>
public static readonly Color Lavender = NamedColors<Color>.Lavender;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #FFF0F5.
/// </summary>
public static readonly Color LavenderBlush = NamedColors<Color>.LavenderBlush;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #7CFC00.
/// </summary>
public static readonly Color LawnGreen = NamedColors<Color>.LawnGreen;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #FFFACD.
/// </summary>
public static readonly Color LemonChiffon = NamedColors<Color>.LemonChiffon;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #ADD8E6.
/// </summary>
public static readonly Color LightBlue = NamedColors<Color>.LightBlue;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #F08080.
/// </summary>
public static readonly Color LightCoral = NamedColors<Color>.LightCoral;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #E0FFFF.
/// </summary>
public static readonly Color LightCyan = NamedColors<Color>.LightCyan;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #FAFAD2.
/// </summary>
public static readonly Color LightGoldenrodYellow = NamedColors<Color>.LightGoldenrodYellow;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #D3D3D3.
/// </summary>
public static readonly Color LightGray = NamedColors<Color>.LightGray;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #90EE90.
/// </summary>
public static readonly Color LightGreen = NamedColors<Color>.LightGreen;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #FFB6C1.
/// </summary>
public static readonly Color LightPink = NamedColors<Color>.LightPink;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #FFA07A.
/// </summary>
public static readonly Color LightSalmon = NamedColors<Color>.LightSalmon;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #20B2AA.
/// </summary>
public static readonly Color LightSeaGreen = NamedColors<Color>.LightSeaGreen;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #87CEFA.
/// </summary>
public static readonly Color LightSkyBlue = NamedColors<Color>.LightSkyBlue;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #778899.
/// </summary>
public static readonly Color LightSlateGray = NamedColors<Color>.LightSlateGray;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #B0C4DE.
/// </summary>
public static readonly Color LightSteelBlue = NamedColors<Color>.LightSteelBlue;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #FFFFE0.
/// </summary>
public static readonly Color LightYellow = NamedColors<Color>.LightYellow;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #00FF00.
/// </summary>
public static readonly Color Lime = NamedColors<Color>.Lime;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #32CD32.
/// </summary>
public static readonly Color LimeGreen = NamedColors<Color>.LimeGreen;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #FAF0E6.
/// </summary>
public static readonly Color Linen = NamedColors<Color>.Linen;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #FF00FF.
/// </summary>
public static readonly Color Magenta = NamedColors<Color>.Magenta;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #800000.
/// </summary>
public static readonly Color Maroon = NamedColors<Color>.Maroon;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #66CDAA.
/// </summary>
public static readonly Color MediumAquamarine = NamedColors<Color>.MediumAquamarine;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #0000CD.
/// </summary>
public static readonly Color MediumBlue = NamedColors<Color>.MediumBlue;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #BA55D3.
/// </summary>
public static readonly Color MediumOrchid = NamedColors<Color>.MediumOrchid;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #9370DB.
/// </summary>
public static readonly Color MediumPurple = NamedColors<Color>.MediumPurple;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #3CB371.
/// </summary>
public static readonly Color MediumSeaGreen = NamedColors<Color>.MediumSeaGreen;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #7B68EE.
/// </summary>
public static readonly Color MediumSlateBlue = NamedColors<Color>.MediumSlateBlue;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #00FA9A.
/// </summary>
public static readonly Color MediumSpringGreen = NamedColors<Color>.MediumSpringGreen;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #48D1CC.
/// </summary>
public static readonly Color MediumTurquoise = NamedColors<Color>.MediumTurquoise;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #C71585.
/// </summary>
public static readonly Color MediumVioletRed = NamedColors<Color>.MediumVioletRed;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #191970.
/// </summary>
public static readonly Color MidnightBlue = NamedColors<Color>.MidnightBlue;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #F5FFFA.
/// </summary>
public static readonly Color MintCream = NamedColors<Color>.MintCream;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #FFE4E1.
/// </summary>
public static readonly Color MistyRose = NamedColors<Color>.MistyRose;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #FFE4B5.
/// </summary>
public static readonly Color Moccasin = NamedColors<Color>.Moccasin;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #FFDEAD.
/// </summary>
public static readonly Color NavajoWhite = NamedColors<Color>.NavajoWhite;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #000080.
/// </summary>
public static readonly Color Navy = NamedColors<Color>.Navy;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #FDF5E6.
/// </summary>
public static readonly Color OldLace = NamedColors<Color>.OldLace;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #808000.
/// </summary>
public static readonly Color Olive = NamedColors<Color>.Olive;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #6B8E23.
/// </summary>
public static readonly Color OliveDrab = NamedColors<Color>.OliveDrab;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #FFA500.
/// </summary>
public static readonly Color Orange = NamedColors<Color>.Orange;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #FF4500.
/// </summary>
public static readonly Color OrangeRed = NamedColors<Color>.OrangeRed;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #DA70D6.
/// </summary>
public static readonly Color Orchid = NamedColors<Color>.Orchid;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #EEE8AA.
/// </summary>
public static readonly Color PaleGoldenrod = NamedColors<Color>.PaleGoldenrod;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #98FB98.
/// </summary>
public static readonly Color PaleGreen = NamedColors<Color>.PaleGreen;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #AFEEEE.
/// </summary>
public static readonly Color PaleTurquoise = NamedColors<Color>.PaleTurquoise;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #DB7093.
/// </summary>
public static readonly Color PaleVioletRed = NamedColors<Color>.PaleVioletRed;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #FFEFD5.
/// </summary>
public static readonly Color PapayaWhip = NamedColors<Color>.PapayaWhip;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #FFDAB9.
/// </summary>
public static readonly Color PeachPuff = NamedColors<Color>.PeachPuff;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #CD853F.
/// </summary>
public static readonly Color Peru = NamedColors<Color>.Peru;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #FFC0CB.
/// </summary>
public static readonly Color Pink = NamedColors<Color>.Pink;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #DDA0DD.
/// </summary>
public static readonly Color Plum = NamedColors<Color>.Plum;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #B0E0E6.
/// </summary>
public static readonly Color PowderBlue = NamedColors<Color>.PowderBlue;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #800080.
/// </summary>
public static readonly Color Purple = NamedColors<Color>.Purple;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #663399.
/// </summary>
public static readonly Color RebeccaPurple = NamedColors<Color>.RebeccaPurple;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #FF0000.
/// </summary>
public static readonly Color Red = NamedColors<Color>.Red;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #BC8F8F.
/// </summary>
public static readonly Color RosyBrown = NamedColors<Color>.RosyBrown;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #4169E1.
/// </summary>
public static readonly Color RoyalBlue = NamedColors<Color>.RoyalBlue;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #8B4513.
/// </summary>
public static readonly Color SaddleBrown = NamedColors<Color>.SaddleBrown;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #FA8072.
/// </summary>
public static readonly Color Salmon = NamedColors<Color>.Salmon;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #F4A460.
/// </summary>
public static readonly Color SandyBrown = NamedColors<Color>.SandyBrown;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #2E8B57.
/// </summary>
public static readonly Color SeaGreen = NamedColors<Color>.SeaGreen;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #FFF5EE.
/// </summary>
public static readonly Color SeaShell = NamedColors<Color>.SeaShell;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #A0522D.
/// </summary>
public static readonly Color Sienna = NamedColors<Color>.Sienna;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #C0C0C0.
/// </summary>
public static readonly Color Silver = NamedColors<Color>.Silver;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #87CEEB.
/// </summary>
public static readonly Color SkyBlue = NamedColors<Color>.SkyBlue;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #6A5ACD.
/// </summary>
public static readonly Color SlateBlue = NamedColors<Color>.SlateBlue;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #708090.
/// </summary>
public static readonly Color SlateGray = NamedColors<Color>.SlateGray;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #FFFAFA.
/// </summary>
public static readonly Color Snow = NamedColors<Color>.Snow;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #00FF7F.
/// </summary>
public static readonly Color SpringGreen = NamedColors<Color>.SpringGreen;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #4682B4.
/// </summary>
public static readonly Color SteelBlue = NamedColors<Color>.SteelBlue;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #D2B48C.
/// </summary>
public static readonly Color Tan = NamedColors<Color>.Tan;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #008080.
/// </summary>
public static readonly Color Teal = NamedColors<Color>.Teal;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #D8BFD8.
/// </summary>
public static readonly Color Thistle = NamedColors<Color>.Thistle;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #FF6347.
/// </summary>
public static readonly Color Tomato = NamedColors<Color>.Tomato;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #FFFFFF.
/// </summary>
public static readonly Color Transparent = NamedColors<Color>.Transparent;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #40E0D0.
/// </summary>
public static readonly Color Turquoise = NamedColors<Color>.Turquoise;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #EE82EE.
/// </summary>
public static readonly Color Violet = NamedColors<Color>.Violet;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #F5DEB3.
/// </summary>
public static readonly Color Wheat = NamedColors<Color>.Wheat;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #FFFFFF.
/// </summary>
public static readonly Color White = NamedColors<Color>.White;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #F5F5F5.
/// </summary>
public static readonly Color WhiteSmoke = NamedColors<Color>.WhiteSmoke;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #FFFF00.
/// </summary>
public static readonly Color Yellow = NamedColors<Color>.Yellow;
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #9ACD32.
/// </summary>
public static readonly Color YellowGreen = NamedColors<Color>.YellowGreen;
}
}

60
src/ImageSharp/Colors/ColorspaceTransforms.cs

@ -17,46 +17,46 @@ namespace ImageSharp
/// This struct is fully mutable. This is done (against the guidelines) for the sake of performance,
/// as it avoids the need to create new values for modification operations.
/// </remarks>
public partial struct Color
public partial struct Color32
{
/// <summary>
/// Allows the implicit conversion of an instance of <see cref="Color"/> to a
/// Allows the implicit conversion of an instance of <see cref="Color32"/> to a
/// <see cref="Bgra32"/>.
/// </summary>
/// <param name="color">The instance of <see cref="Color"/> to convert.</param>
/// <param name="color">The instance of <see cref="Color32"/> to convert.</param>
/// <returns>
/// An instance of <see cref="Bgra32"/>.
/// </returns>
public static implicit operator Color(Bgra32 color)
public static implicit operator Color32(Bgra32 color)
{
return new Color(color.R, color.G, color.B, color.A);
return new Color32(color.R, color.G, color.B, color.A);
}
/// <summary>
/// Allows the implicit conversion of an instance of <see cref="Cmyk"/> to a
/// <see cref="Color"/>.
/// <see cref="Color32"/>.
/// </summary>
/// <param name="cmykColor">The instance of <see cref="Cmyk"/> to convert.</param>
/// <returns>
/// An instance of <see cref="Color"/>.
/// An instance of <see cref="Color32"/>.
/// </returns>
public static implicit operator Color(Cmyk cmykColor)
public static implicit operator Color32(Cmyk cmykColor)
{
float r = (1 - cmykColor.C) * (1 - cmykColor.K);
float g = (1 - cmykColor.M) * (1 - cmykColor.K);
float b = (1 - cmykColor.Y) * (1 - cmykColor.K);
return new Color(r, g, b, 1);
return new Color32(r, g, b, 1);
}
/// <summary>
/// Allows the implicit conversion of an instance of <see cref="YCbCr"/> to a
/// <see cref="Color"/>.
/// <see cref="Color32"/>.
/// </summary>
/// <param name="color">The instance of <see cref="YCbCr"/> to convert.</param>
/// <returns>
/// An instance of <see cref="Color"/>.
/// An instance of <see cref="Color32"/>.
/// </returns>
public static implicit operator Color(YCbCr color)
public static implicit operator Color32(YCbCr color)
{
float y = color.Y;
float cb = color.Cb - 128;
@ -66,18 +66,18 @@ namespace ImageSharp
byte g = (byte)(y - (0.34414F * cb) - (0.71414F * cr)).Clamp(0, 255);
byte b = (byte)(y + (1.772F * cb)).Clamp(0, 255);
return new Color(r, g, b);
return new Color32(r, g, b);
}
/// <summary>
/// Allows the implicit conversion of an instance of <see cref="CieXyz"/> to a
/// <see cref="Color"/>.
/// <see cref="Color32"/>.
/// </summary>
/// <param name="color">The instance of <see cref="CieXyz"/> to convert.</param>
/// <returns>
/// An instance of <see cref="Color"/>.
/// An instance of <see cref="Color32"/>.
/// </returns>
public static implicit operator Color(CieXyz color)
public static implicit operator Color32(CieXyz color)
{
float x = color.X / 100F;
float y = color.Y / 100F;
@ -89,25 +89,25 @@ namespace ImageSharp
float b = (x * 0.0557F) + (y * -0.2040F) + (z * 1.0570F);
Vector4 vector = new Vector4(r, g, b, 1).Compress();
return new Color(vector);
return new Color32(vector);
}
/// <summary>
/// Allows the implicit conversion of an instance of <see cref="Hsv"/> to a
/// <see cref="Color"/>.
/// <see cref="Color32"/>.
/// </summary>
/// <param name="color">The instance of <see cref="Hsv"/> to convert.</param>
/// <returns>
/// An instance of <see cref="Color"/>.
/// An instance of <see cref="Color32"/>.
/// </returns>
public static implicit operator Color(Hsv color)
public static implicit operator Color32(Hsv color)
{
float s = color.S;
float v = color.V;
if (MathF.Abs(s) < Constants.Epsilon)
{
return new Color(v, v, v, 1);
return new Color32(v, v, v, 1);
}
float h = (MathF.Abs(color.H - 360) < Constants.Epsilon) ? 0 : color.H / 60;
@ -158,18 +158,18 @@ namespace ImageSharp
break;
}
return new Color(r, g, b, 1);
return new Color32(r, g, b, 1);
}
/// <summary>
/// Allows the implicit conversion of an instance of <see cref="Hsl"/> to a
/// <see cref="Color"/>.
/// <see cref="Color32"/>.
/// </summary>
/// <param name="color">The instance of <see cref="Hsl"/> to convert.</param>
/// <returns>
/// An instance of <see cref="Color"/>.
/// An instance of <see cref="Color32"/>.
/// </returns>
public static implicit operator Color(Hsl color)
public static implicit operator Color32(Hsl color)
{
float rangedH = color.H / 360F;
float r = 0;
@ -195,18 +195,18 @@ namespace ImageSharp
}
}
return new Color(r, g, b, 1);
return new Color32(r, g, b, 1);
}
/// <summary>
/// Allows the implicit conversion of an instance of <see cref="CieLab"/> to a
/// <see cref="Color"/>.
/// <see cref="Color32"/>.
/// </summary>
/// <param name="cieLabColor">The instance of <see cref="CieLab"/> to convert.</param>
/// <returns>
/// An instance of <see cref="Color"/>.
/// An instance of <see cref="Color32"/>.
/// </returns>
public static implicit operator Color(CieLab cieLabColor)
public static implicit operator Color32(CieLab cieLabColor)
{
// First convert back to XYZ...
float y = (cieLabColor.L + 16F) / 116F;
@ -229,7 +229,7 @@ namespace ImageSharp
float g = (x * -0.9689F) + (y * 1.8758F) + (z * 0.0415F);
float b = (x * 0.0557F) + (y * -0.2040F) + (z * 1.0570F);
return new Color(new Vector4(r, g, b, 1F).Compress());
return new Color32(new Vector4(r, g, b, 1F).Compress());
}
/// <summary>

8
src/ImageSharp/Colors/ComponentOrder.cs

@ -11,22 +11,22 @@ namespace ImageSharp
public enum ComponentOrder
{
/// <summary>
/// Z-> Y-> X order. Equivalent to B-> G-> R in <see cref="Color"/>
/// Z-> Y-> X order. Equivalent to B-> G-> R in <see cref="Color32"/>
/// </summary>
Zyx,
/// <summary>
/// Z-> Y-> X-> W order. Equivalent to B-> G-> R-> A in <see cref="Color"/>
/// Z-> Y-> X-> W order. Equivalent to B-> G-> R-> A in <see cref="Color32"/>
/// </summary>
Zyxw,
/// <summary>
/// X-> Y-> Z order. Equivalent to R-> G-> B in <see cref="Color"/>
/// X-> Y-> Z order. Equivalent to R-> G-> B in <see cref="Color32"/>
/// </summary>
Xyz,
/// <summary>
/// X-> Y-> Z-> W order. Equivalent to R-> G-> B-> A in <see cref="Color"/>
/// X-> Y-> Z-> W order. Equivalent to R-> G-> B-> A in <see cref="Color32"/>
/// </summary>
Xyzw,
}

284
src/ImageSharp/Colors/NamedColors{TColor}.cs

@ -15,712 +15,712 @@ namespace ImageSharp
where TColor : struct, IPixel<TColor>
{
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #F0F8FF.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #F0F8FF.
/// </summary>
public static readonly TColor AliceBlue = ColorBuilder<TColor>.FromRGBA(240, 248, 255, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #FAEBD7.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #FAEBD7.
/// </summary>
public static readonly TColor AntiqueWhite = ColorBuilder<TColor>.FromRGBA(250, 235, 215, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #00FFFF.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #00FFFF.
/// </summary>
public static readonly TColor Aqua = ColorBuilder<TColor>.FromRGBA(0, 255, 255, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #7FFFD4.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #7FFFD4.
/// </summary>
public static readonly TColor Aquamarine = ColorBuilder<TColor>.FromRGBA(127, 255, 212, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #F0FFFF.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #F0FFFF.
/// </summary>
public static readonly TColor Azure = ColorBuilder<TColor>.FromRGBA(240, 255, 255, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #F5F5DC.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #F5F5DC.
/// </summary>
public static readonly TColor Beige = ColorBuilder<TColor>.FromRGBA(245, 245, 220, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #FFE4C4.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #FFE4C4.
/// </summary>
public static readonly TColor Bisque = ColorBuilder<TColor>.FromRGBA(255, 228, 196, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #000000.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #000000.
/// </summary>
public static readonly TColor Black = ColorBuilder<TColor>.FromRGBA(0, 0, 0, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #FFEBCD.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #FFEBCD.
/// </summary>
public static readonly TColor BlanchedAlmond = ColorBuilder<TColor>.FromRGBA(255, 235, 205, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #0000FF.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #0000FF.
/// </summary>
public static readonly TColor Blue = ColorBuilder<TColor>.FromRGBA(0, 0, 255, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #8A2BE2.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #8A2BE2.
/// </summary>
public static readonly TColor BlueViolet = ColorBuilder<TColor>.FromRGBA(138, 43, 226, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #A52A2A.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #A52A2A.
/// </summary>
public static readonly TColor Brown = ColorBuilder<TColor>.FromRGBA(165, 42, 42, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #DEB887.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #DEB887.
/// </summary>
public static readonly TColor BurlyWood = ColorBuilder<TColor>.FromRGBA(222, 184, 135, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #5F9EA0.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #5F9EA0.
/// </summary>
public static readonly TColor CadetBlue = ColorBuilder<TColor>.FromRGBA(95, 158, 160, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #7FFF00.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #7FFF00.
/// </summary>
public static readonly TColor Chartreuse = ColorBuilder<TColor>.FromRGBA(127, 255, 0, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #D2691E.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #D2691E.
/// </summary>
public static readonly TColor Chocolate = ColorBuilder<TColor>.FromRGBA(210, 105, 30, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #FF7F50.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #FF7F50.
/// </summary>
public static readonly TColor Coral = ColorBuilder<TColor>.FromRGBA(255, 127, 80, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #6495ED.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #6495ED.
/// </summary>
public static readonly TColor CornflowerBlue = ColorBuilder<TColor>.FromRGBA(100, 149, 237, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #FFF8DC.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #FFF8DC.
/// </summary>
public static readonly TColor Cornsilk = ColorBuilder<TColor>.FromRGBA(255, 248, 220, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #DC143C.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #DC143C.
/// </summary>
public static readonly TColor Crimson = ColorBuilder<TColor>.FromRGBA(220, 20, 60, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #00FFFF.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #00FFFF.
/// </summary>
public static readonly TColor Cyan = ColorBuilder<TColor>.FromRGBA(0, 255, 255, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #00008B.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #00008B.
/// </summary>
public static readonly TColor DarkBlue = ColorBuilder<TColor>.FromRGBA(0, 0, 139, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #008B8B.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #008B8B.
/// </summary>
public static readonly TColor DarkCyan = ColorBuilder<TColor>.FromRGBA(0, 139, 139, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #B8860B.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #B8860B.
/// </summary>
public static readonly TColor DarkGoldenrod = ColorBuilder<TColor>.FromRGBA(184, 134, 11, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #A9A9A9.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #A9A9A9.
/// </summary>
public static readonly TColor DarkGray = ColorBuilder<TColor>.FromRGBA(169, 169, 169, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #006400.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #006400.
/// </summary>
public static readonly TColor DarkGreen = ColorBuilder<TColor>.FromRGBA(0, 100, 0, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #BDB76B.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #BDB76B.
/// </summary>
public static readonly TColor DarkKhaki = ColorBuilder<TColor>.FromRGBA(189, 183, 107, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #8B008B.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #8B008B.
/// </summary>
public static readonly TColor DarkMagenta = ColorBuilder<TColor>.FromRGBA(139, 0, 139, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #556B2F.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #556B2F.
/// </summary>
public static readonly TColor DarkOliveGreen = ColorBuilder<TColor>.FromRGBA(85, 107, 47, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #FF8C00.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #FF8C00.
/// </summary>
public static readonly TColor DarkOrange = ColorBuilder<TColor>.FromRGBA(255, 140, 0, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #9932CC.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #9932CC.
/// </summary>
public static readonly TColor DarkOrchid = ColorBuilder<TColor>.FromRGBA(153, 50, 204, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #8B0000.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #8B0000.
/// </summary>
public static readonly TColor DarkRed = ColorBuilder<TColor>.FromRGBA(139, 0, 0, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #E9967A.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #E9967A.
/// </summary>
public static readonly TColor DarkSalmon = ColorBuilder<TColor>.FromRGBA(233, 150, 122, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #8FBC8B.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #8FBC8B.
/// </summary>
public static readonly TColor DarkSeaGreen = ColorBuilder<TColor>.FromRGBA(143, 188, 139, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #483D8B.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #483D8B.
/// </summary>
public static readonly TColor DarkSlateBlue = ColorBuilder<TColor>.FromRGBA(72, 61, 139, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #2F4F4F.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #2F4F4F.
/// </summary>
public static readonly TColor DarkSlateGray = ColorBuilder<TColor>.FromRGBA(47, 79, 79, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #00CED1.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #00CED1.
/// </summary>
public static readonly TColor DarkTurquoise = ColorBuilder<TColor>.FromRGBA(0, 206, 209, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #9400D3.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #9400D3.
/// </summary>
public static readonly TColor DarkViolet = ColorBuilder<TColor>.FromRGBA(148, 0, 211, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #FF1493.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #FF1493.
/// </summary>
public static readonly TColor DeepPink = ColorBuilder<TColor>.FromRGBA(255, 20, 147, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #00BFFF.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #00BFFF.
/// </summary>
public static readonly TColor DeepSkyBlue = ColorBuilder<TColor>.FromRGBA(0, 191, 255, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #696969.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #696969.
/// </summary>
public static readonly TColor DimGray = ColorBuilder<TColor>.FromRGBA(105, 105, 105, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #1E90FF.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #1E90FF.
/// </summary>
public static readonly TColor DodgerBlue = ColorBuilder<TColor>.FromRGBA(30, 144, 255, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #B22222.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #B22222.
/// </summary>
public static readonly TColor Firebrick = ColorBuilder<TColor>.FromRGBA(178, 34, 34, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #FFFAF0.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #FFFAF0.
/// </summary>
public static readonly TColor FloralWhite = ColorBuilder<TColor>.FromRGBA(255, 250, 240, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #228B22.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #228B22.
/// </summary>
public static readonly TColor ForestGreen = ColorBuilder<TColor>.FromRGBA(34, 139, 34, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #FF00FF.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #FF00FF.
/// </summary>
public static readonly TColor Fuchsia = ColorBuilder<TColor>.FromRGBA(255, 0, 255, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #DCDCDC.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #DCDCDC.
/// </summary>
public static readonly TColor Gainsboro = ColorBuilder<TColor>.FromRGBA(220, 220, 220, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #F8F8FF.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #F8F8FF.
/// </summary>
public static readonly TColor GhostWhite = ColorBuilder<TColor>.FromRGBA(248, 248, 255, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #FFD700.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #FFD700.
/// </summary>
public static readonly TColor Gold = ColorBuilder<TColor>.FromRGBA(255, 215, 0, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #DAA520.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #DAA520.
/// </summary>
public static readonly TColor Goldenrod = ColorBuilder<TColor>.FromRGBA(218, 165, 32, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #808080.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #808080.
/// </summary>
public static readonly TColor Gray = ColorBuilder<TColor>.FromRGBA(128, 128, 128, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #008000.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #008000.
/// </summary>
public static readonly TColor Green = ColorBuilder<TColor>.FromRGBA(0, 128, 0, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #ADFF2F.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #ADFF2F.
/// </summary>
public static readonly TColor GreenYellow = ColorBuilder<TColor>.FromRGBA(173, 255, 47, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #F0FFF0.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #F0FFF0.
/// </summary>
public static readonly TColor Honeydew = ColorBuilder<TColor>.FromRGBA(240, 255, 240, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #FF69B4.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #FF69B4.
/// </summary>
public static readonly TColor HotPink = ColorBuilder<TColor>.FromRGBA(255, 105, 180, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #CD5C5C.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #CD5C5C.
/// </summary>
public static readonly TColor IndianRed = ColorBuilder<TColor>.FromRGBA(205, 92, 92, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #4B0082.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #4B0082.
/// </summary>
public static readonly TColor Indigo = ColorBuilder<TColor>.FromRGBA(75, 0, 130, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #FFFFF0.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #FFFFF0.
/// </summary>
public static readonly TColor Ivory = ColorBuilder<TColor>.FromRGBA(255, 255, 240, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #F0E68C.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #F0E68C.
/// </summary>
public static readonly TColor Khaki = ColorBuilder<TColor>.FromRGBA(240, 230, 140, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #E6E6FA.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #E6E6FA.
/// </summary>
public static readonly TColor Lavender = ColorBuilder<TColor>.FromRGBA(230, 230, 250, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #FFF0F5.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #FFF0F5.
/// </summary>
public static readonly TColor LavenderBlush = ColorBuilder<TColor>.FromRGBA(255, 240, 245, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #7CFC00.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #7CFC00.
/// </summary>
public static readonly TColor LawnGreen = ColorBuilder<TColor>.FromRGBA(124, 252, 0, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #FFFACD.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #FFFACD.
/// </summary>
public static readonly TColor LemonChiffon = ColorBuilder<TColor>.FromRGBA(255, 250, 205, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #ADD8E6.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #ADD8E6.
/// </summary>
public static readonly TColor LightBlue = ColorBuilder<TColor>.FromRGBA(173, 216, 230, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #F08080.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #F08080.
/// </summary>
public static readonly TColor LightCoral = ColorBuilder<TColor>.FromRGBA(240, 128, 128, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #E0FFFF.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #E0FFFF.
/// </summary>
public static readonly TColor LightCyan = ColorBuilder<TColor>.FromRGBA(224, 255, 255, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #FAFAD2.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #FAFAD2.
/// </summary>
public static readonly TColor LightGoldenrodYellow = ColorBuilder<TColor>.FromRGBA(250, 250, 210, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #D3D3D3.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #D3D3D3.
/// </summary>
public static readonly TColor LightGray = ColorBuilder<TColor>.FromRGBA(211, 211, 211, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #90EE90.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #90EE90.
/// </summary>
public static readonly TColor LightGreen = ColorBuilder<TColor>.FromRGBA(144, 238, 144, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #FFB6C1.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #FFB6C1.
/// </summary>
public static readonly TColor LightPink = ColorBuilder<TColor>.FromRGBA(255, 182, 193, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #FFA07A.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #FFA07A.
/// </summary>
public static readonly TColor LightSalmon = ColorBuilder<TColor>.FromRGBA(255, 160, 122, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #20B2AA.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #20B2AA.
/// </summary>
public static readonly TColor LightSeaGreen = ColorBuilder<TColor>.FromRGBA(32, 178, 170, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #87CEFA.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #87CEFA.
/// </summary>
public static readonly TColor LightSkyBlue = ColorBuilder<TColor>.FromRGBA(135, 206, 250, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #778899.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #778899.
/// </summary>
public static readonly TColor LightSlateGray = ColorBuilder<TColor>.FromRGBA(119, 136, 153, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #B0C4DE.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #B0C4DE.
/// </summary>
public static readonly TColor LightSteelBlue = ColorBuilder<TColor>.FromRGBA(176, 196, 222, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #FFFFE0.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #FFFFE0.
/// </summary>
public static readonly TColor LightYellow = ColorBuilder<TColor>.FromRGBA(255, 255, 224, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #00FF00.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #00FF00.
/// </summary>
public static readonly TColor Lime = ColorBuilder<TColor>.FromRGBA(0, 255, 0, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #32CD32.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #32CD32.
/// </summary>
public static readonly TColor LimeGreen = ColorBuilder<TColor>.FromRGBA(50, 205, 50, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #FAF0E6.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #FAF0E6.
/// </summary>
public static readonly TColor Linen = ColorBuilder<TColor>.FromRGBA(250, 240, 230, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #FF00FF.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #FF00FF.
/// </summary>
public static readonly TColor Magenta = ColorBuilder<TColor>.FromRGBA(255, 0, 255, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #800000.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #800000.
/// </summary>
public static readonly TColor Maroon = ColorBuilder<TColor>.FromRGBA(128, 0, 0, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #66CDAA.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #66CDAA.
/// </summary>
public static readonly TColor MediumAquamarine = ColorBuilder<TColor>.FromRGBA(102, 205, 170, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #0000CD.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #0000CD.
/// </summary>
public static readonly TColor MediumBlue = ColorBuilder<TColor>.FromRGBA(0, 0, 205, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #BA55D3.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #BA55D3.
/// </summary>
public static readonly TColor MediumOrchid = ColorBuilder<TColor>.FromRGBA(186, 85, 211, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #9370DB.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #9370DB.
/// </summary>
public static readonly TColor MediumPurple = ColorBuilder<TColor>.FromRGBA(147, 112, 219, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #3CB371.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #3CB371.
/// </summary>
public static readonly TColor MediumSeaGreen = ColorBuilder<TColor>.FromRGBA(60, 179, 113, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #7B68EE.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #7B68EE.
/// </summary>
public static readonly TColor MediumSlateBlue = ColorBuilder<TColor>.FromRGBA(123, 104, 238, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #00FA9A.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #00FA9A.
/// </summary>
public static readonly TColor MediumSpringGreen = ColorBuilder<TColor>.FromRGBA(0, 250, 154, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #48D1CC.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #48D1CC.
/// </summary>
public static readonly TColor MediumTurquoise = ColorBuilder<TColor>.FromRGBA(72, 209, 204, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #C71585.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #C71585.
/// </summary>
public static readonly TColor MediumVioletRed = ColorBuilder<TColor>.FromRGBA(199, 21, 133, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #191970.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #191970.
/// </summary>
public static readonly TColor MidnightBlue = ColorBuilder<TColor>.FromRGBA(25, 25, 112, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #F5FFFA.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #F5FFFA.
/// </summary>
public static readonly TColor MintCream = ColorBuilder<TColor>.FromRGBA(245, 255, 250, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #FFE4E1.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #FFE4E1.
/// </summary>
public static readonly TColor MistyRose = ColorBuilder<TColor>.FromRGBA(255, 228, 225, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #FFE4B5.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #FFE4B5.
/// </summary>
public static readonly TColor Moccasin = ColorBuilder<TColor>.FromRGBA(255, 228, 181, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #FFDEAD.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #FFDEAD.
/// </summary>
public static readonly TColor NavajoWhite = ColorBuilder<TColor>.FromRGBA(255, 222, 173, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #000080.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #000080.
/// </summary>
public static readonly TColor Navy = ColorBuilder<TColor>.FromRGBA(0, 0, 128, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #FDF5E6.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #FDF5E6.
/// </summary>
public static readonly TColor OldLace = ColorBuilder<TColor>.FromRGBA(253, 245, 230, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #808000.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #808000.
/// </summary>
public static readonly TColor Olive = ColorBuilder<TColor>.FromRGBA(128, 128, 0, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #6B8E23.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #6B8E23.
/// </summary>
public static readonly TColor OliveDrab = ColorBuilder<TColor>.FromRGBA(107, 142, 35, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #FFA500.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #FFA500.
/// </summary>
public static readonly TColor Orange = ColorBuilder<TColor>.FromRGBA(255, 165, 0, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #FF4500.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #FF4500.
/// </summary>
public static readonly TColor OrangeRed = ColorBuilder<TColor>.FromRGBA(255, 69, 0, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #DA70D6.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #DA70D6.
/// </summary>
public static readonly TColor Orchid = ColorBuilder<TColor>.FromRGBA(218, 112, 214, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #EEE8AA.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #EEE8AA.
/// </summary>
public static readonly TColor PaleGoldenrod = ColorBuilder<TColor>.FromRGBA(238, 232, 170, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #98FB98.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #98FB98.
/// </summary>
public static readonly TColor PaleGreen = ColorBuilder<TColor>.FromRGBA(152, 251, 152, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #AFEEEE.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #AFEEEE.
/// </summary>
public static readonly TColor PaleTurquoise = ColorBuilder<TColor>.FromRGBA(175, 238, 238, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #DB7093.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #DB7093.
/// </summary>
public static readonly TColor PaleVioletRed = ColorBuilder<TColor>.FromRGBA(219, 112, 147, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #FFEFD5.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #FFEFD5.
/// </summary>
public static readonly TColor PapayaWhip = ColorBuilder<TColor>.FromRGBA(255, 239, 213, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #FFDAB9.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #FFDAB9.
/// </summary>
public static readonly TColor PeachPuff = ColorBuilder<TColor>.FromRGBA(255, 218, 185, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #CD853F.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #CD853F.
/// </summary>
public static readonly TColor Peru = ColorBuilder<TColor>.FromRGBA(205, 133, 63, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #FFC0CB.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #FFC0CB.
/// </summary>
public static readonly TColor Pink = ColorBuilder<TColor>.FromRGBA(255, 192, 203, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #DDA0DD.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #DDA0DD.
/// </summary>
public static readonly TColor Plum = ColorBuilder<TColor>.FromRGBA(221, 160, 221, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #B0E0E6.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #B0E0E6.
/// </summary>
public static readonly TColor PowderBlue = ColorBuilder<TColor>.FromRGBA(176, 224, 230, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #800080.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #800080.
/// </summary>
public static readonly TColor Purple = ColorBuilder<TColor>.FromRGBA(128, 0, 128, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #663399.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #663399.
/// </summary>
public static readonly TColor RebeccaPurple = ColorBuilder<TColor>.FromRGBA(102, 51, 153, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #FF0000.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #FF0000.
/// </summary>
public static readonly TColor Red = ColorBuilder<TColor>.FromRGBA(255, 0, 0, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #BC8F8F.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #BC8F8F.
/// </summary>
public static readonly TColor RosyBrown = ColorBuilder<TColor>.FromRGBA(188, 143, 143, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #4169E1.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #4169E1.
/// </summary>
public static readonly TColor RoyalBlue = ColorBuilder<TColor>.FromRGBA(65, 105, 225, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #8B4513.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #8B4513.
/// </summary>
public static readonly TColor SaddleBrown = ColorBuilder<TColor>.FromRGBA(139, 69, 19, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #FA8072.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #FA8072.
/// </summary>
public static readonly TColor Salmon = ColorBuilder<TColor>.FromRGBA(250, 128, 114, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #F4A460.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #F4A460.
/// </summary>
public static readonly TColor SandyBrown = ColorBuilder<TColor>.FromRGBA(244, 164, 96, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #2E8B57.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #2E8B57.
/// </summary>
public static readonly TColor SeaGreen = ColorBuilder<TColor>.FromRGBA(46, 139, 87, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #FFF5EE.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #FFF5EE.
/// </summary>
public static readonly TColor SeaShell = ColorBuilder<TColor>.FromRGBA(255, 245, 238, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #A0522D.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #A0522D.
/// </summary>
public static readonly TColor Sienna = ColorBuilder<TColor>.FromRGBA(160, 82, 45, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #C0C0C0.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #C0C0C0.
/// </summary>
public static readonly TColor Silver = ColorBuilder<TColor>.FromRGBA(192, 192, 192, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #87CEEB.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #87CEEB.
/// </summary>
public static readonly TColor SkyBlue = ColorBuilder<TColor>.FromRGBA(135, 206, 235, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #6A5ACD.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #6A5ACD.
/// </summary>
public static readonly TColor SlateBlue = ColorBuilder<TColor>.FromRGBA(106, 90, 205, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #708090.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #708090.
/// </summary>
public static readonly TColor SlateGray = ColorBuilder<TColor>.FromRGBA(112, 128, 144, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #FFFAFA.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #FFFAFA.
/// </summary>
public static readonly TColor Snow = ColorBuilder<TColor>.FromRGBA(255, 250, 250, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #00FF7F.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #00FF7F.
/// </summary>
public static readonly TColor SpringGreen = ColorBuilder<TColor>.FromRGBA(0, 255, 127, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #4682B4.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #4682B4.
/// </summary>
public static readonly TColor SteelBlue = ColorBuilder<TColor>.FromRGBA(70, 130, 180, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #D2B48C.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #D2B48C.
/// </summary>
public static readonly TColor Tan = ColorBuilder<TColor>.FromRGBA(210, 180, 140, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #008080.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #008080.
/// </summary>
public static readonly TColor Teal = ColorBuilder<TColor>.FromRGBA(0, 128, 128, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #D8BFD8.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #D8BFD8.
/// </summary>
public static readonly TColor Thistle = ColorBuilder<TColor>.FromRGBA(216, 191, 216, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #FF6347.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #FF6347.
/// </summary>
public static readonly TColor Tomato = ColorBuilder<TColor>.FromRGBA(255, 99, 71, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #FFFFFF.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #FFFFFF.
/// </summary>
public static readonly TColor Transparent = ColorBuilder<TColor>.FromRGBA(255, 255, 255, 0);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #40E0D0.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #40E0D0.
/// </summary>
public static readonly TColor Turquoise = ColorBuilder<TColor>.FromRGBA(64, 224, 208, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #EE82EE.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #EE82EE.
/// </summary>
public static readonly TColor Violet = ColorBuilder<TColor>.FromRGBA(238, 130, 238, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #F5DEB3.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #F5DEB3.
/// </summary>
public static readonly TColor Wheat = ColorBuilder<TColor>.FromRGBA(245, 222, 179, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #FFFFFF.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #FFFFFF.
/// </summary>
public static readonly TColor White = ColorBuilder<TColor>.FromRGBA(255, 255, 255, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #F5F5F5.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #F5F5F5.
/// </summary>
public static readonly TColor WhiteSmoke = ColorBuilder<TColor>.FromRGBA(245, 245, 245, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #FFFF00.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #FFFF00.
/// </summary>
public static readonly TColor Yellow = ColorBuilder<TColor>.FromRGBA(255, 255, 0, 255);
/// <summary>
/// Represents a <see cref="Color"/> matching the W3C definition that has an hex value of #9ACD32.
/// Represents a <see cref="Color32"/> matching the W3C definition that has an hex value of #9ACD32.
/// </summary>
public static readonly TColor YellowGreen = ColorBuilder<TColor>.FromRGBA(154, 205, 50, 255);
}

8
src/ImageSharp/Colors/PackedPixel/IPixel.cs

@ -52,7 +52,7 @@ namespace ImageSharp
/// <summary>
/// Expands the packed representation into a given byte array.
/// Output is expanded to X-> Y-> Z order. Equivalent to R-> G-> B in <see cref="Color"/>
/// Output is expanded to X-> Y-> Z order. Equivalent to R-> G-> B in <see cref="Color32"/>
/// </summary>
/// <param name="bytes">The bytes to set the color in.</param>
/// <param name="startIndex">The starting index of the <paramref name="bytes"/>.</param>
@ -60,7 +60,7 @@ namespace ImageSharp
/// <summary>
/// Expands the packed representation into a given byte array.
/// Output is expanded to X-> Y-> Z-> W order. Equivalent to R-> G-> B-> A in <see cref="Color"/>
/// Output is expanded to X-> Y-> Z-> W order. Equivalent to R-> G-> B-> A in <see cref="Color32"/>
/// </summary>
/// <param name="bytes">The bytes to set the color in.</param>
/// <param name="startIndex">The starting index of the <paramref name="bytes"/>.</param>
@ -68,7 +68,7 @@ namespace ImageSharp
/// <summary>
/// Expands the packed representation into a given byte array.
/// Output is expanded to Z-> Y-> X order. Equivalent to B-> G-> R in <see cref="Color"/>
/// Output is expanded to Z-> Y-> X order. Equivalent to B-> G-> R in <see cref="Color32"/>
/// </summary>
/// <param name="bytes">The bytes to set the color in.</param>
/// <param name="startIndex">The starting index of the <paramref name="bytes"/>.</param>
@ -76,7 +76,7 @@ namespace ImageSharp
/// <summary>
/// Expands the packed representation into a given byte array.
/// Output is expanded to Z-> Y-> X-> W order. Equivalent to B-> G-> R-> A in <see cref="Color"/>
/// Output is expanded to Z-> Y-> X-> W order. Equivalent to B-> G-> R-> A in <see cref="Color32"/>
/// </summary>
/// <param name="bytes">The bytes to set the color in.</param>
/// <param name="startIndex">The starting index of the <paramref name="bytes"/>.</param>

2
src/ImageSharp/Colors/PackedPixel/PackedPixelConverterHelper.cs

@ -299,7 +299,7 @@ namespace ImageSharp
/// <returns>The <see cref="bool"/></returns>
private static bool IsStandardNormalizedType(Type type)
{
return type == typeof(Color)
return type == typeof(Color32)
|| type == typeof(Argb)
|| type == typeof(Alpha8)
|| type == typeof(Bgr565)

6
src/ImageSharp/Colors/Spaces/Bgra32.cs

@ -79,16 +79,16 @@ namespace ImageSharp.Colors.Spaces
public bool IsEmpty => this.Equals(Empty);
/// <summary>
/// Allows the implicit conversion of an instance of <see cref="Color"/> to a
/// Allows the implicit conversion of an instance of <see cref="Color32"/> to a
/// <see cref="Bgra32"/>.
/// </summary>
/// <param name="color">
/// The instance of <see cref="Color"/> to convert.
/// The instance of <see cref="Color32"/> to convert.
/// </param>
/// <returns>
/// An instance of <see cref="Bgra32"/>.
/// </returns>
public static implicit operator Bgra32(Color color)
public static implicit operator Bgra32(Color32 color)
{
return new Bgra32(color.B, color.G, color.R, color.A);
}

6
src/ImageSharp/Colors/Spaces/CieLab.cs

@ -72,16 +72,16 @@ namespace ImageSharp.Colors.Spaces
public bool IsEmpty => this.Equals(Empty);
/// <summary>
/// Allows the implicit conversion of an instance of <see cref="Color"/> to a
/// Allows the implicit conversion of an instance of <see cref="Color32"/> to a
/// <see cref="CieLab"/>.
/// </summary>
/// <param name="color">
/// The instance of <see cref="Color"/> to convert.
/// The instance of <see cref="Color32"/> to convert.
/// </param>
/// <returns>
/// An instance of <see cref="CieLab"/>.
/// </returns>
public static implicit operator CieLab(Color color)
public static implicit operator CieLab(Color32 color)
{
// First convert to CIE XYZ
Vector4 vector = color.ToVector4().Expand();

6
src/ImageSharp/Colors/Spaces/CieXyz.cs

@ -63,16 +63,16 @@ namespace ImageSharp.Colors.Spaces
public bool IsEmpty => this.Equals(Empty);
/// <summary>
/// Allows the implicit conversion of an instance of <see cref="Color"/> to a
/// Allows the implicit conversion of an instance of <see cref="Color32"/> to a
/// <see cref="CieXyz"/>.
/// </summary>
/// <param name="color">
/// The instance of <see cref="Color"/> to convert.
/// The instance of <see cref="Color32"/> to convert.
/// </param>
/// <returns>
/// An instance of <see cref="CieXyz"/>.
/// </returns>
public static implicit operator CieXyz(Color color)
public static implicit operator CieXyz(Color32 color)
{
Vector4 vector = color.ToVector4().Expand();

4
src/ImageSharp/Colors/Spaces/Cmyk.cs

@ -78,7 +78,7 @@ namespace ImageSharp.Colors.Spaces
public bool IsEmpty => this.Equals(Empty);
/// <summary>
/// Allows the implicit conversion of an instance of <see cref="Color"/> to a
/// Allows the implicit conversion of an instance of <see cref="Color32"/> to a
/// <see cref="Cmyk"/>.
/// </summary>
/// <param name="color">
@ -87,7 +87,7 @@ namespace ImageSharp.Colors.Spaces
/// <returns>
/// An instance of <see cref="Cmyk"/>.
/// </returns>
public static implicit operator Cmyk(Color color)
public static implicit operator Cmyk(Color32 color)
{
float c = 1f - (color.R / 255F);
float m = 1f - (color.G / 255F);

6
src/ImageSharp/Colors/Spaces/Hsl.cs

@ -70,14 +70,14 @@ namespace ImageSharp.Colors.Spaces
public bool IsEmpty => this.Equals(Empty);
/// <summary>
/// Allows the implicit conversion of an instance of <see cref="Color"/> to a
/// Allows the implicit conversion of an instance of <see cref="Color32"/> to a
/// <see cref="Hsl"/>.
/// </summary>
/// <param name="color">The instance of <see cref="Color"/> to convert.</param>
/// <param name="color">The instance of <see cref="Color32"/> to convert.</param>
/// <returns>
/// An instance of <see cref="Hsl"/>.
/// </returns>
public static implicit operator Hsl(Color color)
public static implicit operator Hsl(Color32 color)
{
float r = color.R / 255F;
float g = color.G / 255F;

6
src/ImageSharp/Colors/Spaces/Hsv.cs

@ -70,14 +70,14 @@ namespace ImageSharp.Colors.Spaces
public bool IsEmpty => this.Equals(Empty);
/// <summary>
/// Allows the implicit conversion of an instance of <see cref="Color"/> to a
/// Allows the implicit conversion of an instance of <see cref="Color32"/> to a
/// <see cref="Hsv"/>.
/// </summary>
/// <param name="color">The instance of <see cref="Color"/> to convert.</param>
/// <param name="color">The instance of <see cref="Color32"/> to convert.</param>
/// <returns>
/// An instance of <see cref="Hsv"/>.
/// </returns>
public static implicit operator Hsv(Color color)
public static implicit operator Hsv(Color32 color)
{
float r = color.R / 255F;
float g = color.G / 255F;

6
src/ImageSharp/Colors/Spaces/YCbCr.cs

@ -72,16 +72,16 @@ namespace ImageSharp.Colors.Spaces
public bool IsEmpty => this.Equals(Empty);
/// <summary>
/// Allows the implicit conversion of an instance of <see cref="Color"/> to a
/// Allows the implicit conversion of an instance of <see cref="Color32"/> to a
/// <see cref="YCbCr"/>.
/// </summary>
/// <param name="color">
/// The instance of <see cref="Color"/> to convert.
/// The instance of <see cref="Color32"/> to convert.
/// </param>
/// <returns>
/// An instance of <see cref="YCbCr"/>.
/// </returns>
public static implicit operator YCbCr(Color color)
public static implicit operator YCbCr(Color32 color)
{
byte r = color.R;
byte g = color.G;

2
src/ImageSharp/Common/Extensions/Vector4Extensions.cs

@ -32,7 +32,7 @@ namespace ImageSharp
/// <see href="http://www.4p8.com/eric.brasseur/gamma.html#formulas"/>
/// <see href="http://entropymine.com/imageworsener/srgbformula/"/>
/// </summary>
/// <param name="gamma">The <see cref="Color"/> whose signal to expand.</param>
/// <param name="gamma">The <see cref="Color32"/> whose signal to expand.</param>
/// <returns>The <see cref="Vector4"/>.</returns>
public static Vector4 Expand(this Vector4 gamma)
{

6
src/ImageSharp/Image.Create.cs

@ -29,12 +29,12 @@ namespace ImageSharp
/// The configuration providing initialization code which allows extending the library.
/// </param>
/// <returns>
/// A new <see cref="Image{TColor}"/> unless <typeparamref name="TColor"/> is <see cref="Color"/> in which case it returns <see cref="Image" />
/// A new <see cref="Image{TColor}"/> unless <typeparamref name="TColor"/> is <see cref="Color32"/> in which case it returns <see cref="Image" />
/// </returns>
internal static Image<TColor> Create<TColor>(int width, int height, ImageMetaData metadata, Configuration configuration)
where TColor : struct, IPixel<TColor>
{
if (typeof(TColor) == typeof(Color))
if (typeof(TColor) == typeof(Color32))
{
return new Image(width, height, metadata, configuration) as Image<TColor>;
}
@ -55,7 +55,7 @@ namespace ImageSharp
/// The configuration providing initialization code which allows extending the library.
/// </param>
/// <returns>
/// A new <see cref="Image{TColor}"/> unless <typeparamref name="TColor"/> is <see cref="Color"/> in which case it returns <see cref="Image" />
/// A new <see cref="Image{TColor}"/> unless <typeparamref name="TColor"/> is <see cref="Color32"/> in which case it returns <see cref="Image" />
/// </returns>
internal static Image<TColor> Create<TColor>(int width, int height, Configuration configuration)
where TColor : struct, IPixel<TColor>

2
src/ImageSharp/Image.FromFile.cs

@ -83,7 +83,7 @@ namespace ImageSharp
/// <returns>The image</returns>
public static Image Load(string path, IImageDecoder decoder, IDecoderOptions options)
{
return new Image(Load<Color>(path, decoder, options));
return new Image(Load<Color32>(path, decoder, options));
}
/// <summary>

4
src/ImageSharp/Image.FromStream.cs

@ -83,7 +83,7 @@ namespace ImageSharp
/// <returns>The image</returns>
public static Image Load(Configuration config, Stream stream, IDecoderOptions options)
{
Image<Color> image = Load<Color>(config, stream, options);
Image<Color32> image = Load<Color32>(config, stream, options);
return image as Image ?? new Image(image);
}
@ -100,7 +100,7 @@ namespace ImageSharp
/// <returns>The image</returns>
public static Image Load(Stream stream, IImageDecoder decoder, IDecoderOptions options)
{
Image<Color> image = new Image(Load<Color>(stream, decoder, options));
Image<Color32> image = new Image(Load<Color32>(stream, decoder, options));
return image as Image ?? new Image(image);
}

4
src/ImageSharp/Image.cs

@ -16,7 +16,7 @@ namespace ImageSharp
/// packed into a single unsigned integer value.
/// </summary>
[DebuggerDisplay("Image: {Width}x{Height}")]
public sealed partial class Image : Image<Color>
public sealed partial class Image : Image<Color32>
{
/// <summary>
/// Initializes a new instance of the <see cref="Image"/> class
@ -49,7 +49,7 @@ namespace ImageSharp
/// </summary>
/// <param name="other">The other image, where the clone should be made from.</param>
/// <exception cref="System.ArgumentNullException"><paramref name="other"/> is null.</exception>
public Image(Image<Color> other)
public Image(Image<Color32> other)
: base(other)
{
}

2
src/ImageSharp/Processing/Processors/ColorMatrix/ColorMatrixProcessor.cs

@ -75,7 +75,7 @@ namespace ImageSharp.Processing.Processors
/// <param name="matrix">The matrix.</param>
/// <param name="compand">Whether to compand the color during processing.</param>
/// <returns>
/// The <see cref="Color"/>.
/// The <see cref="Color32"/>.
/// </returns>
private TColor ApplyMatrix(TColor color, Matrix4x4 matrix, bool compand)
{

2
src/ImageSharp/Quantizers/PaletteQuantizer.cs

@ -44,7 +44,7 @@ namespace ImageSharp.Quantizers
{
if (palette == null)
{
Color[] constants = ColorConstants.WebSafeColors;
Color32[] constants = Color32Constants.WebSafeColors;
TColor[] safe = new TColor[constants.Length + 1];
for (int i = 0; i < constants.Length; i++)

10
tests/ImageSharp.Benchmarks/Color/Bulk/PackFromVector4ReferenceVsPointer.cs

@ -14,7 +14,7 @@
/// </summary>
public unsafe class PackFromVector4ReferenceVsPointer
{
private PinnedBuffer<ImageSharp.Color> destination;
private PinnedBuffer<ImageSharp.Color32> destination;
private PinnedBuffer<Vector4> source;
@ -24,7 +24,7 @@
[Setup]
public void Setup()
{
this.destination = new PinnedBuffer<ImageSharp.Color>(this.Count);
this.destination = new PinnedBuffer<ImageSharp.Color32>(this.Count);
this.source = new PinnedBuffer<Vector4>(this.Count * 4);
}
@ -41,12 +41,12 @@
Vector4* sp = (Vector4*)this.source.Pointer;
byte* dp = (byte*)this.destination.Pointer;
int count = this.Count;
int size = sizeof(ImageSharp.Color);
int size = sizeof(ImageSharp.Color32);
for (int i = 0; i < count; i++)
{
Vector4 v = Unsafe.Read<Vector4>(sp);
ImageSharp.Color c = default(ImageSharp.Color);
ImageSharp.Color32 c = default(ImageSharp.Color32);
c.PackFromVector4(v);
Unsafe.Write(dp, c);
@ -59,7 +59,7 @@
public void PackUsingReferences()
{
ref Vector4 sp = ref this.source.Array[0];
ref ImageSharp.Color dp = ref this.destination.Array[0];
ref ImageSharp.Color32 dp = ref this.destination.Array[0];
int count = this.Count;
for (int i = 0; i < count; i++)

4
tests/ImageSharp.Benchmarks/Color/Bulk/PackFromXyzw.cs

@ -3,7 +3,7 @@ namespace ImageSharp.Benchmarks.Color.Bulk
{
using BenchmarkDotNet.Attributes;
using Color = ImageSharp.Color;
using Color32 = ImageSharp.Color32;
public abstract class PackFromXyzw<TColor>
where TColor : struct, IPixel<TColor>
@ -57,7 +57,7 @@ namespace ImageSharp.Benchmarks.Color.Bulk
}
}
public class PackFromXyzw_Color : PackFromXyzw<Color>
public class PackFromXyzw_Color : PackFromXyzw<Color32>
{
}
}

2
tests/ImageSharp.Benchmarks/Color/Bulk/ToVector4.cs

@ -55,7 +55,7 @@ namespace ImageSharp.Benchmarks.Color.Bulk
}
}
public class ToVector4_Color : ToVector4<ImageSharp.Color>
public class ToVector4_Color : ToVector4<ImageSharp.Color32>
{
}
}

4
tests/ImageSharp.Benchmarks/Color/Bulk/ToXyz.cs

@ -3,7 +3,7 @@ namespace ImageSharp.Benchmarks.Color.Bulk
{
using BenchmarkDotNet.Attributes;
using Color = ImageSharp.Color;
using Color32 = ImageSharp.Color32;
public abstract class ToXyz<TColor>
where TColor : struct, IPixel<TColor>
@ -55,7 +55,7 @@ namespace ImageSharp.Benchmarks.Color.Bulk
}
}
public class ToXyz_Color : ToXyz<Color>
public class ToXyz_Color : ToXyz<Color32>
{
}
}

4
tests/ImageSharp.Benchmarks/Color/Bulk/ToXyzw.cs

@ -8,7 +8,7 @@ namespace ImageSharp.Benchmarks.Color.Bulk
{
using BenchmarkDotNet.Attributes;
using Color = ImageSharp.Color;
using Color32 = ImageSharp.Color32;
public abstract class ToXyzw<TColor>
where TColor : struct, IPixel<TColor>
@ -60,7 +60,7 @@ namespace ImageSharp.Benchmarks.Color.Bulk
}
}
public class ToXyzw_Color : ToXyzw<Color>
public class ToXyzw_Color : ToXyzw<Color32>
{
}

2
tests/ImageSharp.Benchmarks/Color/ColorEquality.cs

@ -7,7 +7,7 @@ namespace ImageSharp.Benchmarks
{
using BenchmarkDotNet.Attributes;
using CoreColor = ImageSharp.Color;
using CoreColor = ImageSharp.Color32;
using SystemColor = System.Drawing.Color;
public class ColorEquality

2
tests/ImageSharp.Benchmarks/Drawing/DrawBeziers.cs

@ -12,7 +12,7 @@ namespace ImageSharp.Benchmarks
using BenchmarkDotNet.Attributes;
using CoreColor = ImageSharp.Color;
using CoreColor = ImageSharp.Color32;
using CoreImage = ImageSharp.Image;
using CorePoint = ImageSharp.Point;

2
tests/ImageSharp.Benchmarks/Drawing/DrawLines.cs

@ -12,7 +12,7 @@ namespace ImageSharp.Benchmarks
using BenchmarkDotNet.Attributes;
using CoreColor = ImageSharp.Color;
using CoreColor = ImageSharp.Color32;
using CoreImage = ImageSharp.Image;
using CorePoint = ImageSharp.Point;

2
tests/ImageSharp.Benchmarks/Drawing/DrawPolygon.cs

@ -11,7 +11,7 @@ namespace ImageSharp.Benchmarks
using BenchmarkDotNet.Attributes;
using CoreImage = ImageSharp.Image;
using CorePoint = ImageSharp.Point;
using CoreColor = ImageSharp.Color;
using CoreColor = ImageSharp.Color32;
using System.IO;
using System.Numerics;

2
tests/ImageSharp.Benchmarks/Drawing/FillPolygon.cs

@ -13,7 +13,7 @@ namespace ImageSharp.Benchmarks
using BenchmarkDotNet.Attributes;
using CoreColor = ImageSharp.Color;
using CoreColor = ImageSharp.Color32;
using CoreImage = ImageSharp.Image;
public class FillPolygon : BenchmarkBase

2
tests/ImageSharp.Benchmarks/Drawing/FillRectangle.cs

@ -11,7 +11,7 @@ namespace ImageSharp.Benchmarks
using BenchmarkDotNet.Attributes;
using CoreImage = ImageSharp.Image;
using CoreRectangle = ImageSharp.Rectangle;
using CoreColor = ImageSharp.Color;
using CoreColor = ImageSharp.Color32;
using CoreSize = ImageSharp.Size;
using System.Numerics;

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

@ -12,7 +12,7 @@ namespace ImageSharp.Benchmarks
using BenchmarkDotNet.Attributes;
using CoreBrushes = ImageSharp.Drawing.Brushes.Brushes;
using CoreColor = ImageSharp.Color;
using CoreColor = ImageSharp.Color32;
using CoreImage = ImageSharp.Image;
public class FillWithPattern

6
tests/ImageSharp.Benchmarks/General/ClearBuffer.cs

@ -7,11 +7,11 @@ namespace ImageSharp.Benchmarks.General
using BenchmarkDotNet.Attributes;
using Color = ImageSharp.Color;
using Color32 = ImageSharp.Color32;
public unsafe class ClearBuffer
{
private PinnedBuffer<Color> buffer;
private PinnedBuffer<Color32> buffer;
[Params(32, 128, 512)]
public int Count { get; set; }
@ -19,7 +19,7 @@ namespace ImageSharp.Benchmarks.General
[Setup]
public void Setup()
{
this.buffer = new PinnedBuffer<ImageSharp.Color>(this.Count);
this.buffer = new PinnedBuffer<ImageSharp.Color32>(this.Count);
}
[Cleanup]

2
tests/ImageSharp.Benchmarks/Image/CopyPixels.cs

@ -9,7 +9,7 @@ namespace ImageSharp.Benchmarks.Image
using BenchmarkDotNet.Attributes;
using CoreColor = ImageSharp.Color;
using CoreColor = ImageSharp.Color32;
using CoreImage = ImageSharp.Image;
public class CopyPixels : BenchmarkBase

10
tests/ImageSharp.Benchmarks/Image/EncodeIndexedPng.cs

@ -51,7 +51,7 @@ namespace ImageSharp.Benchmarks.Image
{
using (MemoryStream memoryStream = new MemoryStream())
{
PngEncoderOptions options = new PngEncoderOptions() { Quantizer = new OctreeQuantizer<Color>(), Quality = 256 };
PngEncoderOptions options = new PngEncoderOptions() { Quantizer = new OctreeQuantizer<Color32>(), Quality = 256 };
this.bmpCore.SaveAsPng(memoryStream, options);
}
@ -62,7 +62,7 @@ namespace ImageSharp.Benchmarks.Image
{
using (MemoryStream memoryStream = new MemoryStream())
{
PngEncoderOptions options = new PngEncoderOptions { Quantizer = new OctreeQuantizer<Color> { Dither = false }, Quality = 256 };
PngEncoderOptions options = new PngEncoderOptions { Quantizer = new OctreeQuantizer<Color32> { Dither = false }, Quality = 256 };
this.bmpCore.SaveAsPng(memoryStream, options);
}
@ -73,7 +73,7 @@ namespace ImageSharp.Benchmarks.Image
{
using (MemoryStream memoryStream = new MemoryStream())
{
PngEncoderOptions options = new PngEncoderOptions { Quantizer = new PaletteQuantizer<Color>(), Quality = 256 };
PngEncoderOptions options = new PngEncoderOptions { Quantizer = new PaletteQuantizer<Color32>(), Quality = 256 };
this.bmpCore.SaveAsPng(memoryStream, options);
}
@ -84,7 +84,7 @@ namespace ImageSharp.Benchmarks.Image
{
using (MemoryStream memoryStream = new MemoryStream())
{
PngEncoderOptions options = new PngEncoderOptions { Quantizer = new PaletteQuantizer<Color> { Dither = false }, Quality = 256 };
PngEncoderOptions options = new PngEncoderOptions { Quantizer = new PaletteQuantizer<Color32> { Dither = false }, Quality = 256 };
this.bmpCore.SaveAsPng(memoryStream, options);
}
@ -95,7 +95,7 @@ namespace ImageSharp.Benchmarks.Image
{
using (MemoryStream memoryStream = new MemoryStream())
{
PngEncoderOptions options = new PngEncoderOptions() { Quantizer = new WuQuantizer<Color>(), Quality = 256 };
PngEncoderOptions options = new PngEncoderOptions() { Quantizer = new WuQuantizer<Color32>(), Quality = 256 };
this.bmpCore.SaveAsPng(memoryStream, options);
}

8
tests/ImageSharp.Benchmarks/Image/EncodePng.cs

@ -66,10 +66,10 @@ namespace ImageSharp.Benchmarks.Image
{
using (MemoryStream memoryStream = new MemoryStream())
{
Quantizer<ImageSharp.Color> quantizer = this.UseOctreeQuantizer
? (Quantizer<ImageSharp.Color>)
new OctreeQuantizer<ImageSharp.Color>()
: new PaletteQuantizer<ImageSharp.Color>();
Quantizer<ImageSharp.Color32> quantizer = this.UseOctreeQuantizer
? (Quantizer<ImageSharp.Color32>)
new OctreeQuantizer<ImageSharp.Color32>()
: new PaletteQuantizer<ImageSharp.Color32>();
PngEncoderOptions options = new PngEncoderOptions() { Quantizer = quantizer };
this.bmpCore.SaveAsPng(memoryStream, options);

2
tests/ImageSharp.Benchmarks/Image/GetSetPixel.cs

@ -9,7 +9,7 @@ namespace ImageSharp.Benchmarks.Image
using BenchmarkDotNet.Attributes;
using CoreColor = ImageSharp.Color;
using CoreColor = ImageSharp.Color32;
using CoreImage = ImageSharp.Image;
using SystemColor = System.Drawing.Color;

12
tests/ImageSharp.Tests/Colors/BulkPixelOperationsTests.cs

@ -10,7 +10,7 @@ namespace ImageSharp.Tests.Colors
public class BulkPixelOperationsTests
{
public class Color : BulkPixelOperationsTests<ImageSharp.Color>
public class Color : BulkPixelOperationsTests<ImageSharp.Color32>
{
public Color(ITestOutputHelper output)
: base(output)
@ -23,19 +23,19 @@ namespace ImageSharp.Tests.Colors
[Fact]
public void IsSpecialImplementation()
{
Assert.IsType<ImageSharp.Color.BulkOperations>(BulkPixelOperations<ImageSharp.Color>.Instance);
Assert.IsType<ImageSharp.Color32.BulkOperations>(BulkPixelOperations<ImageSharp.Color32>.Instance);
}
[Fact]
public void ToVector4SimdAligned()
{
ImageSharp.Color[] source = CreatePixelTestData(64);
ImageSharp.Color32[] source = CreatePixelTestData(64);
Vector4[] expected = CreateExpectedVector4Data(source);
TestOperation(
source,
expected,
(s, d) => ImageSharp.Color.BulkOperations.ToVector4SimdAligned(s, d, 64)
(s, d) => ImageSharp.Color32.BulkOperations.ToVector4SimdAligned(s, d, 64)
);
}
@ -45,14 +45,14 @@ namespace ImageSharp.Tests.Colors
int times = 200000;
int count = 1024;
using (PinnedBuffer<ImageSharp.Color> source = new PinnedBuffer<ImageSharp.Color>(count))
using (PinnedBuffer<ImageSharp.Color32> source = new PinnedBuffer<ImageSharp.Color32>(count))
using (PinnedBuffer<Vector4> dest = new PinnedBuffer<Vector4>(count))
{
this.Measure(
times,
() =>
{
BulkPixelOperations<ImageSharp.Color>.Instance.ToVector4(source, dest, count);
BulkPixelOperations<ImageSharp.Color32>.Instance.ToVector4(source, dest, count);
});
}
}

106
tests/ImageSharp.Tests/Colors/ColorConversionTests.cs

@ -20,7 +20,7 @@ namespace ImageSharp.Tests
public class ColorConversionTests
{
/// <summary>
/// Tests the implicit conversion from <see cref="Color"/> to <see cref="YCbCr"/>.
/// Tests the implicit conversion from <see cref="Color32"/> to <see cref="YCbCr"/>.
/// </summary>
[Fact]
[SuppressMessage("StyleCop.CSharp.NamingRules", "SA1305:FieldNamesMustNotUseHungarianNotation",
@ -28,7 +28,7 @@ namespace ImageSharp.Tests
public void ColorToYCbCr()
{
// White
Color color = Color.White;
Color32 color = Color32.White;
YCbCr yCbCr = color;
Assert.Equal(255, yCbCr.Y);
@ -36,14 +36,14 @@ namespace ImageSharp.Tests
Assert.Equal(128, yCbCr.Cr);
// Black
Color color2 = Color.Black;
Color32 color2 = Color32.Black;
YCbCr yCbCr2 = color2;
Assert.Equal(0, yCbCr2.Y);
Assert.Equal(128, yCbCr2.Cb);
Assert.Equal(128, yCbCr2.Cr);
// Gray
Color color3 = Color.Gray;
Color32 color3 = Color32.Gray;
YCbCr yCbCr3 = color3;
Assert.Equal(128, yCbCr3.Y);
Assert.Equal(128, yCbCr3.Cb);
@ -51,7 +51,7 @@ namespace ImageSharp.Tests
}
/// <summary>
/// Tests the implicit conversion from <see cref="YCbCr"/> to <see cref="Color"/>.
/// Tests the implicit conversion from <see cref="YCbCr"/> to <see cref="Color32"/>.
/// </summary>
[Fact]
[SuppressMessage("StyleCop.CSharp.NamingRules", "SA1305:FieldNamesMustNotUseHungarianNotation",
@ -60,7 +60,7 @@ namespace ImageSharp.Tests
{
// White
YCbCr yCbCr = new YCbCr(255, 128, 128);
Color color = yCbCr;
Color32 color = yCbCr;
Assert.Equal(255, color.R);
Assert.Equal(255, color.G);
@ -69,7 +69,7 @@ namespace ImageSharp.Tests
// Black
YCbCr yCbCr2 = new YCbCr(0, 128, 128);
Color color2 = yCbCr2;
Color32 color2 = yCbCr2;
Assert.Equal(0, color2.R);
Assert.Equal(0, color2.G);
@ -78,7 +78,7 @@ namespace ImageSharp.Tests
// Gray
YCbCr yCbCr3 = new YCbCr(128, 128, 128);
Color color3 = yCbCr3;
Color32 color3 = yCbCr3;
Assert.Equal(128, color3.R);
Assert.Equal(128, color3.G);
@ -87,7 +87,7 @@ namespace ImageSharp.Tests
}
/// <summary>
/// Tests the implicit conversion from <see cref="Color"/> to <see cref="CieXyz"/>.
/// Tests the implicit conversion from <see cref="Color32"/> to <see cref="CieXyz"/>.
/// Comparison values obtained from
/// http://colormine.org/convert/rgb-to-xyz
/// </summary>
@ -95,7 +95,7 @@ namespace ImageSharp.Tests
public void ColorToCieXyz()
{
// White
Color color = Color.White;
Color32 color = Color32.White;
CieXyz ciexyz = color;
Assert.Equal(95.05f, ciexyz.X, 3);
@ -103,21 +103,21 @@ namespace ImageSharp.Tests
Assert.Equal(108.900f, ciexyz.Z, 3);
// Black
Color color2 = Color.Black;
Color32 color2 = Color32.Black;
CieXyz ciexyz2 = color2;
Assert.Equal(0, ciexyz2.X, 3);
Assert.Equal(0, ciexyz2.Y, 3);
Assert.Equal(0, ciexyz2.Z, 3);
// Gray
Color color3 = Color.Gray;
Color32 color3 = Color32.Gray;
CieXyz ciexyz3 = color3;
Assert.Equal(20.518, ciexyz3.X, 3);
Assert.Equal(21.586, ciexyz3.Y, 3);
Assert.Equal(23.507, ciexyz3.Z, 3);
// Cyan
Color color4 = Color.Cyan;
Color32 color4 = Color32.Cyan;
CieXyz ciexyz4 = color4;
Assert.Equal(53.810f, ciexyz4.X, 3);
Assert.Equal(78.740f, ciexyz4.Y, 3);
@ -125,7 +125,7 @@ namespace ImageSharp.Tests
}
/// <summary>
/// Tests the implicit conversion from <see cref="CieXyz"/> to <see cref="Color"/>.
/// Tests the implicit conversion from <see cref="CieXyz"/> to <see cref="Color32"/>.
/// Comparison values obtained from
/// http://colormine.org/convert/rgb-to-xyz
/// </summary>
@ -134,7 +134,7 @@ namespace ImageSharp.Tests
{
// Dark moderate pink.
CieXyz ciexyz = new CieXyz(13.337f, 9.297f, 14.727f);
Color color = ciexyz;
Color32 color = ciexyz;
Assert.Equal(128, color.R);
Assert.Equal(64, color.G);
@ -142,7 +142,7 @@ namespace ImageSharp.Tests
// Ochre
CieXyz ciexyz2 = new CieXyz(31.787f, 26.147f, 4.885f);
Color color2 = ciexyz2;
Color32 color2 = ciexyz2;
Assert.Equal(204, color2.R);
Assert.Equal(119, color2.G);
@ -150,7 +150,7 @@ namespace ImageSharp.Tests
// Black
CieXyz ciexyz3 = new CieXyz(0, 0, 0);
Color color3 = ciexyz3;
Color32 color3 = ciexyz3;
Assert.Equal(0, color3.R);
Assert.Equal(0, color3.G);
@ -167,7 +167,7 @@ namespace ImageSharp.Tests
}
/// <summary>
/// Tests the implicit conversion from <see cref="Color"/> to <see cref="Hsv"/>.
/// Tests the implicit conversion from <see cref="Color32"/> to <see cref="Hsv"/>.
/// </summary>
[Fact]
[SuppressMessage("StyleCop.CSharp.NamingRules", "SA1305:FieldNamesMustNotUseHungarianNotation",
@ -175,7 +175,7 @@ namespace ImageSharp.Tests
public void ColorToHsv()
{
// Black
Color b = Color.Black;
Color32 b = Color32.Black;
Hsv h = b;
Assert.Equal(0, h.H, 1);
@ -183,7 +183,7 @@ namespace ImageSharp.Tests
Assert.Equal(0, h.V, 1);
// White
Color color = Color.White;
Color32 color = Color32.White;
Hsv hsv = color;
Assert.Equal(0f, hsv.H, 1);
@ -191,7 +191,7 @@ namespace ImageSharp.Tests
Assert.Equal(1f, hsv.V, 1);
// Dark moderate pink.
Color color2 = new Color(128, 64, 106);
Color32 color2 = new Color32(128, 64, 106);
Hsv hsv2 = color2;
Assert.Equal(320.6f, hsv2.H, 1);
@ -199,7 +199,7 @@ namespace ImageSharp.Tests
Assert.Equal(0.502f, hsv2.V, 2);
// Ochre.
Color color3 = new Color(204, 119, 34);
Color32 color3 = new Color32(204, 119, 34);
Hsv hsv3 = color3;
Assert.Equal(30f, hsv3.H, 1);
@ -208,14 +208,14 @@ namespace ImageSharp.Tests
}
/// <summary>
/// Tests the implicit conversion from <see cref="Hsv"/> to <see cref="Color"/>.
/// Tests the implicit conversion from <see cref="Hsv"/> to <see cref="Color32"/>.
/// </summary>
[Fact]
public void HsvToColor()
{
// Dark moderate pink.
Hsv hsv = new Hsv(320.6f, 0.5f, 0.502f);
Color color = hsv;
Color32 color = hsv;
Assert.Equal(color.R, 128);
Assert.Equal(color.G, 64);
@ -223,7 +223,7 @@ namespace ImageSharp.Tests
// Ochre
Hsv hsv2 = new Hsv(30, 0.833f, 0.8f);
Color color2 = hsv2;
Color32 color2 = hsv2;
Assert.Equal(color2.R, 204);
Assert.Equal(color2.G, 119);
@ -231,7 +231,7 @@ namespace ImageSharp.Tests
// White
Hsv hsv3 = new Hsv(0, 0, 1);
Color color3 = hsv3;
Color32 color3 = hsv3;
Assert.Equal(color3.B, 255);
Assert.Equal(color3.G, 255);
@ -248,7 +248,7 @@ namespace ImageSharp.Tests
}
/// <summary>
/// Tests the implicit conversion from <see cref="Color"/> to <see cref="Hsl"/>.
/// Tests the implicit conversion from <see cref="Color32"/> to <see cref="Hsl"/>.
/// </summary>
[Fact]
[SuppressMessage("StyleCop.CSharp.NamingRules", "SA1305:FieldNamesMustNotUseHungarianNotation",
@ -256,7 +256,7 @@ namespace ImageSharp.Tests
public void ColorToHsl()
{
// Black
Color b = Color.Black;
Color32 b = Color32.Black;
Hsl h = b;
Assert.Equal(0, h.H, 1);
@ -264,7 +264,7 @@ namespace ImageSharp.Tests
Assert.Equal(0, h.L, 1);
// White
Color color = Color.White;
Color32 color = Color32.White;
Hsl hsl = color;
Assert.Equal(0f, hsl.H, 1);
@ -272,7 +272,7 @@ namespace ImageSharp.Tests
Assert.Equal(1f, hsl.L, 1);
// Dark moderate pink.
Color color2 = new Color(128, 64, 106);
Color32 color2 = new Color32(128, 64, 106);
Hsl hsl2 = color2;
Assert.Equal(320.6f, hsl2.H, 1);
@ -280,7 +280,7 @@ namespace ImageSharp.Tests
Assert.Equal(0.376f, hsl2.L, 2);
// Ochre.
Color color3 = new Color(204, 119, 34);
Color32 color3 = new Color32(204, 119, 34);
Hsl hsl3 = color3;
Assert.Equal(30f, hsl3.H, 1);
@ -289,14 +289,14 @@ namespace ImageSharp.Tests
}
/// <summary>
/// Tests the implicit conversion from <see cref="Hsl"/> to <see cref="Color"/>.
/// Tests the implicit conversion from <see cref="Hsl"/> to <see cref="Color32"/>.
/// </summary>
[Fact]
public void HslToColor()
{
// Dark moderate pink.
Hsl hsl = new Hsl(320.6f, 0.33f, 0.376f);
Color color = hsl;
Color32 color = hsl;
Assert.Equal(color.R, 128);
Assert.Equal(color.G, 64);
@ -304,7 +304,7 @@ namespace ImageSharp.Tests
// Ochre
Hsl hsl2 = new Hsl(30, 0.714f, 0.467f);
Color color2 = hsl2;
Color32 color2 = hsl2;
Assert.Equal(color2.R, 204);
Assert.Equal(color2.G, 119);
@ -312,7 +312,7 @@ namespace ImageSharp.Tests
// White
Hsl hsl3 = new Hsl(0, 0, 1);
Color color3 = hsl3;
Color32 color3 = hsl3;
Assert.Equal(color3.R, 255);
Assert.Equal(color3.G, 255);
@ -329,7 +329,7 @@ namespace ImageSharp.Tests
}
/// <summary>
/// Tests the implicit conversion from <see cref="Color"/> to <see cref="Cmyk"/>.
/// Tests the implicit conversion from <see cref="Color32"/> to <see cref="Cmyk"/>.
/// </summary>
[Fact]
[SuppressMessage("StyleCop.CSharp.NamingRules", "SA1305:FieldNamesMustNotUseHungarianNotation",
@ -337,7 +337,7 @@ namespace ImageSharp.Tests
public void ColorToCmyk()
{
// White
Color color = Color.White;
Color32 color = Color32.White;
Cmyk cmyk = color;
Assert.Equal(0, cmyk.C, 1);
@ -346,7 +346,7 @@ namespace ImageSharp.Tests
Assert.Equal(0, cmyk.K, 1);
// Black
Color color2 = Color.Black;
Color32 color2 = Color32.Black;
Cmyk cmyk2 = color2;
Assert.Equal(0, cmyk2.C, 1);
Assert.Equal(0, cmyk2.M, 1);
@ -354,7 +354,7 @@ namespace ImageSharp.Tests
Assert.Equal(1, cmyk2.K, 1);
// Gray
Color color3 = Color.Gray;
Color32 color3 = Color32.Gray;
Cmyk cmyk3 = color3;
Assert.Equal(0f, cmyk3.C, 1);
Assert.Equal(0f, cmyk3.M, 1);
@ -362,7 +362,7 @@ namespace ImageSharp.Tests
Assert.Equal(0.498, cmyk3.K, 2); // Checked with other online converters.
// Cyan
Color color4 = Color.Cyan;
Color32 color4 = Color32.Cyan;
Cmyk cmyk4 = color4;
Assert.Equal(1, cmyk4.C, 1);
Assert.Equal(0f, cmyk4.M, 1);
@ -371,14 +371,14 @@ namespace ImageSharp.Tests
}
/// <summary>
/// Tests the implicit conversion from <see cref="Cmyk"/> to <see cref="Color"/>.
/// Tests the implicit conversion from <see cref="Cmyk"/> to <see cref="Color32"/>.
/// </summary>
[Fact]
public void CmykToColor()
{
// Dark moderate pink.
Cmyk cmyk = new Cmyk(0f, .5f, .171f, .498f);
Color color = cmyk;
Color32 color = cmyk;
Assert.Equal(color.R, 128);
Assert.Equal(color.G, 64);
@ -386,7 +386,7 @@ namespace ImageSharp.Tests
// Ochre
Cmyk cmyk2 = new Cmyk(0, .416f, .833f, .199f);
Color color2 = cmyk2;
Color32 color2 = cmyk2;
Assert.Equal(color2.R, 204);
Assert.Equal(color2.G, 119);
@ -394,7 +394,7 @@ namespace ImageSharp.Tests
// White
Cmyk cmyk3 = new Cmyk(0, 0, 0, 0);
Color color3 = cmyk3;
Color32 color3 = cmyk3;
Assert.Equal(color3.R, 255);
Assert.Equal(color3.G, 255);
@ -411,7 +411,7 @@ namespace ImageSharp.Tests
}
/// <summary>
/// Tests the implicit conversion from <see cref="Color"/> to <see cref="CieLab"/>.
/// Tests the implicit conversion from <see cref="Color32"/> to <see cref="CieLab"/>.
/// Comparison values obtained from
/// http://colormine.org/convert/rgb-to-lab
/// </summary>
@ -419,7 +419,7 @@ namespace ImageSharp.Tests
public void ColorToCieLab()
{
// White
Color color = Color.White;
Color32 color = Color32.White;
CieLab cielab = color;
Assert.Equal(100, cielab.L, 3);
@ -427,21 +427,21 @@ namespace ImageSharp.Tests
Assert.Equal(-0.010, cielab.B, 3);
// Black
Color color2 = Color.Black;
Color32 color2 = Color32.Black;
CieLab cielab2 = color2;
Assert.Equal(0, cielab2.L, 3);
Assert.Equal(0, cielab2.A, 3);
Assert.Equal(0, cielab2.B, 3);
// Gray
Color color3 = Color.Gray;
Color32 color3 = Color32.Gray;
CieLab cielab3 = color3;
Assert.Equal(53.585, cielab3.L, 3);
Assert.Equal(0.003, cielab3.A, 3);
Assert.Equal(-0.006, cielab3.B, 3);
// Cyan
Color color4 = Color.Cyan;
Color32 color4 = Color32.Cyan;
CieLab cielab4 = color4;
Assert.Equal(91.117, cielab4.L, 3);
Assert.Equal(-48.080, cielab4.A, 3);
@ -449,7 +449,7 @@ namespace ImageSharp.Tests
}
/// <summary>
/// Tests the implicit conversion from <see cref="CieLab"/> to <see cref="Color"/>.
/// Tests the implicit conversion from <see cref="CieLab"/> to <see cref="Color32"/>.
/// </summary>
/// Comparison values obtained from
/// http://colormine.org/convert/rgb-to-lab
@ -458,7 +458,7 @@ namespace ImageSharp.Tests
{
// Dark moderate pink.
CieLab cielab = new CieLab(36.5492f, 33.3173f, -12.0615f);
Color color = cielab;
Color32 color = cielab;
Assert.Equal(color.R, 128);
Assert.Equal(color.G, 64);
@ -466,7 +466,7 @@ namespace ImageSharp.Tests
// Ochre
CieLab cielab2 = new CieLab(58.1758f, 27.3399f, 56.8240f);
Color color2 = cielab2;
Color32 color2 = cielab2;
Assert.Equal(color2.R, 204);
Assert.Equal(color2.G, 119);
@ -474,7 +474,7 @@ namespace ImageSharp.Tests
// Black
CieLab cielab3 = new CieLab(0, 0, 0);
Color color3 = cielab3;
Color32 color3 = cielab3;
Assert.Equal(color3.R, 0);
Assert.Equal(color3.G, 0);

10
tests/ImageSharp.Tests/Colors/ColorDefinitionTests.cs

@ -15,14 +15,14 @@ namespace ImageSharp.Tests
using Xunit;
public class ColorDefinitionTests
{
public static IEnumerable<string[]> ColorNames => typeof(NamedColors<Color>).GetTypeInfo().GetFields().Select(x => new[] { x.Name });
public static IEnumerable<string[]> ColorNames => typeof(NamedColors<Color32>).GetTypeInfo().GetFields().Select(x => new[] { x.Name });
[Theory]
[MemberData(nameof(ColorNames))]
public void AllColorsAreOnGenericAndBaseColor(string name)
{
FieldInfo generic = typeof(NamedColors<Color>).GetTypeInfo().GetField(name);
FieldInfo specific = typeof(Color).GetTypeInfo().GetField(name);
FieldInfo generic = typeof(NamedColors<Color32>).GetTypeInfo().GetField(name);
FieldInfo specific = typeof(Color32).GetTypeInfo().GetField(name);
Assert.NotNull(specific);
Assert.NotNull(generic);
@ -30,8 +30,8 @@ namespace ImageSharp.Tests
Assert.True(specific.Attributes.HasFlag(FieldAttributes.Static), "specific must be static");
Assert.True(generic.Attributes.HasFlag(FieldAttributes.Public), "generic must be public");
Assert.True(generic.Attributes.HasFlag(FieldAttributes.Static), "generic must be static");
Color expected = (Color)generic.GetValue(null);
Color actual = (Color)specific.GetValue(null);
Color32 expected = (Color32)generic.GetValue(null);
Color32 actual = (Color32)specific.GetValue(null);
Assert.Equal(expected, actual);
}
}

36
tests/ImageSharp.Tests/Colors/ColorTests.cs

@ -11,7 +11,7 @@ namespace ImageSharp.Tests
using Xunit;
/// <summary>
/// Tests the <see cref="Color"/> struct.
/// Tests the <see cref="Color32"/> struct.
/// </summary>
public class ColorTests
{
@ -21,12 +21,12 @@ namespace ImageSharp.Tests
[Fact]
public void AreEqual()
{
Color color1 = new Color(0, 0, 0);
Color color2 = new Color(0, 0, 0, 1F);
Color color3 = Color.FromHex("#000");
Color color4 = Color.FromHex("#000F");
Color color5 = Color.FromHex("#000000");
Color color6 = Color.FromHex("#000000FF");
Color32 color1 = new Color32(0, 0, 0);
Color32 color2 = new Color32(0, 0, 0, 1F);
Color32 color3 = Color32.FromHex("#000");
Color32 color4 = Color32.FromHex("#000F");
Color32 color5 = Color32.FromHex("#000000");
Color32 color6 = Color32.FromHex("#000000FF");
Assert.Equal(color1, color2);
Assert.Equal(color1, color3);
@ -41,11 +41,11 @@ namespace ImageSharp.Tests
[Fact]
public void AreNotEqual()
{
Color color1 = new Color(255, 0, 0, 255);
Color color2 = new Color(0, 0, 0, 255);
Color color3 = Color.FromHex("#000");
Color color4 = Color.FromHex("#000000");
Color color5 = Color.FromHex("#FF000000");
Color32 color1 = new Color32(255, 0, 0, 255);
Color32 color2 = new Color32(0, 0, 0, 255);
Color32 color3 = Color32.FromHex("#000");
Color32 color4 = Color32.FromHex("#000000");
Color32 color5 = Color32.FromHex("#FF000000");
Assert.NotEqual(color1, color2);
Assert.NotEqual(color1, color3);
@ -59,25 +59,25 @@ namespace ImageSharp.Tests
[Fact]
public void ConstructorAssignsProperties()
{
Color color1 = new Color(1, .1f, .133f, .864f);
Color32 color1 = new Color32(1, .1f, .133f, .864f);
Assert.Equal(255, color1.R);
Assert.Equal((byte)Math.Round(.1f * 255), color1.G);
Assert.Equal((byte)Math.Round(.133f * 255), color1.B);
Assert.Equal((byte)Math.Round(.864f * 255), color1.A);
Color color2 = new Color(1, .1f, .133f);
Color32 color2 = new Color32(1, .1f, .133f);
Assert.Equal(255, color2.R);
Assert.Equal(Math.Round(.1f * 255), color2.G);
Assert.Equal(Math.Round(.133f * 255), color2.B);
Assert.Equal(255, color2.A);
Color color4 = new Color(new Vector3(1, .1f, .133f));
Color32 color4 = new Color32(new Vector3(1, .1f, .133f));
Assert.Equal(255, color4.R);
Assert.Equal(Math.Round(.1f * 255), color4.G);
Assert.Equal(Math.Round(.133f * 255), color4.B);
Assert.Equal(255, color4.A);
Color color5 = new Color(new Vector4(1, .1f, .133f, .5f));
Color32 color5 = new Color32(new Vector4(1, .1f, .133f, .5f));
Assert.Equal(255, color5.R);
Assert.Equal(Math.Round(.1f * 255), color5.G);
Assert.Equal(Math.Round(.133f * 255), color5.B);
@ -90,7 +90,7 @@ namespace ImageSharp.Tests
[Fact]
public void FromAndToHex()
{
Color color = Color.FromHex("#AABBCCDD");
Color32 color = Color32.FromHex("#AABBCCDD");
Assert.Equal(170, color.R);
Assert.Equal(187, color.G);
Assert.Equal(204, color.B);
@ -118,7 +118,7 @@ namespace ImageSharp.Tests
[Fact]
public unsafe void ByteLayout()
{
Color color = new Color(1, 2, 3, 4);
Color32 color = new Color32(1, 2, 3, 4);
byte* colorBase = (byte*)&color;
Assert.Equal(1, colorBase[0]);
Assert.Equal(2, colorBase[1]);

58
tests/ImageSharp.Tests/Colors/ColorTransformTests.cs

@ -16,101 +16,101 @@ namespace ImageSharp.Tests.Colors
/// <summary>
/// Orange backdrop
/// </summary>
private static readonly Color Backdrop = new Color(204, 102, 0);
private static readonly Color32 Backdrop = new Color32(204, 102, 0);
/// <summary>
/// Blue source
/// </summary>
private static readonly Color Source = new Color(0, 102, 153);
private static readonly Color32 Source = new Color32(0, 102, 153);
[Fact]
public void Normal()
{
Color normal = Color.Normal(Backdrop, Source);
Color32 normal = Color32.Normal(Backdrop, Source);
Assert.True(normal == Source);
}
[Fact]
public void Multiply()
{
Assert.True(Color.Multiply(Backdrop, Color.Black) == Color.Black);
Assert.True(Color.Multiply(Backdrop, Color.White) == Backdrop);
Assert.True(Color32.Multiply(Backdrop, Color32.Black) == Color32.Black);
Assert.True(Color32.Multiply(Backdrop, Color32.White) == Backdrop);
Color multiply = Color.Multiply(Backdrop, Source);
Assert.True(multiply == new Color(0, 41, 0));
Color32 multiply = Color32.Multiply(Backdrop, Source);
Assert.True(multiply == new Color32(0, 41, 0));
}
[Fact]
public void Screen()
{
Assert.True(Color.Screen(Backdrop, Color.Black) == Backdrop);
Assert.True(Color.Screen(Backdrop, Color.White) == Color.White);
Assert.True(Color32.Screen(Backdrop, Color32.Black) == Backdrop);
Assert.True(Color32.Screen(Backdrop, Color32.White) == Color32.White);
Color screen = Color.Screen(Backdrop, Source);
Assert.True(screen == new Color(204, 163, 153));
Color32 screen = Color32.Screen(Backdrop, Source);
Assert.True(screen == new Color32(204, 163, 153));
}
[Fact]
public void HardLight()
{
Color hardLight = Color.HardLight(Backdrop, Source);
Assert.True(hardLight == new Color(0, 82, 51));
Color32 hardLight = Color32.HardLight(Backdrop, Source);
Assert.True(hardLight == new Color32(0, 82, 51));
}
[Fact]
public void Overlay()
{
Color overlay = Color.Overlay(Backdrop, Source);
Assert.True(overlay == new Color(153, 82, 0));
Color32 overlay = Color32.Overlay(Backdrop, Source);
Assert.True(overlay == new Color32(153, 82, 0));
}
[Fact]
public void Darken()
{
Color darken = Color.Darken(Backdrop, Source);
Assert.True(darken == new Color(0, 102, 0));
Color32 darken = Color32.Darken(Backdrop, Source);
Assert.True(darken == new Color32(0, 102, 0));
}
[Fact]
public void Lighten()
{
Color lighten = Color.Lighten(Backdrop, Source);
Assert.True(lighten == new Color(204, 102, 153));
Color32 lighten = Color32.Lighten(Backdrop, Source);
Assert.True(lighten == new Color32(204, 102, 153));
}
[Fact]
public void SoftLight()
{
Color softLight = Color.SoftLight(Backdrop, Source);
Assert.True(softLight == new Color(163, 90, 0));
Color32 softLight = Color32.SoftLight(Backdrop, Source);
Assert.True(softLight == new Color32(163, 90, 0));
}
[Fact]
public void ColorDodge()
{
Color colorDodge = Color.ColorDodge(Backdrop, Source);
Assert.True(colorDodge == new Color(204, 170, 0));
Color32 colorDodge = Color32.ColorDodge(Backdrop, Source);
Assert.True(colorDodge == new Color32(204, 170, 0));
}
[Fact]
public void ColorBurn()
{
Color colorBurn = Color.ColorBurn(Backdrop, Source);
Assert.True(colorBurn == new Color(0, 0, 0));
Color32 colorBurn = Color32.ColorBurn(Backdrop, Source);
Assert.True(colorBurn == new Color32(0, 0, 0));
}
[Fact]
public void Difference()
{
Color difference = Color.Difference(Backdrop, Source);
Assert.True(difference == new Color(204, 0, 153));
Color32 difference = Color32.Difference(Backdrop, Source);
Assert.True(difference == new Color32(204, 0, 153));
}
[Fact]
public void Exclusion()
{
Color exclusion = Color.Exclusion(Backdrop, Source);
Assert.True(exclusion == new Color(204, 122, 153));
Color32 exclusion = Color32.Exclusion(Backdrop, Source);
Assert.True(exclusion == new Color32(204, 122, 153));
}
}
}

6
tests/ImageSharp.Tests/Common/BufferSpanTests.cs

@ -420,12 +420,12 @@ namespace ImageSharp.Tests.Common
[Fact]
public void ColorToBytes()
{
Color[] colors = { new Color(0, 1, 2, 3), new Color(4, 5, 6, 7), new Color(8, 9, 10, 11), };
Color32[] colors = { new Color32(0, 1, 2, 3), new Color32(4, 5, 6, 7), new Color32(8, 9, 10, 11), };
using (PinnedBuffer<Color> colorBuf = new PinnedBuffer<Color>(colors))
using (PinnedBuffer<Color32> colorBuf = new PinnedBuffer<Color32>(colors))
using (PinnedBuffer<byte> byteBuf = new PinnedBuffer<byte>(colors.Length*4))
{
BufferSpan.Copy<Color>(colorBuf, byteBuf, colorBuf.Length);
BufferSpan.Copy<Color32>(colorBuf, byteBuf, colorBuf.Length);
byte[] a = byteBuf.Array;

8
tests/ImageSharp.Tests/Common/PixelDataPoolTests.cs

@ -18,7 +18,7 @@ namespace ImageSharp.Tests
[Fact]
public void PixelDataPoolRentsMinimumSize()
{
Color[] pixels = PixelDataPool<Color>.Rent(1024);
Color32[] pixels = PixelDataPool<Color32>.Rent(1024);
Assert.True(pixels.Length >= 1024);
}
@ -26,9 +26,9 @@ namespace ImageSharp.Tests
[Fact]
public void PixelDataPoolDoesNotThrowWhenReturningNonPooled()
{
Color[] pixels = new Color[1024];
Color32[] pixels = new Color32[1024];
PixelDataPool<Color>.Return(pixels);
PixelDataPool<Color32>.Return(pixels);
Assert.True(pixels.Length >= 1024);
}
@ -39,7 +39,7 @@ namespace ImageSharp.Tests
public void CalculateMaxArrayLength(bool isRawData)
{
int max = isRawData ? PixelDataPool<int>.CalculateMaxArrayLength()
: PixelDataPool<Color>.CalculateMaxArrayLength();
: PixelDataPool<Color32>.CalculateMaxArrayLength();
Assert.Equal(max < int.MaxValue, !isRawData);
}

32
tests/ImageSharp.Tests/Drawing/BeziersTests.cs

@ -23,8 +23,8 @@ namespace ImageSharp.Tests.Drawing
{
using (FileStream output = File.OpenWrite($"{path}/Simple.png"))
{
image.BackgroundColor(Color.Blue)
.DrawBeziers(Color.HotPink, 5,
image.BackgroundColor(Color32.Blue)
.DrawBeziers(Color32.HotPink, 5,
new[] {
new Vector2(10, 400),
new Vector2(30, 10),
@ -34,21 +34,21 @@ namespace ImageSharp.Tests.Drawing
.Save(output);
}
using (PixelAccessor<Color> sourcePixels = image.Lock())
using (PixelAccessor<Color32> sourcePixels = image.Lock())
{
//top of curve
Assert.Equal(Color.HotPink, sourcePixels[138, 115]);
Assert.Equal(Color32.HotPink, sourcePixels[138, 115]);
//start points
Assert.Equal(Color.HotPink, sourcePixels[10, 400]);
Assert.Equal(Color.HotPink, sourcePixels[300, 400]);
Assert.Equal(Color32.HotPink, sourcePixels[10, 400]);
Assert.Equal(Color32.HotPink, sourcePixels[300, 400]);
//curve points should not be never be set
Assert.Equal(Color.Blue, sourcePixels[30, 10]);
Assert.Equal(Color.Blue, sourcePixels[240, 30]);
Assert.Equal(Color32.Blue, sourcePixels[30, 10]);
Assert.Equal(Color32.Blue, sourcePixels[240, 30]);
// inside shape should be empty
Assert.Equal(Color.Blue, sourcePixels[200, 250]);
Assert.Equal(Color32.Blue, sourcePixels[200, 250]);
}
}
}
@ -59,13 +59,13 @@ namespace ImageSharp.Tests.Drawing
{
string path = this.CreateOutputDirectory("Drawing", "BezierLine");
Color color = new Color(Color.HotPink.R, Color.HotPink.G, Color.HotPink.B, 150);
Color32 color = new Color32(Color32.HotPink.R, Color32.HotPink.G, Color32.HotPink.B, 150);
using (Image image = new Image(500, 500))
{
using (FileStream output = File.OpenWrite($"{path}/Opacity.png"))
{
image.BackgroundColor(Color.Blue)
image.BackgroundColor(Color32.Blue)
.DrawBeziers(color,
10,
new[] {
@ -78,9 +78,9 @@ namespace ImageSharp.Tests.Drawing
}
//shift background color towards forground color by the opacity amount
Color mergedColor = new Color(Vector4.Lerp(Color.Blue.ToVector4(), Color.HotPink.ToVector4(), 150f / 255f));
Color32 mergedColor = new Color32(Vector4.Lerp(Color32.Blue.ToVector4(), Color32.HotPink.ToVector4(), 150f / 255f));
using (PixelAccessor<Color> sourcePixels = image.Lock())
using (PixelAccessor<Color32> sourcePixels = image.Lock())
{
//top of curve
Assert.Equal(mergedColor, sourcePixels[138, 115]);
@ -90,11 +90,11 @@ namespace ImageSharp.Tests.Drawing
Assert.Equal(mergedColor, sourcePixels[300, 400]);
//curve points should not be never be set
Assert.Equal(Color.Blue, sourcePixels[30, 10]);
Assert.Equal(Color.Blue, sourcePixels[240, 30]);
Assert.Equal(Color32.Blue, sourcePixels[30, 10]);
Assert.Equal(Color32.Blue, sourcePixels[240, 30]);
// inside shape should be empty
Assert.Equal(Color.Blue, sourcePixels[200, 250]);
Assert.Equal(Color32.Blue, sourcePixels[200, 250]);
}
}
}

22
tests/ImageSharp.Tests/Drawing/DrawPathTests.cs

@ -38,18 +38,18 @@ namespace ImageSharp.Tests.Drawing
using (FileStream output = File.OpenWrite($"{path}/Simple.png"))
{
image
.BackgroundColor(Color.Blue)
.Draw(Color.HotPink, 5, p)
.BackgroundColor(Color32.Blue)
.Draw(Color32.HotPink, 5, p)
.Save(output);
}
using (PixelAccessor<Color> sourcePixels = image.Lock())
using (PixelAccessor<Color32> sourcePixels = image.Lock())
{
Assert.Equal(Color.HotPink, sourcePixels[9, 9]);
Assert.Equal(Color32.HotPink, sourcePixels[9, 9]);
Assert.Equal(Color.HotPink, sourcePixels[199, 149]);
Assert.Equal(Color32.HotPink, sourcePixels[199, 149]);
Assert.Equal(Color.Blue, sourcePixels[50, 50]);
Assert.Equal(Color32.Blue, sourcePixels[50, 50]);
}
}
}
@ -60,7 +60,7 @@ namespace ImageSharp.Tests.Drawing
{
string path = this.CreateOutputDirectory("Drawing", "Path");
Color color = new Color(Color.HotPink.R, Color.HotPink.G, Color.HotPink.B, 150);
Color32 color = new Color32(Color32.HotPink.R, Color32.HotPink.G, Color32.HotPink.B, 150);
LinearLineSegment linerSegemnt = new LinearLineSegment(
@ -81,21 +81,21 @@ namespace ImageSharp.Tests.Drawing
using (FileStream output = File.OpenWrite($"{path}/Opacity.png"))
{
image
.BackgroundColor(Color.Blue)
.BackgroundColor(Color32.Blue)
.Draw(color, 10, p)
.Save(output);
}
//shift background color towards forground color by the opacity amount
Color mergedColor = new Color(Vector4.Lerp(Color.Blue.ToVector4(), Color.HotPink.ToVector4(), 150f / 255f));
Color32 mergedColor = new Color32(Vector4.Lerp(Color32.Blue.ToVector4(), Color32.HotPink.ToVector4(), 150f / 255f));
using (PixelAccessor<Color> sourcePixels = image.Lock())
using (PixelAccessor<Color32> sourcePixels = image.Lock())
{
Assert.Equal(mergedColor, sourcePixels[9, 9]);
Assert.Equal(mergedColor, sourcePixels[199, 149]);
Assert.Equal(Color.Blue, sourcePixels[50, 50]);
Assert.Equal(Color32.Blue, sourcePixels[50, 50]);
}
}
}

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

@ -15,7 +15,7 @@ namespace ImageSharp.Tests.Drawing
public class FillPatternBrushTests : FileTestBase
{
private void Test(string name, Color background, IBrush<Color> brush, Color[,] expectedPattern)
private void Test(string name, Color32 background, IBrush<Color32> brush, Color32[,] expectedPattern)
{
string path = this.CreateOutputDirectory("Fill", "PatternBrush");
using (Image image = new Image(20, 20))
@ -29,11 +29,11 @@ namespace ImageSharp.Tests.Drawing
image.Save(output);
}
using (PixelAccessor<Color> sourcePixels = image.Lock())
using (PixelAccessor<Color32> sourcePixels = image.Lock())
{
// lets pick random spots to start checking
Random r = new Random();
Fast2DArray<Color> expectedPatternFast = new Fast2DArray<Color>(expectedPattern);
Fast2DArray<Color32> expectedPatternFast = new Fast2DArray<Color32>(expectedPattern);
int xStride = expectedPatternFast.Width;
int yStride = expectedPatternFast.Height;
int offsetX = r.Next(image.Width / xStride) * xStride;
@ -44,8 +44,8 @@ namespace ImageSharp.Tests.Drawing
{
int actualX = x + offsetX;
int actualY = y + offsetY;
Color expected = expectedPatternFast[y, x]; // inverted pattern
Color actual = sourcePixels[actualX, actualY];
Color32 expected = expectedPatternFast[y, x]; // inverted pattern
Color32 actual = sourcePixels[actualX, actualY];
if (expected != actual)
{
Assert.True(false, $"Expected {expected} but found {actual} at ({actualX},{actualY})");
@ -63,73 +63,73 @@ namespace ImageSharp.Tests.Drawing
[Fact]
public void ImageShouldBeFloodFilledWithPercent10()
{
this.Test("Percent10", Color.Blue, Brushes.Percent10(Color.HotPink, Color.LimeGreen),
this.Test("Percent10", Color32.Blue, Brushes.Percent10(Color32.HotPink, Color32.LimeGreen),
new[,]
{
{ Color.HotPink , Color.LimeGreen, Color.LimeGreen, Color.LimeGreen},
{ Color.LimeGreen, Color.LimeGreen, Color.LimeGreen, Color.LimeGreen},
{ Color.LimeGreen, Color.LimeGreen, Color.HotPink , Color.LimeGreen},
{ Color.LimeGreen, Color.LimeGreen, Color.LimeGreen, Color.LimeGreen}
{ Color32.HotPink , Color32.LimeGreen, Color32.LimeGreen, Color32.LimeGreen},
{ Color32.LimeGreen, Color32.LimeGreen, Color32.LimeGreen, Color32.LimeGreen},
{ Color32.LimeGreen, Color32.LimeGreen, Color32.HotPink , Color32.LimeGreen},
{ Color32.LimeGreen, Color32.LimeGreen, Color32.LimeGreen, Color32.LimeGreen}
});
}
[Fact]
public void ImageShouldBeFloodFilledWithPercent10Transparent()
{
Test("Percent10_Transparent", Color.Blue, Brushes.Percent10(Color.HotPink),
new Color[,] {
{ Color.HotPink , Color.Blue, Color.Blue, Color.Blue},
{ Color.Blue, Color.Blue, Color.Blue, Color.Blue},
{ Color.Blue, Color.Blue, Color.HotPink , Color.Blue},
{ Color.Blue, Color.Blue, Color.Blue, Color.Blue}
Test("Percent10_Transparent", Color32.Blue, Brushes.Percent10(Color32.HotPink),
new Color32[,] {
{ Color32.HotPink , Color32.Blue, Color32.Blue, Color32.Blue},
{ Color32.Blue, Color32.Blue, Color32.Blue, Color32.Blue},
{ Color32.Blue, Color32.Blue, Color32.HotPink , Color32.Blue},
{ Color32.Blue, Color32.Blue, Color32.Blue, Color32.Blue}
});
}
[Fact]
public void ImageShouldBeFloodFilledWithPercent20()
{
Test("Percent20", Color.Blue, Brushes.Percent20(Color.HotPink, Color.LimeGreen),
new Color[,] {
{ Color.HotPink , Color.LimeGreen, Color.LimeGreen, Color.LimeGreen},
{ Color.LimeGreen, Color.LimeGreen, Color.HotPink , Color.LimeGreen},
{ Color.HotPink , Color.LimeGreen, Color.LimeGreen, Color.LimeGreen},
{ Color.LimeGreen, Color.LimeGreen, Color.HotPink , Color.LimeGreen}
Test("Percent20", Color32.Blue, Brushes.Percent20(Color32.HotPink, Color32.LimeGreen),
new Color32[,] {
{ Color32.HotPink , Color32.LimeGreen, Color32.LimeGreen, Color32.LimeGreen},
{ Color32.LimeGreen, Color32.LimeGreen, Color32.HotPink , Color32.LimeGreen},
{ Color32.HotPink , Color32.LimeGreen, Color32.LimeGreen, Color32.LimeGreen},
{ Color32.LimeGreen, Color32.LimeGreen, Color32.HotPink , Color32.LimeGreen}
});
}
[Fact]
public void ImageShouldBeFloodFilledWithPercent20_transparent()
{
Test("Percent20_Transparent", Color.Blue, Brushes.Percent20(Color.HotPink),
new Color[,] {
{ Color.HotPink , Color.Blue, Color.Blue, Color.Blue},
{ Color.Blue, Color.Blue, Color.HotPink , Color.Blue},
{ Color.HotPink , Color.Blue, Color.Blue, Color.Blue},
{ Color.Blue, Color.Blue, Color.HotPink , Color.Blue}
Test("Percent20_Transparent", Color32.Blue, Brushes.Percent20(Color32.HotPink),
new Color32[,] {
{ Color32.HotPink , Color32.Blue, Color32.Blue, Color32.Blue},
{ Color32.Blue, Color32.Blue, Color32.HotPink , Color32.Blue},
{ Color32.HotPink , Color32.Blue, Color32.Blue, Color32.Blue},
{ Color32.Blue, Color32.Blue, Color32.HotPink , Color32.Blue}
});
}
[Fact]
public void ImageShouldBeFloodFilledWithHorizontal()
{
Test("Horizontal", Color.Blue, Brushes.Horizontal(Color.HotPink, Color.LimeGreen),
new Color[,] {
{ Color.LimeGreen , Color.LimeGreen, Color.LimeGreen, Color.LimeGreen},
{ Color.HotPink, Color.HotPink, Color.HotPink , Color.HotPink},
{ Color.LimeGreen , Color.LimeGreen, Color.LimeGreen, Color.LimeGreen},
{ Color.LimeGreen, Color.LimeGreen, Color.LimeGreen , Color.LimeGreen}
Test("Horizontal", Color32.Blue, Brushes.Horizontal(Color32.HotPink, Color32.LimeGreen),
new Color32[,] {
{ Color32.LimeGreen , Color32.LimeGreen, Color32.LimeGreen, Color32.LimeGreen},
{ Color32.HotPink, Color32.HotPink, Color32.HotPink , Color32.HotPink},
{ Color32.LimeGreen , Color32.LimeGreen, Color32.LimeGreen, Color32.LimeGreen},
{ Color32.LimeGreen, Color32.LimeGreen, Color32.LimeGreen , Color32.LimeGreen}
});
}
[Fact]
public void ImageShouldBeFloodFilledWithHorizontal_transparent()
{
Test("Horizontal_Transparent", Color.Blue, Brushes.Horizontal(Color.HotPink),
new Color[,] {
{ Color.Blue , Color.Blue, Color.Blue, Color.Blue},
{ Color.HotPink, Color.HotPink, Color.HotPink , Color.HotPink},
{ Color.Blue , Color.Blue, Color.Blue, Color.Blue},
{ Color.Blue, Color.Blue, Color.Blue , Color.Blue}
Test("Horizontal_Transparent", Color32.Blue, Brushes.Horizontal(Color32.HotPink),
new Color32[,] {
{ Color32.Blue , Color32.Blue, Color32.Blue, Color32.Blue},
{ Color32.HotPink, Color32.HotPink, Color32.HotPink , Color32.HotPink},
{ Color32.Blue , Color32.Blue, Color32.Blue, Color32.Blue},
{ Color32.Blue, Color32.Blue, Color32.Blue , Color32.Blue}
});
}
@ -138,96 +138,96 @@ namespace ImageSharp.Tests.Drawing
[Fact]
public void ImageShouldBeFloodFilledWithMin()
{
Test("Min", Color.Blue, Brushes.Min(Color.HotPink, Color.LimeGreen),
new Color[,] {
{ Color.LimeGreen , Color.LimeGreen, Color.LimeGreen, Color.LimeGreen},
{ Color.LimeGreen , Color.LimeGreen, Color.LimeGreen, Color.LimeGreen},
{ Color.LimeGreen, Color.LimeGreen, Color.LimeGreen , Color.LimeGreen},
{ Color.HotPink, Color.HotPink, Color.HotPink , Color.HotPink}
Test("Min", Color32.Blue, Brushes.Min(Color32.HotPink, Color32.LimeGreen),
new Color32[,] {
{ Color32.LimeGreen , Color32.LimeGreen, Color32.LimeGreen, Color32.LimeGreen},
{ Color32.LimeGreen , Color32.LimeGreen, Color32.LimeGreen, Color32.LimeGreen},
{ Color32.LimeGreen, Color32.LimeGreen, Color32.LimeGreen , Color32.LimeGreen},
{ Color32.HotPink, Color32.HotPink, Color32.HotPink , Color32.HotPink}
});
}
[Fact]
public void ImageShouldBeFloodFilledWithMin_transparent()
{
Test("Min_Transparent", Color.Blue, Brushes.Min(Color.HotPink),
new Color[,] {
{ Color.Blue , Color.Blue, Color.Blue, Color.Blue},
{ Color.Blue , Color.Blue, Color.Blue, Color.Blue},
{ Color.Blue, Color.Blue, Color.Blue , Color.Blue},
{ Color.HotPink, Color.HotPink, Color.HotPink , Color.HotPink},
Test("Min_Transparent", Color32.Blue, Brushes.Min(Color32.HotPink),
new Color32[,] {
{ Color32.Blue , Color32.Blue, Color32.Blue, Color32.Blue},
{ Color32.Blue , Color32.Blue, Color32.Blue, Color32.Blue},
{ Color32.Blue, Color32.Blue, Color32.Blue , Color32.Blue},
{ Color32.HotPink, Color32.HotPink, Color32.HotPink , Color32.HotPink},
});
}
[Fact]
public void ImageShouldBeFloodFilledWithVertical()
{
Test("Vertical", Color.Blue, Brushes.Vertical(Color.HotPink, Color.LimeGreen),
new Color[,] {
{ Color.LimeGreen, Color.HotPink, Color.LimeGreen, Color.LimeGreen},
{ Color.LimeGreen, Color.HotPink, Color.LimeGreen, Color.LimeGreen},
{ Color.LimeGreen, Color.HotPink, Color.LimeGreen, Color.LimeGreen},
{ Color.LimeGreen, Color.HotPink, Color.LimeGreen, Color.LimeGreen}
Test("Vertical", Color32.Blue, Brushes.Vertical(Color32.HotPink, Color32.LimeGreen),
new Color32[,] {
{ Color32.LimeGreen, Color32.HotPink, Color32.LimeGreen, Color32.LimeGreen},
{ Color32.LimeGreen, Color32.HotPink, Color32.LimeGreen, Color32.LimeGreen},
{ Color32.LimeGreen, Color32.HotPink, Color32.LimeGreen, Color32.LimeGreen},
{ Color32.LimeGreen, Color32.HotPink, Color32.LimeGreen, Color32.LimeGreen}
});
}
[Fact]
public void ImageShouldBeFloodFilledWithVertical_transparent()
{
Test("Vertical_Transparent", Color.Blue, Brushes.Vertical(Color.HotPink),
new Color[,] {
{ Color.Blue, Color.HotPink, Color.Blue, Color.Blue},
{ Color.Blue, Color.HotPink, Color.Blue, Color.Blue},
{ Color.Blue, Color.HotPink, Color.Blue, Color.Blue},
{ Color.Blue, Color.HotPink, Color.Blue, Color.Blue}
Test("Vertical_Transparent", Color32.Blue, Brushes.Vertical(Color32.HotPink),
new Color32[,] {
{ Color32.Blue, Color32.HotPink, Color32.Blue, Color32.Blue},
{ Color32.Blue, Color32.HotPink, Color32.Blue, Color32.Blue},
{ Color32.Blue, Color32.HotPink, Color32.Blue, Color32.Blue},
{ Color32.Blue, Color32.HotPink, Color32.Blue, Color32.Blue}
});
}
[Fact]
public void ImageShouldBeFloodFilledWithForwardDiagonal()
{
Test("ForwardDiagonal", Color.Blue, Brushes.ForwardDiagonal(Color.HotPink, Color.LimeGreen),
new Color[,] {
{ Color.LimeGreen, Color.LimeGreen, Color.LimeGreen, Color.HotPink},
{ Color.LimeGreen, Color.LimeGreen, Color.HotPink, Color.LimeGreen},
{ Color.LimeGreen, Color.HotPink, Color.LimeGreen, Color.LimeGreen},
{ Color.HotPink, Color.LimeGreen, Color.LimeGreen, Color.LimeGreen}
Test("ForwardDiagonal", Color32.Blue, Brushes.ForwardDiagonal(Color32.HotPink, Color32.LimeGreen),
new Color32[,] {
{ Color32.LimeGreen, Color32.LimeGreen, Color32.LimeGreen, Color32.HotPink},
{ Color32.LimeGreen, Color32.LimeGreen, Color32.HotPink, Color32.LimeGreen},
{ Color32.LimeGreen, Color32.HotPink, Color32.LimeGreen, Color32.LimeGreen},
{ Color32.HotPink, Color32.LimeGreen, Color32.LimeGreen, Color32.LimeGreen}
});
}
[Fact]
public void ImageShouldBeFloodFilledWithForwardDiagonal_transparent()
{
Test("ForwardDiagonal_Transparent", Color.Blue, Brushes.ForwardDiagonal(Color.HotPink),
new Color[,] {
{ Color.Blue, Color.Blue, Color.Blue, Color.HotPink},
{ Color.Blue, Color.Blue, Color.HotPink, Color.Blue},
{ Color.Blue, Color.HotPink, Color.Blue, Color.Blue},
{ Color.HotPink, Color.Blue, Color.Blue, Color.Blue}
Test("ForwardDiagonal_Transparent", Color32.Blue, Brushes.ForwardDiagonal(Color32.HotPink),
new Color32[,] {
{ Color32.Blue, Color32.Blue, Color32.Blue, Color32.HotPink},
{ Color32.Blue, Color32.Blue, Color32.HotPink, Color32.Blue},
{ Color32.Blue, Color32.HotPink, Color32.Blue, Color32.Blue},
{ Color32.HotPink, Color32.Blue, Color32.Blue, Color32.Blue}
});
}
[Fact]
public void ImageShouldBeFloodFilledWithBackwardDiagonal()
{
Test("BackwardDiagonal", Color.Blue, Brushes.BackwardDiagonal(Color.HotPink, Color.LimeGreen),
new Color[,] {
{ Color.HotPink, Color.LimeGreen, Color.LimeGreen, Color.LimeGreen},
{ Color.LimeGreen, Color.HotPink, Color.LimeGreen, Color.LimeGreen},
{ Color.LimeGreen, Color.LimeGreen, Color.HotPink, Color.LimeGreen},
{ Color.LimeGreen, Color.LimeGreen, Color.LimeGreen, Color.HotPink}
Test("BackwardDiagonal", Color32.Blue, Brushes.BackwardDiagonal(Color32.HotPink, Color32.LimeGreen),
new Color32[,] {
{ Color32.HotPink, Color32.LimeGreen, Color32.LimeGreen, Color32.LimeGreen},
{ Color32.LimeGreen, Color32.HotPink, Color32.LimeGreen, Color32.LimeGreen},
{ Color32.LimeGreen, Color32.LimeGreen, Color32.HotPink, Color32.LimeGreen},
{ Color32.LimeGreen, Color32.LimeGreen, Color32.LimeGreen, Color32.HotPink}
});
}
[Fact]
public void ImageShouldBeFloodFilledWithBackwardDiagonal_transparent()
{
Test("BackwardDiagonal_Transparent", Color.Blue, Brushes.BackwardDiagonal(Color.HotPink),
new Color[,] {
{ Color.HotPink, Color.Blue, Color.Blue, Color.Blue},
{ Color.Blue, Color.HotPink, Color.Blue, Color.Blue},
{ Color.Blue, Color.Blue, Color.HotPink, Color.Blue},
{ Color.Blue, Color.Blue, Color.Blue, Color.HotPink}
Test("BackwardDiagonal_Transparent", Color32.Blue, Brushes.BackwardDiagonal(Color32.HotPink),
new Color32[,] {
{ Color32.HotPink, Color32.Blue, Color32.Blue, Color32.Blue},
{ Color32.Blue, Color32.HotPink, Color32.Blue, Color32.Blue},
{ Color32.Blue, Color32.Blue, Color32.HotPink, Color32.Blue},
{ Color32.Blue, Color32.Blue, Color32.Blue, Color32.HotPink}
});
}
}

4
tests/ImageSharp.Tests/Drawing/FillRegionProcessorTests.cs

@ -29,14 +29,14 @@ namespace ImageSharp.Tests.Drawing
{
ImageSharp.Rectangle bounds = new ImageSharp.Rectangle(0, 0, 1, 1);
Mock<IBrush<Color>> brush = new Mock<IBrush<Color>>();
Mock<IBrush<Color32>> brush = new Mock<IBrush<Color32>>();
Mock<Region> region = new Mock<Region>();
region.Setup(x => x.Bounds).Returns(bounds);
GraphicsOptions options = new GraphicsOptions(antialias) {
AntialiasSubpixelDepth = 1
};
FillRegionProcessor<Color> processor = new FillRegionProcessor<Color>(brush.Object, region.Object, options);
FillRegionProcessor<Color32> processor = new FillRegionProcessor<Color32>(brush.Object, region.Object, options);
Image img = new Image(1, 1);
processor.Apply(img, bounds);

26
tests/ImageSharp.Tests/Drawing/FillSolidBrushTests.cs

@ -24,15 +24,15 @@ namespace ImageSharp.Tests.Drawing
using (FileStream output = File.OpenWrite($"{path}/DefaultBack.png"))
{
image
.Fill(Color.HotPink)
.Fill(Color32.HotPink)
.Save(output);
}
using (PixelAccessor<Color> sourcePixels = image.Lock())
using (PixelAccessor<Color32> sourcePixels = image.Lock())
{
Assert.Equal(Color.HotPink, sourcePixels[9, 9]);
Assert.Equal(Color32.HotPink, sourcePixels[9, 9]);
Assert.Equal(Color.HotPink, sourcePixels[199, 149]);
Assert.Equal(Color32.HotPink, sourcePixels[199, 149]);
}
}
}
@ -46,16 +46,16 @@ namespace ImageSharp.Tests.Drawing
using (FileStream output = File.OpenWrite($"{path}/Simple.png"))
{
image
.BackgroundColor(Color.Blue)
.Fill(Color.HotPink)
.BackgroundColor(Color32.Blue)
.Fill(Color32.HotPink)
.Save(output);
}
using (PixelAccessor<Color> sourcePixels = image.Lock())
using (PixelAccessor<Color32> sourcePixels = image.Lock())
{
Assert.Equal(Color.HotPink, sourcePixels[9, 9]);
Assert.Equal(Color32.HotPink, sourcePixels[9, 9]);
Assert.Equal(Color.HotPink, sourcePixels[199, 149]);
Assert.Equal(Color32.HotPink, sourcePixels[199, 149]);
}
}
}
@ -66,20 +66,20 @@ namespace ImageSharp.Tests.Drawing
string path = this.CreateOutputDirectory("Fill", "SolidBrush");
using (Image image = new Image(500, 500))
{
Color color = new Color(Color.HotPink.R, Color.HotPink.G, Color.HotPink.B, 150);
Color32 color = new Color32(Color32.HotPink.R, Color32.HotPink.G, Color32.HotPink.B, 150);
using (FileStream output = File.OpenWrite($"{path}/Opacity.png"))
{
image
.BackgroundColor(Color.Blue)
.BackgroundColor(Color32.Blue)
.Fill(color)
.Save(output);
}
//shift background color towards forground color by the opacity amount
Color mergedColor = new Color(Vector4.Lerp(Color.Blue.ToVector4(), Color.HotPink.ToVector4(), 150f / 255f));
Color32 mergedColor = new Color32(Vector4.Lerp(Color32.Blue.ToVector4(), Color32.HotPink.ToVector4(), 150f / 255f));
using (PixelAccessor<Color> sourcePixels = image.Lock())
using (PixelAccessor<Color32> sourcePixels = image.Lock())
{
Assert.Equal(mergedColor, sourcePixels[9, 9]);
Assert.Equal(mergedColor, sourcePixels[199, 149]);

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

@ -36,33 +36,33 @@ namespace ImageSharp.Tests.Drawing
using (FileStream output = File.OpenWrite($"{path}/Simple.png"))
{
image
.BackgroundColor(Color.Blue)
.Draw(Color.HotPink, 5, simplePath.Clip(hole1))
.BackgroundColor(Color32.Blue)
.Draw(Color32.HotPink, 5, simplePath.Clip(hole1))
.Save(output);
}
using (PixelAccessor<Color> sourcePixels = image.Lock())
using (PixelAccessor<Color32> sourcePixels = image.Lock())
{
Assert.Equal(Color.HotPink, sourcePixels[10, 10]);
Assert.Equal(Color32.HotPink, sourcePixels[10, 10]);
Assert.Equal(Color.HotPink, sourcePixels[200, 150]);
Assert.Equal(Color32.HotPink, sourcePixels[200, 150]);
Assert.Equal(Color.HotPink, sourcePixels[50, 300]);
Assert.Equal(Color32.HotPink, sourcePixels[50, 300]);
Assert.Equal(Color.HotPink, sourcePixels[37, 85]);
Assert.Equal(Color32.HotPink, sourcePixels[37, 85]);
Assert.Equal(Color.HotPink, sourcePixels[93, 85]);
Assert.Equal(Color32.HotPink, sourcePixels[93, 85]);
Assert.Equal(Color.HotPink, sourcePixels[65, 137]);
Assert.Equal(Color32.HotPink, sourcePixels[65, 137]);
Assert.Equal(Color.Blue, sourcePixels[2, 2]);
Assert.Equal(Color32.Blue, sourcePixels[2, 2]);
//inside hole
Assert.Equal(Color.Blue, sourcePixels[57, 99]);
Assert.Equal(Color32.Blue, sourcePixels[57, 99]);
//inside shape
Assert.Equal(Color.Blue, sourcePixels[100, 192]);
Assert.Equal(Color32.Blue, sourcePixels[100, 192]);
}
}
}
@ -86,18 +86,18 @@ namespace ImageSharp.Tests.Drawing
using (FileStream output = File.OpenWrite($"{path}/SimpleVanishHole.png"))
{
image
.BackgroundColor(Color.Blue)
.Draw(Color.HotPink, 5, simplePath.Clip(hole1))
.BackgroundColor(Color32.Blue)
.Draw(Color32.HotPink, 5, simplePath.Clip(hole1))
.Save(output);
}
using (PixelAccessor<Color> sourcePixels = image.Lock())
using (PixelAccessor<Color32> sourcePixels = image.Lock())
{
Assert.Equal(Color.HotPink, sourcePixels[10, 10]);
Assert.Equal(Color32.HotPink, sourcePixels[10, 10]);
Assert.Equal(Color.HotPink, sourcePixels[200, 150]);
Assert.Equal(Color32.HotPink, sourcePixels[200, 150]);
Assert.Equal(Color.HotPink, sourcePixels[50, 300]);
Assert.Equal(Color32.HotPink, sourcePixels[50, 300]);
//Assert.Equal(Color.HotPink, sourcePixels[37, 85]);
@ -106,13 +106,13 @@ namespace ImageSharp.Tests.Drawing
//Assert.Equal(Color.HotPink, sourcePixels[65, 137]);
Assert.Equal(Color.Blue, sourcePixels[2, 2]);
Assert.Equal(Color32.Blue, sourcePixels[2, 2]);
//inside hole
Assert.Equal(Color.Blue, sourcePixels[57, 99]);
Assert.Equal(Color32.Blue, sourcePixels[57, 99]);
//inside shape
Assert.Equal(Color.Blue, sourcePixels[100, 192]);
Assert.Equal(Color32.Blue, sourcePixels[100, 192]);
}
}
}
@ -137,28 +137,28 @@ namespace ImageSharp.Tests.Drawing
using (FileStream output = File.OpenWrite($"{path}/SimpleOverlapping.png"))
{
image
.BackgroundColor(Color.Blue)
.Draw(Color.HotPink, 5, simplePath.Clip(hole1))
.BackgroundColor(Color32.Blue)
.Draw(Color32.HotPink, 5, simplePath.Clip(hole1))
.Save(output);
}
using (PixelAccessor<Color> sourcePixels = image.Lock())
using (PixelAccessor<Color32> sourcePixels = image.Lock())
{
Assert.Equal(Color.HotPink, sourcePixels[10, 10]);
Assert.Equal(Color32.HotPink, sourcePixels[10, 10]);
Assert.Equal(Color.HotPink, sourcePixels[200, 150]);
Assert.Equal(Color32.HotPink, sourcePixels[200, 150]);
Assert.Equal(Color.HotPink, sourcePixels[50, 300]);
Assert.Equal(Color32.HotPink, sourcePixels[50, 300]);
Assert.Equal(Color.Blue, sourcePixels[130, 41]);
Assert.Equal(Color32.Blue, sourcePixels[130, 41]);
Assert.Equal(Color.Blue, sourcePixels[2, 2]);
Assert.Equal(Color32.Blue, sourcePixels[2, 2]);
//inside hole
Assert.Equal(Color.Blue, sourcePixels[57, 99]);
Assert.Equal(Color32.Blue, sourcePixels[57, 99]);
//inside shape
Assert.Equal(Color.Blue, sourcePixels[100, 192]);
Assert.Equal(Color32.Blue, sourcePixels[100, 192]);
}
}
}
@ -183,8 +183,8 @@ namespace ImageSharp.Tests.Drawing
using (FileStream output = File.OpenWrite($"{path}/Dashed.png"))
{
image
.BackgroundColor(Color.Blue)
.Draw(Pens.Dash(Color.HotPink, 5), simplePath.Clip(hole1))
.BackgroundColor(Color32.Blue)
.Draw(Pens.Dash(Color32.HotPink, 5), simplePath.Clip(hole1))
.Save(output);
}
}
@ -204,22 +204,22 @@ namespace ImageSharp.Tests.Drawing
new Vector2(37, 85),
new Vector2(93, 85),
new Vector2(65, 137)));
Color color = new Color(Color.HotPink.R, Color.HotPink.G, Color.HotPink.B, 150);
Color32 color = new Color32(Color32.HotPink.R, Color32.HotPink.G, Color32.HotPink.B, 150);
using (Image image = new Image(500, 500))
{
using (FileStream output = File.OpenWrite($"{path}/Opacity.png"))
{
image
.BackgroundColor(Color.Blue)
.BackgroundColor(Color32.Blue)
.Draw(color, 5, simplePath.Clip(hole1))
.Save(output);
}
//shift background color towards forground color by the opacity amount
Color mergedColor = new Color(Vector4.Lerp(Color.Blue.ToVector4(), Color.HotPink.ToVector4(), 150f / 255f));
Color32 mergedColor = new Color32(Vector4.Lerp(Color32.Blue.ToVector4(), Color32.HotPink.ToVector4(), 150f / 255f));
using (PixelAccessor<Color> sourcePixels = image.Lock())
using (PixelAccessor<Color32> sourcePixels = image.Lock())
{
Assert.Equal(mergedColor, sourcePixels[10, 10]);
@ -234,14 +234,14 @@ namespace ImageSharp.Tests.Drawing
Assert.Equal(mergedColor, sourcePixels[65, 137]);
Assert.Equal(Color.Blue, sourcePixels[2, 2]);
Assert.Equal(Color32.Blue, sourcePixels[2, 2]);
//inside hole
Assert.Equal(Color.Blue, sourcePixels[57, 99]);
Assert.Equal(Color32.Blue, sourcePixels[57, 99]);
//inside shape
Assert.Equal(Color.Blue, sourcePixels[100, 192]);
Assert.Equal(Color32.Blue, sourcePixels[100, 192]);
}
}
}

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

@ -23,8 +23,8 @@ namespace ImageSharp.Tests.Drawing
using (FileStream output = File.OpenWrite($"{path}/Simple.png"))
{
image
.BackgroundColor(Color.Blue)
.DrawLines(Color.HotPink, 5,
.BackgroundColor(Color32.Blue)
.DrawLines(Color32.HotPink, 5,
new[] {
new Vector2(10, 10),
new Vector2(200, 150),
@ -33,13 +33,13 @@ namespace ImageSharp.Tests.Drawing
.Save(output);
}
using (PixelAccessor<Color> sourcePixels = image.Lock())
using (PixelAccessor<Color32> sourcePixels = image.Lock())
{
Assert.Equal(Color.HotPink, sourcePixels[9, 9]);
Assert.Equal(Color32.HotPink, sourcePixels[9, 9]);
Assert.Equal(Color.HotPink, sourcePixels[199, 149]);
Assert.Equal(Color32.HotPink, sourcePixels[199, 149]);
Assert.Equal(Color.Blue, sourcePixels[50, 50]);
Assert.Equal(Color32.Blue, sourcePixels[50, 50]);
}
}
}
@ -53,8 +53,8 @@ namespace ImageSharp.Tests.Drawing
using (FileStream output = File.OpenWrite($"{path}/Simple_noantialias.png"))
{
image
.BackgroundColor(Color.Blue)
.DrawLines(Color.HotPink, 5,
.BackgroundColor(Color32.Blue)
.DrawLines(Color32.HotPink, 5,
new[] {
new Vector2(10, 10),
new Vector2(200, 150),
@ -64,13 +64,13 @@ namespace ImageSharp.Tests.Drawing
.Save(output);
}
using (PixelAccessor<Color> sourcePixels = image.Lock())
using (PixelAccessor<Color32> sourcePixels = image.Lock())
{
Assert.Equal(Color.HotPink, sourcePixels[9, 9]);
Assert.Equal(Color32.HotPink, sourcePixels[9, 9]);
Assert.Equal(Color.HotPink, sourcePixels[199, 149]);
Assert.Equal(Color32.HotPink, sourcePixels[199, 149]);
Assert.Equal(Color.Blue, sourcePixels[50, 50]);
Assert.Equal(Color32.Blue, sourcePixels[50, 50]);
}
}
}
@ -84,8 +84,8 @@ namespace ImageSharp.Tests.Drawing
using (FileStream output = File.OpenWrite($"{path}/Dashed.png"))
{
image
.BackgroundColor(Color.Blue)
.DrawLines(Pens.Dash(Color.HotPink, 5),
.BackgroundColor(Color32.Blue)
.DrawLines(Pens.Dash(Color32.HotPink, 5),
new[] {
new Vector2(10, 10),
new Vector2(200, 150),
@ -105,8 +105,8 @@ namespace ImageSharp.Tests.Drawing
using (FileStream output = File.OpenWrite($"{path}/Dot.png"))
{
image
.BackgroundColor(Color.Blue)
.DrawLines(Pens.Dot(Color.HotPink, 5),
.BackgroundColor(Color32.Blue)
.DrawLines(Pens.Dot(Color32.HotPink, 5),
new[] {
new Vector2(10, 10),
new Vector2(200, 150),
@ -126,8 +126,8 @@ namespace ImageSharp.Tests.Drawing
using (FileStream output = File.OpenWrite($"{path}/DashDot.png"))
{
image
.BackgroundColor(Color.Blue)
.DrawLines(Pens.DashDot(Color.HotPink, 5),
.BackgroundColor(Color32.Blue)
.DrawLines(Pens.DashDot(Color32.HotPink, 5),
new[] {
new Vector2(10, 10),
new Vector2(200, 150),
@ -147,8 +147,8 @@ namespace ImageSharp.Tests.Drawing
using (FileStream output = File.OpenWrite($"{path}/DashDotDot.png"))
{
image
.BackgroundColor(Color.Blue)
.DrawLines(Pens.DashDotDot(Color.HotPink, 5), new[] {
.BackgroundColor(Color32.Blue)
.DrawLines(Pens.DashDotDot(Color32.HotPink, 5), new[] {
new Vector2(10, 10),
new Vector2(200, 150),
new Vector2(50, 300)
@ -162,7 +162,7 @@ namespace ImageSharp.Tests.Drawing
{
string path = this.CreateOutputDirectory("Drawing", "Lines");
Color color = new Color(Color.HotPink.R, Color.HotPink.G, Color.HotPink.B, 150);
Color32 color = new Color32(Color32.HotPink.R, Color32.HotPink.G, Color32.HotPink.B, 150);
Image image = new Image(500, 500);
@ -170,7 +170,7 @@ namespace ImageSharp.Tests.Drawing
using (FileStream output = File.OpenWrite($"{path}/Opacity.png"))
{
image
.BackgroundColor(Color.Blue)
.BackgroundColor(Color32.Blue)
.DrawLines(color, 10, new[] {
new Vector2(10, 10),
new Vector2(200, 150),
@ -180,15 +180,15 @@ namespace ImageSharp.Tests.Drawing
}
//shift background color towards forground color by the opacity amount
Color mergedColor = new Color(Vector4.Lerp(Color.Blue.ToVector4(), Color.HotPink.ToVector4(), 150f/255f));
Color32 mergedColor = new Color32(Vector4.Lerp(Color32.Blue.ToVector4(), Color32.HotPink.ToVector4(), 150f/255f));
using (PixelAccessor<Color> sourcePixels = image.Lock())
using (PixelAccessor<Color32> sourcePixels = image.Lock())
{
Assert.Equal(mergedColor, sourcePixels[9, 9]);
Assert.Equal(mergedColor, sourcePixels[199, 149]);
Assert.Equal(Color.Blue, sourcePixels[50, 50]);
Assert.Equal(Color32.Blue, sourcePixels[50, 50]);
}
}
@ -202,8 +202,8 @@ namespace ImageSharp.Tests.Drawing
using (FileStream output = File.OpenWrite($"{path}/Rectangle.png"))
{
image
.BackgroundColor(Color.Blue)
.DrawLines(Color.HotPink, 10, new[] {
.BackgroundColor(Color32.Blue)
.DrawLines(Color32.HotPink, 10, new[] {
new Vector2(10, 10),
new Vector2(200, 10),
new Vector2(200, 150),
@ -212,15 +212,15 @@ namespace ImageSharp.Tests.Drawing
.Save(output);
}
using (PixelAccessor<Color> sourcePixels = image.Lock())
using (PixelAccessor<Color32> sourcePixels = image.Lock())
{
Assert.Equal(Color.HotPink, sourcePixels[8, 8]);
Assert.Equal(Color32.HotPink, sourcePixels[8, 8]);
Assert.Equal(Color.HotPink, sourcePixels[198, 10]);
Assert.Equal(Color32.HotPink, sourcePixels[198, 10]);
Assert.Equal(Color.Blue, sourcePixels[10, 50]);
Assert.Equal(Color32.Blue, sourcePixels[10, 50]);
Assert.Equal(Color.Blue, sourcePixels[50, 50]);
Assert.Equal(Color32.Blue, sourcePixels[50, 50]);
}
}

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

@ -18,9 +18,9 @@ namespace ImageSharp.Tests.Drawing.Paths
{
float thickness = 7.2f;
GraphicsOptions noneDefault = new GraphicsOptions();
Color color = Color.HotPink;
SolidBrush brush = Brushes.Solid(Color.HotPink);
Pen pen = new Pen(Color.Firebrick, 99.9f);
Color32 color = Color32.HotPink;
SolidBrush brush = Brushes.Solid(Color32.HotPink);
Pen pen = new Pen(Color32.Firebrick, 99.9f);
Vector2[] points = new Vector2[] {
new Vector2(10,10),
new Vector2(20,10),
@ -45,7 +45,7 @@ namespace ImageSharp.Tests.Drawing.Paths
img.DrawBeziers(brush, thickness, points);
Assert.NotEmpty(img.ProcessorApplications);
DrawPathProcessor<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor);
DrawPathProcessor<Color32> processor = Assert.IsType<DrawPathProcessor<Color32>>(img.ProcessorApplications[0].processor);
Assert.Equal(GraphicsOptions.Default, processor.Options);
@ -56,7 +56,7 @@ namespace ImageSharp.Tests.Drawing.Paths
BezierLineSegment segment = Assert.IsType<BezierLineSegment>(vector.LineSegments[0]);
Pen<Color> pen = Assert.IsType<Pen<Color>>(processor.Pen);
Pen<Color32> pen = Assert.IsType<Pen<Color32>>(processor.Pen);
Assert.Equal(brush, pen.Brush);
Assert.Equal(thickness, pen.Width);
}
@ -67,7 +67,7 @@ namespace ImageSharp.Tests.Drawing.Paths
img.DrawBeziers(brush, thickness, points, noneDefault);
Assert.NotEmpty(img.ProcessorApplications);
DrawPathProcessor<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor);
DrawPathProcessor<Color32> processor = Assert.IsType<DrawPathProcessor<Color32>>(img.ProcessorApplications[0].processor);
Assert.Equal(noneDefault, processor.Options);
@ -76,7 +76,7 @@ namespace ImageSharp.Tests.Drawing.Paths
SixLabors.Shapes.Path vector = Assert.IsType<SixLabors.Shapes.Path>(path.Path);
BezierLineSegment segment = Assert.IsType<BezierLineSegment>(vector.LineSegments[0]);
Pen<Color> pen = Assert.IsType<Pen<Color>>(processor.Pen);
Pen<Color32> pen = Assert.IsType<Pen<Color32>>(processor.Pen);
Assert.Equal(brush, pen.Brush);
Assert.Equal(thickness, pen.Width);
}
@ -87,7 +87,7 @@ namespace ImageSharp.Tests.Drawing.Paths
img.DrawBeziers(color, thickness, points);
Assert.NotEmpty(img.ProcessorApplications);
DrawPathProcessor<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor);
DrawPathProcessor<Color32> processor = Assert.IsType<DrawPathProcessor<Color32>>(img.ProcessorApplications[0].processor);
Assert.Equal(GraphicsOptions.Default, processor.Options);
@ -96,10 +96,10 @@ namespace ImageSharp.Tests.Drawing.Paths
SixLabors.Shapes.Path vector = Assert.IsType<SixLabors.Shapes.Path>(path.Path);
BezierLineSegment segment = Assert.IsType<BezierLineSegment>(vector.LineSegments[0]);
Pen<Color> pen = Assert.IsType<Pen<Color>>(processor.Pen);
Pen<Color32> pen = Assert.IsType<Pen<Color32>>(processor.Pen);
Assert.Equal(thickness, pen.Width);
SolidBrush<Color> brush = Assert.IsType<SolidBrush<Color>>(pen.Brush);
SolidBrush<Color32> brush = Assert.IsType<SolidBrush<Color32>>(pen.Brush);
Assert.Equal(color, brush.Color);
}
@ -109,7 +109,7 @@ namespace ImageSharp.Tests.Drawing.Paths
img.DrawBeziers(color, thickness, points, noneDefault);
Assert.NotEmpty(img.ProcessorApplications);
DrawPathProcessor<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor);
DrawPathProcessor<Color32> processor = Assert.IsType<DrawPathProcessor<Color32>>(img.ProcessorApplications[0].processor);
Assert.Equal(noneDefault, processor.Options);
@ -118,10 +118,10 @@ namespace ImageSharp.Tests.Drawing.Paths
SixLabors.Shapes.Path vector = Assert.IsType<SixLabors.Shapes.Path>(path.Path);
BezierLineSegment segment = Assert.IsType<BezierLineSegment>(vector.LineSegments[0]);
Pen<Color> pen = Assert.IsType<Pen<Color>>(processor.Pen);
Pen<Color32> pen = Assert.IsType<Pen<Color32>>(processor.Pen);
Assert.Equal(thickness, pen.Width);
SolidBrush<Color> brush = Assert.IsType<SolidBrush<Color>>(pen.Brush);
SolidBrush<Color32> brush = Assert.IsType<SolidBrush<Color32>>(pen.Brush);
Assert.Equal(color, brush.Color);
}
@ -131,7 +131,7 @@ namespace ImageSharp.Tests.Drawing.Paths
img.DrawBeziers(pen, points);
Assert.NotEmpty(img.ProcessorApplications);
DrawPathProcessor<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor);
DrawPathProcessor<Color32> processor = Assert.IsType<DrawPathProcessor<Color32>>(img.ProcessorApplications[0].processor);
Assert.Equal(GraphicsOptions.Default, processor.Options);
@ -149,7 +149,7 @@ namespace ImageSharp.Tests.Drawing.Paths
img.DrawBeziers(pen, points, noneDefault);
Assert.NotEmpty(img.ProcessorApplications);
DrawPathProcessor<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor);
DrawPathProcessor<Color32> processor = Assert.IsType<DrawPathProcessor<Color32>>(img.ProcessorApplications[0].processor);
Assert.Equal(noneDefault, processor.Options);

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

@ -18,9 +18,9 @@ namespace ImageSharp.Tests.Drawing.Paths
{
float thickness = 7.2f;
GraphicsOptions noneDefault = new GraphicsOptions();
Color color = Color.HotPink;
SolidBrush brush = Brushes.Solid(Color.HotPink);
Pen pen = new Pen(Color.Gray, 99.9f);
Color32 color = Color32.HotPink;
SolidBrush brush = Brushes.Solid(Color32.HotPink);
Pen pen = new Pen(Color32.Gray, 99.9f);
Vector2[] points = new Vector2[] {
new Vector2(10,10),
new Vector2(20,10),
@ -45,7 +45,7 @@ namespace ImageSharp.Tests.Drawing.Paths
img.DrawLines(brush, thickness, points);
Assert.NotEmpty(img.ProcessorApplications);
DrawPathProcessor<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor);
DrawPathProcessor<Color32> processor = Assert.IsType<DrawPathProcessor<Color32>>(img.ProcessorApplications[0].processor);
Assert.Equal(GraphicsOptions.Default, processor.Options);
@ -54,7 +54,7 @@ namespace ImageSharp.Tests.Drawing.Paths
SixLabors.Shapes.Path vector = Assert.IsType<SixLabors.Shapes.Path>(path.Path);
LinearLineSegment segment = Assert.IsType<LinearLineSegment>(vector.LineSegments[0]);
Pen<Color> pen = Assert.IsType<Pen<Color>>(processor.Pen);
Pen<Color32> pen = Assert.IsType<Pen<Color32>>(processor.Pen);
Assert.Equal(brush, pen.Brush);
Assert.Equal(thickness, pen.Width);
}
@ -65,7 +65,7 @@ namespace ImageSharp.Tests.Drawing.Paths
img.DrawLines(brush, thickness, points, noneDefault);
Assert.NotEmpty(img.ProcessorApplications);
DrawPathProcessor<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor);
DrawPathProcessor<Color32> processor = Assert.IsType<DrawPathProcessor<Color32>>(img.ProcessorApplications[0].processor);
Assert.Equal(noneDefault, processor.Options);
@ -74,7 +74,7 @@ namespace ImageSharp.Tests.Drawing.Paths
SixLabors.Shapes.Path vector = Assert.IsType<SixLabors.Shapes.Path>(path.Path);
LinearLineSegment segment = Assert.IsType<LinearLineSegment>(vector.LineSegments[0]);
Pen<Color> pen = Assert.IsType<Pen<Color>>(processor.Pen);
Pen<Color32> pen = Assert.IsType<Pen<Color32>>(processor.Pen);
Assert.Equal(brush, pen.Brush);
Assert.Equal(thickness, pen.Width);
}
@ -85,7 +85,7 @@ namespace ImageSharp.Tests.Drawing.Paths
img.DrawLines(color, thickness, points);
Assert.NotEmpty(img.ProcessorApplications);
DrawPathProcessor<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor);
DrawPathProcessor<Color32> processor = Assert.IsType<DrawPathProcessor<Color32>>(img.ProcessorApplications[0].processor);
Assert.Equal(GraphicsOptions.Default, processor.Options);
@ -94,10 +94,10 @@ namespace ImageSharp.Tests.Drawing.Paths
SixLabors.Shapes.Path vector = Assert.IsType<SixLabors.Shapes.Path>(path.Path);
LinearLineSegment segment = Assert.IsType<LinearLineSegment>(vector.LineSegments[0]);
Pen<Color> pen = Assert.IsType<Pen<Color>>(processor.Pen);
Pen<Color32> pen = Assert.IsType<Pen<Color32>>(processor.Pen);
Assert.Equal(thickness, pen.Width);
SolidBrush<Color> brush = Assert.IsType<SolidBrush<Color>>(pen.Brush);
SolidBrush<Color32> brush = Assert.IsType<SolidBrush<Color32>>(pen.Brush);
Assert.Equal(color, brush.Color);
}
@ -107,7 +107,7 @@ namespace ImageSharp.Tests.Drawing.Paths
img.DrawLines(color, thickness, points, noneDefault);
Assert.NotEmpty(img.ProcessorApplications);
DrawPathProcessor<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor);
DrawPathProcessor<Color32> processor = Assert.IsType<DrawPathProcessor<Color32>>(img.ProcessorApplications[0].processor);
Assert.Equal(noneDefault, processor.Options);
@ -116,10 +116,10 @@ namespace ImageSharp.Tests.Drawing.Paths
SixLabors.Shapes.Path vector = Assert.IsType<SixLabors.Shapes.Path>(path.Path);
LinearLineSegment segment = Assert.IsType<LinearLineSegment>(vector.LineSegments[0]);
Pen<Color> pen = Assert.IsType<Pen<Color>>(processor.Pen);
Pen<Color32> pen = Assert.IsType<Pen<Color32>>(processor.Pen);
Assert.Equal(thickness, pen.Width);
SolidBrush<Color> brush = Assert.IsType<SolidBrush<Color>>(pen.Brush);
SolidBrush<Color32> brush = Assert.IsType<SolidBrush<Color32>>(pen.Brush);
Assert.Equal(color, brush.Color);
}
@ -129,7 +129,7 @@ namespace ImageSharp.Tests.Drawing.Paths
img.DrawLines(pen, points);
Assert.NotEmpty(img.ProcessorApplications);
DrawPathProcessor<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor);
DrawPathProcessor<Color32> processor = Assert.IsType<DrawPathProcessor<Color32>>(img.ProcessorApplications[0].processor);
Assert.Equal(GraphicsOptions.Default, processor.Options);
@ -147,7 +147,7 @@ namespace ImageSharp.Tests.Drawing.Paths
img.DrawLines(pen, points, noneDefault);
Assert.NotEmpty(img.ProcessorApplications);
DrawPathProcessor<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor);
DrawPathProcessor<Color32> processor = Assert.IsType<DrawPathProcessor<Color32>>(img.ProcessorApplications[0].processor);
Assert.Equal(noneDefault, processor.Options);

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

@ -18,9 +18,9 @@ namespace ImageSharp.Tests.Drawing.Paths
{
float thickness = 7.2f;
GraphicsOptions noneDefault = new GraphicsOptions();
Color color = Color.HotPink;
SolidBrush brush = Brushes.Solid(Color.HotPink);
Pen pen = new Pen(Color.Gray, 99.9f);
Color32 color = Color32.HotPink;
SolidBrush brush = Brushes.Solid(Color32.HotPink);
Pen pen = new Pen(Color32.Gray, 99.9f);
IPath path = new SixLabors.Shapes.Path(new LinearLineSegment(new Vector2[] {
new Vector2(10,10),
new Vector2(20,10),
@ -45,14 +45,14 @@ namespace ImageSharp.Tests.Drawing.Paths
img.Draw(brush, thickness, path);
Assert.NotEmpty(img.ProcessorApplications);
DrawPathProcessor<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor);
DrawPathProcessor<Color32> processor = Assert.IsType<DrawPathProcessor<Color32>>(img.ProcessorApplications[0].processor);
Assert.Equal(GraphicsOptions.Default, processor.Options);
ShapePath shapepath = Assert.IsType<ShapePath>(processor.Path);
Assert.Equal(path, shapepath.Path);
Pen<Color> pen = Assert.IsType<Pen<Color>>(processor.Pen);
Pen<Color32> pen = Assert.IsType<Pen<Color32>>(processor.Pen);
Assert.Equal(brush, pen.Brush);
Assert.Equal(thickness, pen.Width);
}
@ -63,14 +63,14 @@ namespace ImageSharp.Tests.Drawing.Paths
img.Draw(brush, thickness, path, noneDefault);
Assert.NotEmpty(img.ProcessorApplications);
DrawPathProcessor<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor);
DrawPathProcessor<Color32> processor = Assert.IsType<DrawPathProcessor<Color32>>(img.ProcessorApplications[0].processor);
Assert.Equal(noneDefault, processor.Options);
ShapePath shapepath = Assert.IsType<ShapePath>(processor.Path);
Assert.Equal(path, shapepath.Path);
Pen<Color> pen = Assert.IsType<Pen<Color>>(processor.Pen);
Pen<Color32> pen = Assert.IsType<Pen<Color32>>(processor.Pen);
Assert.Equal(brush, pen.Brush);
Assert.Equal(thickness, pen.Width);
}
@ -81,17 +81,17 @@ namespace ImageSharp.Tests.Drawing.Paths
img.Draw(color, thickness, path);
Assert.NotEmpty(img.ProcessorApplications);
DrawPathProcessor<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor);
DrawPathProcessor<Color32> processor = Assert.IsType<DrawPathProcessor<Color32>>(img.ProcessorApplications[0].processor);
Assert.Equal(GraphicsOptions.Default, processor.Options);
ShapePath shapepath = Assert.IsType<ShapePath>(processor.Path);
Assert.Equal(path, shapepath.Path);
Pen<Color> pen = Assert.IsType<Pen<Color>>(processor.Pen);
Pen<Color32> pen = Assert.IsType<Pen<Color32>>(processor.Pen);
Assert.Equal(thickness, pen.Width);
SolidBrush<Color> brush = Assert.IsType<SolidBrush<Color>>(pen.Brush);
SolidBrush<Color32> brush = Assert.IsType<SolidBrush<Color32>>(pen.Brush);
Assert.Equal(color, brush.Color);
}
@ -101,17 +101,17 @@ namespace ImageSharp.Tests.Drawing.Paths
img.Draw(color, thickness, path, noneDefault);
Assert.NotEmpty(img.ProcessorApplications);
DrawPathProcessor<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor);
DrawPathProcessor<Color32> processor = Assert.IsType<DrawPathProcessor<Color32>>(img.ProcessorApplications[0].processor);
Assert.Equal(noneDefault, processor.Options);
ShapePath shapepath = Assert.IsType<ShapePath>(processor.Path);
Assert.Equal(path, shapepath.Path);
Pen<Color> pen = Assert.IsType<Pen<Color>>(processor.Pen);
Pen<Color32> pen = Assert.IsType<Pen<Color32>>(processor.Pen);
Assert.Equal(thickness, pen.Width);
SolidBrush<Color> brush = Assert.IsType<SolidBrush<Color>>(pen.Brush);
SolidBrush<Color32> brush = Assert.IsType<SolidBrush<Color32>>(pen.Brush);
Assert.Equal(color, brush.Color);
}
@ -121,7 +121,7 @@ namespace ImageSharp.Tests.Drawing.Paths
img.Draw(pen, path);
Assert.NotEmpty(img.ProcessorApplications);
DrawPathProcessor<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor);
DrawPathProcessor<Color32> processor = Assert.IsType<DrawPathProcessor<Color32>>(img.ProcessorApplications[0].processor);
Assert.Equal(GraphicsOptions.Default, processor.Options);
@ -137,7 +137,7 @@ namespace ImageSharp.Tests.Drawing.Paths
img.Draw(pen, path, noneDefault);
Assert.NotEmpty(img.ProcessorApplications);
DrawPathProcessor<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor);
DrawPathProcessor<Color32> processor = Assert.IsType<DrawPathProcessor<Color32>>(img.ProcessorApplications[0].processor);
Assert.Equal(noneDefault, processor.Options);

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

@ -18,9 +18,9 @@ namespace ImageSharp.Tests.Drawing.Paths
{
float thickness = 7.2f;
GraphicsOptions noneDefault = new GraphicsOptions();
Color color = Color.HotPink;
SolidBrush brush = Brushes.Solid(Color.HotPink);
Pen pen = new Pen(Color.Gray, 99.9f);
Color32 color = Color32.HotPink;
SolidBrush brush = Brushes.Solid(Color32.HotPink);
Pen pen = new Pen(Color32.Gray, 99.9f);
Vector2[] points = new Vector2[] {
new Vector2(10,10),
new Vector2(20,10),
@ -45,7 +45,7 @@ namespace ImageSharp.Tests.Drawing.Paths
img.DrawPolygon(brush, thickness, points);
Assert.NotEmpty(img.ProcessorApplications);
DrawPathProcessor<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor);
DrawPathProcessor<Color32> processor = Assert.IsType<DrawPathProcessor<Color32>>(img.ProcessorApplications[0].processor);
Assert.Equal(GraphicsOptions.Default, processor.Options);
@ -54,7 +54,7 @@ namespace ImageSharp.Tests.Drawing.Paths
Polygon vector = Assert.IsType<SixLabors.Shapes.Polygon>(path.Path);
LinearLineSegment segment = Assert.IsType<LinearLineSegment>(vector.LineSegments[0]);
Pen<Color> pen = Assert.IsType<Pen<Color>>(processor.Pen);
Pen<Color32> pen = Assert.IsType<Pen<Color32>>(processor.Pen);
Assert.Equal(brush, pen.Brush);
Assert.Equal(thickness, pen.Width);
}
@ -65,7 +65,7 @@ namespace ImageSharp.Tests.Drawing.Paths
img.DrawPolygon(brush, thickness, points, noneDefault);
Assert.NotEmpty(img.ProcessorApplications);
DrawPathProcessor<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor);
DrawPathProcessor<Color32> processor = Assert.IsType<DrawPathProcessor<Color32>>(img.ProcessorApplications[0].processor);
Assert.Equal(noneDefault, processor.Options);
@ -74,7 +74,7 @@ namespace ImageSharp.Tests.Drawing.Paths
Polygon vector = Assert.IsType<SixLabors.Shapes.Polygon>(path.Path);
LinearLineSegment segment = Assert.IsType<LinearLineSegment>(vector.LineSegments[0]);
Pen<Color> pen = Assert.IsType<Pen<Color>>(processor.Pen);
Pen<Color32> pen = Assert.IsType<Pen<Color32>>(processor.Pen);
Assert.Equal(brush, pen.Brush);
Assert.Equal(thickness, pen.Width);
}
@ -85,7 +85,7 @@ namespace ImageSharp.Tests.Drawing.Paths
img.DrawPolygon(color, thickness, points);
Assert.NotEmpty(img.ProcessorApplications);
DrawPathProcessor<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor);
DrawPathProcessor<Color32> processor = Assert.IsType<DrawPathProcessor<Color32>>(img.ProcessorApplications[0].processor);
Assert.Equal(GraphicsOptions.Default, processor.Options);
@ -94,10 +94,10 @@ namespace ImageSharp.Tests.Drawing.Paths
Polygon vector = Assert.IsType<SixLabors.Shapes.Polygon>(path.Path);
LinearLineSegment segment = Assert.IsType<LinearLineSegment>(vector.LineSegments[0]);
Pen<Color> pen = Assert.IsType<Pen<Color>>(processor.Pen);
Pen<Color32> pen = Assert.IsType<Pen<Color32>>(processor.Pen);
Assert.Equal(thickness, pen.Width);
SolidBrush<Color> brush = Assert.IsType<SolidBrush<Color>>(pen.Brush);
SolidBrush<Color32> brush = Assert.IsType<SolidBrush<Color32>>(pen.Brush);
Assert.Equal(color, brush.Color);
}
@ -107,7 +107,7 @@ namespace ImageSharp.Tests.Drawing.Paths
img.DrawPolygon(color, thickness, points, noneDefault);
Assert.NotEmpty(img.ProcessorApplications);
DrawPathProcessor<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor);
DrawPathProcessor<Color32> processor = Assert.IsType<DrawPathProcessor<Color32>>(img.ProcessorApplications[0].processor);
Assert.Equal(noneDefault, processor.Options);
@ -116,10 +116,10 @@ namespace ImageSharp.Tests.Drawing.Paths
Polygon vector = Assert.IsType<SixLabors.Shapes.Polygon>(path.Path);
LinearLineSegment segment = Assert.IsType<LinearLineSegment>(vector.LineSegments[0]);
Pen<Color> pen = Assert.IsType<Pen<Color>>(processor.Pen);
Pen<Color32> pen = Assert.IsType<Pen<Color32>>(processor.Pen);
Assert.Equal(thickness, pen.Width);
SolidBrush<Color> brush = Assert.IsType<SolidBrush<Color>>(pen.Brush);
SolidBrush<Color32> brush = Assert.IsType<SolidBrush<Color32>>(pen.Brush);
Assert.Equal(color, brush.Color);
}
@ -129,7 +129,7 @@ namespace ImageSharp.Tests.Drawing.Paths
img.DrawPolygon(pen, points);
Assert.NotEmpty(img.ProcessorApplications);
DrawPathProcessor<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor);
DrawPathProcessor<Color32> processor = Assert.IsType<DrawPathProcessor<Color32>>(img.ProcessorApplications[0].processor);
Assert.Equal(GraphicsOptions.Default, processor.Options);
@ -147,7 +147,7 @@ namespace ImageSharp.Tests.Drawing.Paths
img.DrawPolygon(pen, points, noneDefault);
Assert.NotEmpty(img.ProcessorApplications);
DrawPathProcessor<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor);
DrawPathProcessor<Color32> processor = Assert.IsType<DrawPathProcessor<Color32>>(img.ProcessorApplications[0].processor);
Assert.Equal(noneDefault, processor.Options);

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

@ -18,9 +18,9 @@ namespace ImageSharp.Tests.Drawing.Paths
{
float thickness = 7.2f;
GraphicsOptions noneDefault = new GraphicsOptions();
Color color = Color.HotPink;
SolidBrush brush = Brushes.Solid(Color.HotPink);
Pen pen = new Pen(Color.Gray, 99.9f);
Color32 color = Color32.HotPink;
SolidBrush brush = Brushes.Solid(Color32.HotPink);
Pen pen = new Pen(Color32.Gray, 99.9f);
ImageSharp.Rectangle rectangle = new ImageSharp.Rectangle(10, 10, 98, 324);
private ProcessorWatchingImage img;
@ -41,7 +41,7 @@ namespace ImageSharp.Tests.Drawing.Paths
img.Draw(brush, thickness, rectangle);
Assert.NotEmpty(img.ProcessorApplications);
DrawPathProcessor<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor);
DrawPathProcessor<Color32> processor = Assert.IsType<DrawPathProcessor<Color32>>(img.ProcessorApplications[0].processor);
Assert.Equal(GraphicsOptions.Default, processor.Options);
@ -53,7 +53,7 @@ namespace ImageSharp.Tests.Drawing.Paths
Assert.Equal(rect.Size.Width, rectangle.Width);
Assert.Equal(rect.Size.Height, rectangle.Height);
Pen<Color> pen = Assert.IsType<Pen<Color>>(processor.Pen);
Pen<Color32> pen = Assert.IsType<Pen<Color32>>(processor.Pen);
Assert.Equal(brush, pen.Brush);
Assert.Equal(thickness, pen.Width);
}
@ -64,7 +64,7 @@ namespace ImageSharp.Tests.Drawing.Paths
img.Draw(brush, thickness, rectangle, noneDefault);
Assert.NotEmpty(img.ProcessorApplications);
DrawPathProcessor<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor);
DrawPathProcessor<Color32> processor = Assert.IsType<DrawPathProcessor<Color32>>(img.ProcessorApplications[0].processor);
Assert.Equal(noneDefault, processor.Options);
@ -77,7 +77,7 @@ namespace ImageSharp.Tests.Drawing.Paths
Assert.Equal(rect.Size.Width, rectangle.Width);
Assert.Equal(rect.Size.Height, rectangle.Height);
Pen<Color> pen = Assert.IsType<Pen<Color>>(processor.Pen);
Pen<Color32> pen = Assert.IsType<Pen<Color32>>(processor.Pen);
Assert.Equal(brush, pen.Brush);
Assert.Equal(thickness, pen.Width);
}
@ -88,7 +88,7 @@ namespace ImageSharp.Tests.Drawing.Paths
img.Draw(color, thickness, rectangle);
Assert.NotEmpty(img.ProcessorApplications);
DrawPathProcessor<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor);
DrawPathProcessor<Color32> processor = Assert.IsType<DrawPathProcessor<Color32>>(img.ProcessorApplications[0].processor);
Assert.Equal(GraphicsOptions.Default, processor.Options);
@ -101,10 +101,10 @@ namespace ImageSharp.Tests.Drawing.Paths
Assert.Equal(rect.Size.Width, rectangle.Width);
Assert.Equal(rect.Size.Height, rectangle.Height);
Pen<Color> pen = Assert.IsType<Pen<Color>>(processor.Pen);
Pen<Color32> pen = Assert.IsType<Pen<Color32>>(processor.Pen);
Assert.Equal(thickness, pen.Width);
SolidBrush<Color> brush = Assert.IsType<SolidBrush<Color>>(pen.Brush);
SolidBrush<Color32> brush = Assert.IsType<SolidBrush<Color32>>(pen.Brush);
Assert.Equal(color, brush.Color);
}
@ -114,7 +114,7 @@ namespace ImageSharp.Tests.Drawing.Paths
img.Draw(color, thickness, rectangle, noneDefault);
Assert.NotEmpty(img.ProcessorApplications);
DrawPathProcessor<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor);
DrawPathProcessor<Color32> processor = Assert.IsType<DrawPathProcessor<Color32>>(img.ProcessorApplications[0].processor);
Assert.Equal(noneDefault, processor.Options);
@ -127,10 +127,10 @@ namespace ImageSharp.Tests.Drawing.Paths
Assert.Equal(rect.Size.Width, rectangle.Width);
Assert.Equal(rect.Size.Height, rectangle.Height);
Pen<Color> pen = Assert.IsType<Pen<Color>>(processor.Pen);
Pen<Color32> pen = Assert.IsType<Pen<Color32>>(processor.Pen);
Assert.Equal(thickness, pen.Width);
SolidBrush<Color> brush = Assert.IsType<SolidBrush<Color>>(pen.Brush);
SolidBrush<Color32> brush = Assert.IsType<SolidBrush<Color32>>(pen.Brush);
Assert.Equal(color, brush.Color);
}
@ -140,7 +140,7 @@ namespace ImageSharp.Tests.Drawing.Paths
img.Draw(pen, rectangle);
Assert.NotEmpty(img.ProcessorApplications);
DrawPathProcessor<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor);
DrawPathProcessor<Color32> processor = Assert.IsType<DrawPathProcessor<Color32>>(img.ProcessorApplications[0].processor);
Assert.Equal(GraphicsOptions.Default, processor.Options);
@ -162,7 +162,7 @@ namespace ImageSharp.Tests.Drawing.Paths
img.Draw(pen, rectangle, noneDefault);
Assert.NotEmpty(img.ProcessorApplications);
DrawPathProcessor<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor);
DrawPathProcessor<Color32> processor = Assert.IsType<DrawPathProcessor<Color32>>(img.ProcessorApplications[0].processor);
Assert.Equal(noneDefault, processor.Options);

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

@ -17,8 +17,8 @@ namespace ImageSharp.Tests.Drawing.Paths
public class FillPath : IDisposable
{
GraphicsOptions noneDefault = new GraphicsOptions();
Color color = Color.HotPink;
SolidBrush brush = Brushes.Solid(Color.HotPink);
Color32 color = Color32.HotPink;
SolidBrush brush = Brushes.Solid(Color32.HotPink);
IPath path = new SixLabors.Shapes.Path(new LinearLineSegment(new Vector2[] {
new Vector2(10,10),
new Vector2(20,10),
@ -43,7 +43,7 @@ namespace ImageSharp.Tests.Drawing.Paths
img.Fill(brush, path);
Assert.NotEmpty(img.ProcessorApplications);
FillRegionProcessor<Color> processor = Assert.IsType<FillRegionProcessor<Color>>(img.ProcessorApplications[0].processor);
FillRegionProcessor<Color32> processor = Assert.IsType<FillRegionProcessor<Color32>>(img.ProcessorApplications[0].processor);
Assert.Equal(GraphicsOptions.Default, processor.Options);
@ -62,7 +62,7 @@ namespace ImageSharp.Tests.Drawing.Paths
img.Fill(brush, path, noneDefault);
Assert.NotEmpty(img.ProcessorApplications);
FillRegionProcessor<Color> processor = Assert.IsType<FillRegionProcessor<Color>>(img.ProcessorApplications[0].processor);
FillRegionProcessor<Color32> processor = Assert.IsType<FillRegionProcessor<Color32>>(img.ProcessorApplications[0].processor);
Assert.Equal(noneDefault, processor.Options);
@ -79,7 +79,7 @@ namespace ImageSharp.Tests.Drawing.Paths
img.Fill(color, path);
Assert.NotEmpty(img.ProcessorApplications);
FillRegionProcessor<Color> processor = Assert.IsType<FillRegionProcessor<Color>>(img.ProcessorApplications[0].processor);
FillRegionProcessor<Color32> processor = Assert.IsType<FillRegionProcessor<Color32>>(img.ProcessorApplications[0].processor);
Assert.Equal(GraphicsOptions.Default, processor.Options);
@ -87,7 +87,7 @@ namespace ImageSharp.Tests.Drawing.Paths
Polygon polygon = Assert.IsType<Polygon>(region.Shape);
LinearLineSegment segments = Assert.IsType<LinearLineSegment>(polygon.LineSegments[0]);
SolidBrush<Color> brush = Assert.IsType<SolidBrush<Color>>(processor.Brush);
SolidBrush<Color32> brush = Assert.IsType<SolidBrush<Color32>>(processor.Brush);
Assert.Equal(color, brush.Color);
}
@ -97,7 +97,7 @@ namespace ImageSharp.Tests.Drawing.Paths
img.Fill(color, path, noneDefault);
Assert.NotEmpty(img.ProcessorApplications);
FillRegionProcessor<Color> processor = Assert.IsType<FillRegionProcessor<Color>>(img.ProcessorApplications[0].processor);
FillRegionProcessor<Color32> processor = Assert.IsType<FillRegionProcessor<Color32>>(img.ProcessorApplications[0].processor);
Assert.Equal(noneDefault, processor.Options);
@ -105,7 +105,7 @@ namespace ImageSharp.Tests.Drawing.Paths
Polygon polygon = Assert.IsType<Polygon>(region.Shape);
LinearLineSegment segments = Assert.IsType<LinearLineSegment>(polygon.LineSegments[0]);
SolidBrush<Color> brush = Assert.IsType<SolidBrush<Color>>(processor.Brush);
SolidBrush<Color32> brush = Assert.IsType<SolidBrush<Color32>>(processor.Brush);
Assert.Equal(color, brush.Color);
}
}

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

@ -17,8 +17,8 @@ namespace ImageSharp.Tests.Drawing.Paths
public class FillPolygon : IDisposable
{
GraphicsOptions noneDefault = new GraphicsOptions();
Color color = Color.HotPink;
SolidBrush brush = Brushes.Solid(Color.HotPink);
Color32 color = Color32.HotPink;
SolidBrush brush = Brushes.Solid(Color32.HotPink);
Vector2[] path = new Vector2[] {
new Vector2(10,10),
new Vector2(20,10),
@ -43,7 +43,7 @@ namespace ImageSharp.Tests.Drawing.Paths
img.FillPolygon(brush, path);
Assert.NotEmpty(img.ProcessorApplications);
FillRegionProcessor<Color> processor = Assert.IsType<FillRegionProcessor<Color>>(img.ProcessorApplications[0].processor);
FillRegionProcessor<Color32> processor = Assert.IsType<FillRegionProcessor<Color32>>(img.ProcessorApplications[0].processor);
Assert.Equal(GraphicsOptions.Default, processor.Options);
@ -60,7 +60,7 @@ namespace ImageSharp.Tests.Drawing.Paths
img.FillPolygon(brush, path, noneDefault);
Assert.NotEmpty(img.ProcessorApplications);
FillRegionProcessor<Color> processor = Assert.IsType<FillRegionProcessor<Color>>(img.ProcessorApplications[0].processor);
FillRegionProcessor<Color32> processor = Assert.IsType<FillRegionProcessor<Color32>>(img.ProcessorApplications[0].processor);
Assert.Equal(noneDefault, processor.Options);
@ -77,7 +77,7 @@ namespace ImageSharp.Tests.Drawing.Paths
img.FillPolygon(color, path);
Assert.NotEmpty(img.ProcessorApplications);
FillRegionProcessor<Color> processor = Assert.IsType<FillRegionProcessor<Color>>(img.ProcessorApplications[0].processor);
FillRegionProcessor<Color32> processor = Assert.IsType<FillRegionProcessor<Color32>>(img.ProcessorApplications[0].processor);
Assert.Equal(GraphicsOptions.Default, processor.Options);
@ -85,7 +85,7 @@ namespace ImageSharp.Tests.Drawing.Paths
Polygon polygon = Assert.IsType<Polygon>(region.Shape);
LinearLineSegment segemnt = Assert.IsType<LinearLineSegment>(polygon.LineSegments[0]);
SolidBrush<Color> brush = Assert.IsType<SolidBrush<Color>>(processor.Brush);
SolidBrush<Color32> brush = Assert.IsType<SolidBrush<Color32>>(processor.Brush);
Assert.Equal(color, brush.Color);
}
@ -95,7 +95,7 @@ namespace ImageSharp.Tests.Drawing.Paths
img.FillPolygon(color, path, noneDefault);
Assert.NotEmpty(img.ProcessorApplications);
FillRegionProcessor<Color> processor = Assert.IsType<FillRegionProcessor<Color>>(img.ProcessorApplications[0].processor);
FillRegionProcessor<Color32> processor = Assert.IsType<FillRegionProcessor<Color32>>(img.ProcessorApplications[0].processor);
Assert.Equal(noneDefault, processor.Options);
@ -103,7 +103,7 @@ namespace ImageSharp.Tests.Drawing.Paths
Polygon polygon = Assert.IsType<Polygon>(region.Shape);
LinearLineSegment segemnt = Assert.IsType<LinearLineSegment>(polygon.LineSegments[0]);
SolidBrush<Color> brush = Assert.IsType<SolidBrush<Color>>(processor.Brush);
SolidBrush<Color32> brush = Assert.IsType<SolidBrush<Color32>>(processor.Brush);
Assert.Equal(color, brush.Color);
}
}

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

@ -17,8 +17,8 @@ namespace ImageSharp.Tests.Drawing.Paths
public class FillRectangle : IDisposable
{
GraphicsOptions noneDefault = new GraphicsOptions();
Color color = Color.HotPink;
SolidBrush brush = Brushes.Solid(Color.HotPink);
Color32 color = Color32.HotPink;
SolidBrush brush = Brushes.Solid(Color32.HotPink);
ImageSharp.Rectangle rectangle = new ImageSharp.Rectangle(10, 10, 77, 76);
private ProcessorWatchingImage img;
@ -39,7 +39,7 @@ namespace ImageSharp.Tests.Drawing.Paths
img.Fill(brush, rectangle);
Assert.NotEmpty(img.ProcessorApplications);
FillRegionProcessor<Color> processor = Assert.IsType<FillRegionProcessor<Color>>(img.ProcessorApplications[0].processor);
FillRegionProcessor<Color32> processor = Assert.IsType<FillRegionProcessor<Color32>>(img.ProcessorApplications[0].processor);
Assert.Equal(GraphicsOptions.Default, processor.Options);
@ -59,7 +59,7 @@ namespace ImageSharp.Tests.Drawing.Paths
img.Fill(brush, rectangle, noneDefault);
Assert.NotEmpty(img.ProcessorApplications);
FillRegionProcessor<Color> processor = Assert.IsType<FillRegionProcessor<Color>>(img.ProcessorApplications[0].processor);
FillRegionProcessor<Color32> processor = Assert.IsType<FillRegionProcessor<Color32>>(img.ProcessorApplications[0].processor);
Assert.Equal(noneDefault, processor.Options);
@ -79,7 +79,7 @@ namespace ImageSharp.Tests.Drawing.Paths
img.Fill(color, rectangle);
Assert.NotEmpty(img.ProcessorApplications);
FillRegionProcessor<Color> processor = Assert.IsType<FillRegionProcessor<Color>>(img.ProcessorApplications[0].processor);
FillRegionProcessor<Color32> processor = Assert.IsType<FillRegionProcessor<Color32>>(img.ProcessorApplications[0].processor);
Assert.Equal(GraphicsOptions.Default, processor.Options);
@ -90,7 +90,7 @@ namespace ImageSharp.Tests.Drawing.Paths
Assert.Equal(rect.Size.Width, rectangle.Width);
Assert.Equal(rect.Size.Height, rectangle.Height);
SolidBrush<Color> brush = Assert.IsType<SolidBrush<Color>>(processor.Brush);
SolidBrush<Color32> brush = Assert.IsType<SolidBrush<Color32>>(processor.Brush);
Assert.Equal(color, brush.Color);
}
@ -100,7 +100,7 @@ namespace ImageSharp.Tests.Drawing.Paths
img.Fill(color, rectangle, noneDefault);
Assert.NotEmpty(img.ProcessorApplications);
FillRegionProcessor<Color> processor = Assert.IsType<FillRegionProcessor<Color>>(img.ProcessorApplications[0].processor);
FillRegionProcessor<Color32> processor = Assert.IsType<FillRegionProcessor<Color32>>(img.ProcessorApplications[0].processor);
Assert.Equal(noneDefault, processor.Options);
@ -111,7 +111,7 @@ namespace ImageSharp.Tests.Drawing.Paths
Assert.Equal(rect.Size.Width, rectangle.Width);
Assert.Equal(rect.Size.Height, rectangle.Height);
SolidBrush<Color> brush = Assert.IsType<SolidBrush<Color>>(processor.Brush);
SolidBrush<Color32> brush = Assert.IsType<SolidBrush<Color32>>(processor.Brush);
Assert.Equal(color, brush.Color);
}
}

8
tests/ImageSharp.Tests/Drawing/Paths/ProcessorWatchingImage.cs

@ -11,8 +11,8 @@ namespace ImageSharp.Tests.Drawing.Paths
/// <summary>
/// Watches but does not actually run the processors against the image.
/// </summary>
/// <seealso cref="ImageSharp.Image{ImageSharp.Color}" />
public class ProcessorWatchingImage : Image<Color>
/// <seealso cref="ImageSharp.Image{ImageSharp.Color32}" />
public class ProcessorWatchingImage : Image<Color32>
{
public List<ProcessorDetails> ProcessorApplications { get; } = new List<ProcessorDetails>();
@ -21,7 +21,7 @@ namespace ImageSharp.Tests.Drawing.Paths
{
}
public override void ApplyProcessor(IImageProcessor<Color> processor, Rectangle rectangle)
public override void ApplyProcessor(IImageProcessor<Color32> processor, Rectangle rectangle)
{
this.ProcessorApplications.Add(new ProcessorDetails
{
@ -32,7 +32,7 @@ namespace ImageSharp.Tests.Drawing.Paths
public struct ProcessorDetails
{
public IImageProcessor<Color> processor;
public IImageProcessor<Color32> processor;
public Rectangle rectangle;
}
}

42
tests/ImageSharp.Tests/Drawing/PolygonTests.cs

@ -25,8 +25,8 @@ namespace ImageSharp.Tests.Drawing
using (FileStream output = File.OpenWrite($"{path}/Simple.png"))
{
image
.BackgroundColor(Color.Blue)
.DrawPolygon(Color.HotPink, 5,
.BackgroundColor(Color32.Blue)
.DrawPolygon(Color32.HotPink, 5,
new[] {
new Vector2(10, 10),
new Vector2(200, 150),
@ -35,15 +35,15 @@ namespace ImageSharp.Tests.Drawing
.Save(output);
}
using (PixelAccessor<Color> sourcePixels = image.Lock())
using (PixelAccessor<Color32> sourcePixels = image.Lock())
{
Assert.Equal(Color.HotPink, sourcePixels[9, 9]);
Assert.Equal(Color32.HotPink, sourcePixels[9, 9]);
Assert.Equal(Color.HotPink, sourcePixels[199, 149]);
Assert.Equal(Color32.HotPink, sourcePixels[199, 149]);
Assert.Equal(Color.Blue, sourcePixels[50, 50]);
Assert.Equal(Color32.Blue, sourcePixels[50, 50]);
Assert.Equal(Color.Blue, sourcePixels[2, 2]);
Assert.Equal(Color32.Blue, sourcePixels[2, 2]);
}
}
}
@ -58,30 +58,30 @@ namespace ImageSharp.Tests.Drawing
new Vector2(50, 300)
};
Color color = new Color(Color.HotPink.R, Color.HotPink.G, Color.HotPink.B, 150);
Color32 color = new Color32(Color32.HotPink.R, Color32.HotPink.G, Color32.HotPink.B, 150);
using (Image image = new Image(500, 500))
{
using (FileStream output = File.OpenWrite($"{path}/Opacity.png"))
{
image
.BackgroundColor(Color.Blue)
.BackgroundColor(Color32.Blue)
.DrawPolygon(color, 10, simplePath)
.Save(output);
}
//shift background color towards forground color by the opacity amount
Color mergedColor = new Color(Vector4.Lerp(Color.Blue.ToVector4(), Color.HotPink.ToVector4(), 150f / 255f));
Color32 mergedColor = new Color32(Vector4.Lerp(Color32.Blue.ToVector4(), Color32.HotPink.ToVector4(), 150f / 255f));
using (PixelAccessor<Color> sourcePixels = image.Lock())
using (PixelAccessor<Color32> sourcePixels = image.Lock())
{
Assert.Equal(mergedColor, sourcePixels[9, 9]);
Assert.Equal(mergedColor, sourcePixels[199, 149]);
Assert.Equal(Color.Blue, sourcePixels[50, 50]);
Assert.Equal(Color32.Blue, sourcePixels[50, 50]);
Assert.Equal(Color.Blue, sourcePixels[2, 2]);
Assert.Equal(Color32.Blue, sourcePixels[2, 2]);
}
}
}
@ -96,22 +96,22 @@ namespace ImageSharp.Tests.Drawing
using (FileStream output = File.OpenWrite($"{path}/Rectangle.png"))
{
image
.BackgroundColor(Color.Blue)
.Draw(Color.HotPink, 10, new Rectangle(10, 10, 190, 140))
.BackgroundColor(Color32.Blue)
.Draw(Color32.HotPink, 10, new Rectangle(10, 10, 190, 140))
.Save(output);
}
using (PixelAccessor<Color> sourcePixels = image.Lock())
using (PixelAccessor<Color32> sourcePixels = image.Lock())
{
Assert.Equal(Color.HotPink, sourcePixels[8, 8]);
Assert.Equal(Color32.HotPink, sourcePixels[8, 8]);
Assert.Equal(Color.HotPink, sourcePixels[198, 10]);
Assert.Equal(Color32.HotPink, sourcePixels[198, 10]);
Assert.Equal(Color.HotPink, sourcePixels[10, 50]);
Assert.Equal(Color32.HotPink, sourcePixels[10, 50]);
Assert.Equal(Color.Blue, sourcePixels[50, 50]);
Assert.Equal(Color32.Blue, sourcePixels[50, 50]);
Assert.Equal(Color.Blue, sourcePixels[2, 2]);
Assert.Equal(Color32.Blue, sourcePixels[2, 2]);
}
}
}

4
tests/ImageSharp.Tests/Drawing/RecolorImageTest.cs

@ -18,7 +18,7 @@ namespace ImageSharp.Tests
{
string path = this.CreateOutputDirectory("Drawing", "RecolorImage");
RecolorBrush brush = new RecolorBrush(Color.Yellow, Color.HotPink, 0.2f);
RecolorBrush brush = new RecolorBrush(Color32.Yellow, Color32.HotPink, 0.2f);
foreach (TestFile file in Files)
{
@ -38,7 +38,7 @@ namespace ImageSharp.Tests
{
string path = this.CreateOutputDirectory("Drawing", "RecolorImage");
RecolorBrush brush = new RecolorBrush(Color.Yellow, Color.HotPink, 0.2f);
RecolorBrush brush = new RecolorBrush(Color32.Yellow, Color32.HotPink, 0.2f);
foreach (TestFile file in Files)
{

22
tests/ImageSharp.Tests/Drawing/SolidBezierTests.cs

@ -29,20 +29,20 @@ namespace ImageSharp.Tests.Drawing
using (FileStream output = File.OpenWrite($"{path}/Simple.png"))
{
image
.BackgroundColor(Color.Blue)
.Fill(Color.HotPink, new Polygon(new BezierLineSegment(simplePath)))
.BackgroundColor(Color32.Blue)
.Fill(Color32.HotPink, new Polygon(new BezierLineSegment(simplePath)))
.Save(output);
}
using (PixelAccessor<Color> sourcePixels = image.Lock())
using (PixelAccessor<Color32> sourcePixels = image.Lock())
{
Assert.Equal(Color.HotPink, sourcePixels[150, 300]);
Assert.Equal(Color32.HotPink, sourcePixels[150, 300]);
//curve points should not be never be set
Assert.Equal(Color.Blue, sourcePixels[240, 30]);
Assert.Equal(Color32.Blue, sourcePixels[240, 30]);
// inside shape should not be empty
Assert.Equal(Color.HotPink, sourcePixels[200, 250]);
Assert.Equal(Color32.HotPink, sourcePixels[200, 250]);
}
}
}
@ -57,28 +57,28 @@ namespace ImageSharp.Tests.Drawing
new Vector2(240, 30),
new Vector2(300, 400)
};
Color color = new Color(Color.HotPink.R, Color.HotPink.G, Color.HotPink.B, 150);
Color32 color = new Color32(Color32.HotPink.R, Color32.HotPink.G, Color32.HotPink.B, 150);
using (Image image = new Image(500, 500))
{
using (FileStream output = File.OpenWrite($"{path}/Opacity.png"))
{
image
.BackgroundColor(Color.Blue)
.BackgroundColor(Color32.Blue)
.Fill(color, new Polygon(new BezierLineSegment(simplePath)))
.Save(output);
}
//shift background color towards forground color by the opacity amount
Color mergedColor = new Color(Vector4.Lerp(Color.Blue.ToVector4(), Color.HotPink.ToVector4(), 150f / 255f));
Color32 mergedColor = new Color32(Vector4.Lerp(Color32.Blue.ToVector4(), Color32.HotPink.ToVector4(), 150f / 255f));
using (PixelAccessor<Color> sourcePixels = image.Lock())
using (PixelAccessor<Color32> sourcePixels = image.Lock())
{
//top of curve
Assert.Equal(mergedColor, sourcePixels[138, 116]);
//curve points should not be never be set
Assert.Equal(Color.Blue, sourcePixels[240, 30]);
Assert.Equal(Color32.Blue, sourcePixels[240, 30]);
// inside shape should not be empty
Assert.Equal(mergedColor, sourcePixels[200, 250]);

30
tests/ImageSharp.Tests/Drawing/SolidComplexPolygonTests.cs

@ -35,17 +35,17 @@ namespace ImageSharp.Tests.Drawing
using (FileStream output = File.OpenWrite($"{path}/Simple.png"))
{
image
.BackgroundColor(Color.Blue)
.Fill(Color.HotPink, clipped)
.BackgroundColor(Color32.Blue)
.Fill(Color32.HotPink, clipped)
.Save(output);
}
using (PixelAccessor<Color> sourcePixels = image.Lock())
using (PixelAccessor<Color32> sourcePixels = image.Lock())
{
Assert.Equal(Color.HotPink, sourcePixels[20, 35]);
Assert.Equal(Color32.HotPink, sourcePixels[20, 35]);
//inside hole
Assert.Equal(Color.Blue, sourcePixels[60, 100]);
Assert.Equal(Color32.Blue, sourcePixels[60, 100]);
}
}
}
@ -70,17 +70,17 @@ namespace ImageSharp.Tests.Drawing
using (FileStream output = File.OpenWrite($"{path}/SimpleOverlapping.png"))
{
image
.BackgroundColor(Color.Blue)
.Fill(Color.HotPink, simplePath.Clip(hole1))
.BackgroundColor(Color32.Blue)
.Fill(Color32.HotPink, simplePath.Clip(hole1))
.Save(output);
}
using (PixelAccessor<Color> sourcePixels = image.Lock())
using (PixelAccessor<Color32> sourcePixels = image.Lock())
{
Assert.Equal(Color.HotPink, sourcePixels[20, 35]);
Assert.Equal(Color32.HotPink, sourcePixels[20, 35]);
//inside hole
Assert.Equal(Color.Blue, sourcePixels[60, 100]);
Assert.Equal(Color32.Blue, sourcePixels[60, 100]);
}
}
}
@ -98,27 +98,27 @@ namespace ImageSharp.Tests.Drawing
new Vector2(37, 85),
new Vector2(93, 85),
new Vector2(65, 137)));
Color color = new Color(Color.HotPink.R, Color.HotPink.G, Color.HotPink.B, 150);
Color32 color = new Color32(Color32.HotPink.R, Color32.HotPink.G, Color32.HotPink.B, 150);
using (Image image = new Image(500, 500))
{
using (FileStream output = File.OpenWrite($"{path}/Opacity.png"))
{
image
.BackgroundColor(Color.Blue)
.BackgroundColor(Color32.Blue)
.Fill(color, simplePath.Clip(hole1))
.Save(output);
}
//shift background color towards forground color by the opacity amount
Color mergedColor = new Color(Vector4.Lerp(Color.Blue.ToVector4(), Color.HotPink.ToVector4(), 150f / 255f));
Color32 mergedColor = new Color32(Vector4.Lerp(Color32.Blue.ToVector4(), Color32.HotPink.ToVector4(), 150f / 255f));
using (PixelAccessor<Color> sourcePixels = image.Lock())
using (PixelAccessor<Color32> sourcePixels = image.Lock())
{
Assert.Equal(mergedColor, sourcePixels[20, 35]);
//inside hole
Assert.Equal(Color.Blue, sourcePixels[60, 100]);
Assert.Equal(Color32.Blue, sourcePixels[60, 100]);
}
}
}

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

@ -32,13 +32,13 @@ namespace ImageSharp.Tests.Drawing
using (FileStream output = File.OpenWrite($"{path}/Simple.png"))
{
image
.FillPolygon(Color.HotPink, simplePath, new GraphicsOptions(true))
.FillPolygon(Color32.HotPink, simplePath, new GraphicsOptions(true))
.Save(output);
}
using (PixelAccessor<Color> sourcePixels = image.Lock())
using (PixelAccessor<Color32> sourcePixels = image.Lock())
{
Assert.Equal(Color.HotPink, sourcePixels[81, 145]);
Assert.Equal(Color32.HotPink, sourcePixels[81, 145]);
}
}
}
@ -58,13 +58,13 @@ namespace ImageSharp.Tests.Drawing
using (FileStream output = File.OpenWrite($"{path}/Pattern.png"))
{
image
.FillPolygon(Brushes.Horizontal(Color.HotPink), simplePath, new GraphicsOptions(true))
.FillPolygon(Brushes.Horizontal(Color32.HotPink), simplePath, new GraphicsOptions(true))
.Save(output);
}
using (PixelAccessor<Color> sourcePixels = image.Lock())
using (PixelAccessor<Color32> sourcePixels = image.Lock())
{
Assert.Equal(Color.HotPink, sourcePixels[81, 145]);
Assert.Equal(Color32.HotPink, sourcePixels[81, 145]);
}
}
}
@ -83,19 +83,19 @@ namespace ImageSharp.Tests.Drawing
using (FileStream output = File.OpenWrite($"{path}/Simple_NoAntialias.png"))
{
image
.BackgroundColor(Color.Blue)
.FillPolygon(Color.HotPink, simplePath, new GraphicsOptions(false))
.BackgroundColor(Color32.Blue)
.FillPolygon(Color32.HotPink, simplePath, new GraphicsOptions(false))
.Save(output);
using (PixelAccessor<Color> sourcePixels = image.Lock())
using (PixelAccessor<Color32> sourcePixels = image.Lock())
{
Assert.Equal(Color.HotPink, sourcePixels[11, 11]);
Assert.Equal(Color32.HotPink, sourcePixels[11, 11]);
Assert.Equal(Color.HotPink, sourcePixels[199, 150]);
Assert.Equal(Color32.HotPink, sourcePixels[199, 150]);
Assert.Equal(Color.HotPink, sourcePixels[50, 50]);
Assert.Equal(Color32.HotPink, sourcePixels[50, 50]);
Assert.Equal(Color.Blue, sourcePixels[2, 2]);
Assert.Equal(Color32.Blue, sourcePixels[2, 2]);
}
}
}
@ -117,7 +117,7 @@ namespace ImageSharp.Tests.Drawing
ImageBrush brush = new ImageBrush(brushImage);
image
.BackgroundColor(Color.Blue)
.BackgroundColor(Color32.Blue)
.FillPolygon(brush, simplePath)
.Save(output);
}
@ -132,24 +132,24 @@ namespace ImageSharp.Tests.Drawing
new Vector2(200, 150),
new Vector2(50, 300)
};
Color color = new Color(Color.HotPink.R, Color.HotPink.G, Color.HotPink.B, 150);
Color32 color = new Color32(Color32.HotPink.R, Color32.HotPink.G, Color32.HotPink.B, 150);
using (Image image = new Image(500, 500))
{
using (FileStream output = File.OpenWrite($"{path}/Opacity.png"))
{
image
.BackgroundColor(Color.Blue)
.BackgroundColor(Color32.Blue)
.FillPolygon(color, simplePath)
.Save(output);
}
//shift background color towards forground color by the opacity amount
Color mergedColor = new Color(Vector4.Lerp(Color.Blue.ToVector4(), Color.HotPink.ToVector4(), 150f / 255f));
Color32 mergedColor = new Color32(Vector4.Lerp(Color32.Blue.ToVector4(), Color32.HotPink.ToVector4(), 150f / 255f));
using (PixelAccessor<Color> sourcePixels = image.Lock())
using (PixelAccessor<Color32> sourcePixels = image.Lock())
{
Assert.Equal(Color.Blue, sourcePixels[2, 2]);
Assert.Equal(Color32.Blue, sourcePixels[2, 2]);
}
}
}
@ -164,22 +164,22 @@ namespace ImageSharp.Tests.Drawing
using (FileStream output = File.OpenWrite($"{path}/Rectangle.png"))
{
image
.BackgroundColor(Color.Blue)
.Fill(Color.HotPink, new SixLabors.Shapes.Rectangle(10, 10, 190, 140))
.BackgroundColor(Color32.Blue)
.Fill(Color32.HotPink, new SixLabors.Shapes.Rectangle(10, 10, 190, 140))
.Save(output);
}
using (PixelAccessor<Color> sourcePixels = image.Lock())
using (PixelAccessor<Color32> sourcePixels = image.Lock())
{
Assert.Equal(Color.HotPink, sourcePixels[11, 11]);
Assert.Equal(Color32.HotPink, sourcePixels[11, 11]);
Assert.Equal(Color.HotPink, sourcePixels[198, 10]);
Assert.Equal(Color32.HotPink, sourcePixels[198, 10]);
Assert.Equal(Color.HotPink, sourcePixels[10, 50]);
Assert.Equal(Color32.HotPink, sourcePixels[10, 50]);
Assert.Equal(Color.HotPink, sourcePixels[50, 50]);
Assert.Equal(Color32.HotPink, sourcePixels[50, 50]);
Assert.Equal(Color.Blue, sourcePixels[2, 2]);
Assert.Equal(Color32.Blue, sourcePixels[2, 2]);
}
}
}
@ -194,16 +194,16 @@ namespace ImageSharp.Tests.Drawing
using (FileStream output = File.OpenWrite($"{path}/Triangle.png"))
{
image
.BackgroundColor(Color.Blue)
.Fill(Color.HotPink, new RegularPolygon(50, 50, 3, 30))
.BackgroundColor(Color32.Blue)
.Fill(Color32.HotPink, new RegularPolygon(50, 50, 3, 30))
.Save(output);
}
using (PixelAccessor<Color> sourcePixels = image.Lock())
using (PixelAccessor<Color32> sourcePixels = image.Lock())
{
Assert.Equal(Color.Blue, sourcePixels[30, 65]);
Assert.Equal(Color32.Blue, sourcePixels[30, 65]);
Assert.Equal(Color.HotPink, sourcePixels[50, 50]);
Assert.Equal(Color32.HotPink, sourcePixels[50, 50]);
}
}
}
@ -220,8 +220,8 @@ namespace ImageSharp.Tests.Drawing
using (FileStream output = File.OpenWrite($"{path}/Septagon.png"))
{
image
.BackgroundColor(Color.Blue)
.Fill(Color.HotPink, new RegularPolygon(50, 50, 7, 30, -(float)Math.PI))
.BackgroundColor(Color32.Blue)
.Fill(Color32.HotPink, new RegularPolygon(50, 50, 7, 30, -(float)Math.PI))
.Save(output);
}
}
@ -239,8 +239,8 @@ namespace ImageSharp.Tests.Drawing
using (FileStream output = File.OpenWrite($"{path}/ellipse.png"))
{
image
.BackgroundColor(Color.Blue)
.Fill(Color.HotPink, new Ellipse(50, 50, 30, 50)
.BackgroundColor(Color32.Blue)
.Fill(Color32.HotPink, new Ellipse(50, 50, 30, 50)
.Rotate((float)(Math.PI / 3)))
.Save(output);
}
@ -259,8 +259,8 @@ namespace ImageSharp.Tests.Drawing
using (FileStream output = File.OpenWrite($"{path}/clipped-corner.png"))
{
image
.Fill(Color.Blue)
.FillPolygon(Color.HotPink, new[]
.Fill(Color32.Blue)
.FillPolygon(Color32.HotPink, new[]
{
new Vector2( 8, 8 ),
new Vector2( 64, 8 ),

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

@ -21,9 +21,9 @@ namespace ImageSharp.Tests.Drawing.Text
public class DrawText : IDisposable
{
Color color = Color.HotPink;
Color32 color = Color32.HotPink;
SolidBrush brush = Brushes.Solid(Color.HotPink);
SolidBrush brush = Brushes.Solid(Color32.HotPink);
IPath path = new SixLabors.Shapes.Path(
new LinearLineSegment(
@ -53,73 +53,73 @@ namespace ImageSharp.Tests.Drawing.Text
this.img.DrawText(
"123",
this.Font,
Brushes.Solid(Color.Red),
Brushes.Solid(Color32.Red),
null,
Vector2.Zero,
new TextGraphicsOptions(true));
Assert.NotEmpty(this.img.ProcessorApplications);
Assert.Equal(3, this.img.ProcessorApplications.Count); // 3 fills where applied
Assert.IsType<FillRegionProcessor<Color>>(this.img.ProcessorApplications[0].processor);
Assert.IsType<FillRegionProcessor<Color32>>(this.img.ProcessorApplications[0].processor);
}
[Fact]
public void FillsForEachACharachterWhenBrushSetAndNotPenDefaultOptions()
{
this.img.DrawText("123", this.Font, Brushes.Solid(Color.Red), null, Vector2.Zero);
this.img.DrawText("123", this.Font, Brushes.Solid(Color32.Red), null, Vector2.Zero);
Assert.NotEmpty(this.img.ProcessorApplications);
Assert.Equal(3, this.img.ProcessorApplications.Count); // 3 fills where applied
Assert.IsType<FillRegionProcessor<Color>>(this.img.ProcessorApplications[0].processor);
Assert.IsType<FillRegionProcessor<Color32>>(this.img.ProcessorApplications[0].processor);
}
[Fact]
public void FillsForEachACharachterWhenBrushSet()
{
this.img.DrawText("123", this.Font, Brushes.Solid(Color.Red), Vector2.Zero, new TextGraphicsOptions(true));
this.img.DrawText("123", this.Font, Brushes.Solid(Color32.Red), Vector2.Zero, new TextGraphicsOptions(true));
Assert.NotEmpty(this.img.ProcessorApplications);
Assert.Equal(3, this.img.ProcessorApplications.Count); // 3 fills where applied
Assert.IsType<FillRegionProcessor<Color>>(this.img.ProcessorApplications[0].processor);
Assert.IsType<FillRegionProcessor<Color32>>(this.img.ProcessorApplications[0].processor);
}
[Fact]
public void FillsForEachACharachterWhenBrushSetDefaultOptions()
{
this.img.DrawText("123", this.Font, Brushes.Solid(Color.Red), Vector2.Zero);
this.img.DrawText("123", this.Font, Brushes.Solid(Color32.Red), Vector2.Zero);
Assert.NotEmpty(this.img.ProcessorApplications);
Assert.Equal(3, this.img.ProcessorApplications.Count); // 3 fills where applied
Assert.IsType<FillRegionProcessor<Color>>(this.img.ProcessorApplications[0].processor);
Assert.IsType<FillRegionProcessor<Color32>>(this.img.ProcessorApplications[0].processor);
}
[Fact]
public void FillsForEachACharachterWhenColorSet()
{
this.img.DrawText("123", this.Font, Color.Red, Vector2.Zero, new TextGraphicsOptions(true));
this.img.DrawText("123", this.Font, Color32.Red, Vector2.Zero, new TextGraphicsOptions(true));
Assert.NotEmpty(this.img.ProcessorApplications);
Assert.Equal(3, this.img.ProcessorApplications.Count);
FillRegionProcessor<Color> processor =
Assert.IsType<FillRegionProcessor<Color>>(this.img.ProcessorApplications[0].processor);
FillRegionProcessor<Color32> processor =
Assert.IsType<FillRegionProcessor<Color32>>(this.img.ProcessorApplications[0].processor);
SolidBrush<Color> brush = Assert.IsType<SolidBrush<Color>>(processor.Brush);
Assert.Equal(Color.Red, brush.Color);
SolidBrush<Color32> brush = Assert.IsType<SolidBrush<Color32>>(processor.Brush);
Assert.Equal(Color32.Red, brush.Color);
}
[Fact]
public void FillsForEachACharachterWhenColorSetDefaultOptions()
{
this.img.DrawText("123", this.Font, Color.Red, Vector2.Zero);
this.img.DrawText("123", this.Font, Color32.Red, Vector2.Zero);
Assert.NotEmpty(this.img.ProcessorApplications);
Assert.Equal(3, this.img.ProcessorApplications.Count);
Assert.IsType<FillRegionProcessor<Color>>(this.img.ProcessorApplications[0].processor);
FillRegionProcessor<Color> processor =
Assert.IsType<FillRegionProcessor<Color>>(this.img.ProcessorApplications[0].processor);
Assert.IsType<FillRegionProcessor<Color32>>(this.img.ProcessorApplications[0].processor);
FillRegionProcessor<Color32> processor =
Assert.IsType<FillRegionProcessor<Color32>>(this.img.ProcessorApplications[0].processor);
SolidBrush<Color> brush = Assert.IsType<SolidBrush<Color>>(processor.Brush);
Assert.Equal(Color.Red, brush.Color);
SolidBrush<Color32> brush = Assert.IsType<SolidBrush<Color32>>(processor.Brush);
Assert.Equal(Color32.Red, brush.Color);
}
[Fact]
@ -129,43 +129,43 @@ namespace ImageSharp.Tests.Drawing.Text
"123",
this.Font,
null,
Pens.Dash(Color.Red, 1),
Pens.Dash(Color32.Red, 1),
Vector2.Zero,
new TextGraphicsOptions(true));
Assert.NotEmpty(this.img.ProcessorApplications);
Assert.Equal(3, this.img.ProcessorApplications.Count); // 3 fills where applied
Assert.IsType<DrawPathProcessor<Color>>(this.img.ProcessorApplications[0].processor);
Assert.IsType<DrawPathProcessor<Color32>>(this.img.ProcessorApplications[0].processor);
}
[Fact]
public void DrawForEachACharachterWhenPenSetAndNotBrushDefaultOptions()
{
this.img.DrawText("123", this.Font, null, Pens.Dash(Color.Red, 1), Vector2.Zero);
this.img.DrawText("123", this.Font, null, Pens.Dash(Color32.Red, 1), Vector2.Zero);
Assert.NotEmpty(this.img.ProcessorApplications);
Assert.Equal(3, this.img.ProcessorApplications.Count); // 3 fills where applied
Assert.IsType<DrawPathProcessor<Color>>(this.img.ProcessorApplications[0].processor);
Assert.IsType<DrawPathProcessor<Color32>>(this.img.ProcessorApplications[0].processor);
}
[Fact]
public void DrawForEachACharachterWhenPenSet()
{
this.img.DrawText("123", this.Font, Pens.Dash(Color.Red, 1), Vector2.Zero, new TextGraphicsOptions(true));
this.img.DrawText("123", this.Font, Pens.Dash(Color32.Red, 1), Vector2.Zero, new TextGraphicsOptions(true));
Assert.NotEmpty(this.img.ProcessorApplications);
Assert.Equal(3, this.img.ProcessorApplications.Count); // 3 fills where applied
Assert.IsType<DrawPathProcessor<Color>>(this.img.ProcessorApplications[0].processor);
Assert.IsType<DrawPathProcessor<Color32>>(this.img.ProcessorApplications[0].processor);
}
[Fact]
public void DrawForEachACharachterWhenPenSetDefaultOptions()
{
this.img.DrawText("123", this.Font, Pens.Dash(Color.Red, 1), Vector2.Zero);
this.img.DrawText("123", this.Font, Pens.Dash(Color32.Red, 1), Vector2.Zero);
Assert.NotEmpty(this.img.ProcessorApplications);
Assert.Equal(3, this.img.ProcessorApplications.Count); // 3 fills where applied
Assert.IsType<DrawPathProcessor<Color>>(this.img.ProcessorApplications[0].processor);
Assert.IsType<DrawPathProcessor<Color32>>(this.img.ProcessorApplications[0].processor);
}
[Fact]
@ -174,8 +174,8 @@ namespace ImageSharp.Tests.Drawing.Text
this.img.DrawText(
"123",
this.Font,
Brushes.Solid(Color.Red),
Pens.Dash(Color.Red, 1),
Brushes.Solid(Color32.Red),
Pens.Dash(Color32.Red, 1),
Vector2.Zero,
new TextGraphicsOptions(true));
@ -186,7 +186,7 @@ namespace ImageSharp.Tests.Drawing.Text
[Fact]
public void DrawForEachACharachterWhenPenSetAndFillFroEachWhenBrushSetDefaultOptions()
{
this.img.DrawText("123", this.Font, Brushes.Solid(Color.Red), Pens.Dash(Color.Red, 1), Vector2.Zero);
this.img.DrawText("123", this.Font, Brushes.Solid(Color32.Red), Pens.Dash(Color32.Red, 1), Vector2.Zero);
Assert.NotEmpty(this.img.ProcessorApplications);
Assert.Equal(6, this.img.ProcessorApplications.Count);
@ -198,26 +198,26 @@ namespace ImageSharp.Tests.Drawing.Text
this.img.DrawText(
"1",
this.Font,
Brushes.Solid(Color.Red),
Pens.Dash(Color.Red, 1),
Brushes.Solid(Color32.Red),
Pens.Dash(Color32.Red, 1),
Vector2.Zero,
new TextGraphicsOptions(true));
Assert.NotEmpty(this.img.ProcessorApplications);
Assert.Equal(2, this.img.ProcessorApplications.Count);
Assert.IsType<FillRegionProcessor<Color>>(this.img.ProcessorApplications[0].processor);
Assert.IsType<DrawPathProcessor<Color>>(this.img.ProcessorApplications[1].processor);
Assert.IsType<FillRegionProcessor<Color32>>(this.img.ProcessorApplications[0].processor);
Assert.IsType<DrawPathProcessor<Color32>>(this.img.ProcessorApplications[1].processor);
}
[Fact]
public void BrushAppliesBeforPenDefaultOptions()
{
this.img.DrawText("1", this.Font, Brushes.Solid(Color.Red), Pens.Dash(Color.Red, 1), Vector2.Zero);
this.img.DrawText("1", this.Font, Brushes.Solid(Color32.Red), Pens.Dash(Color32.Red, 1), Vector2.Zero);
Assert.NotEmpty(this.img.ProcessorApplications);
Assert.Equal(2, this.img.ProcessorApplications.Count);
Assert.IsType<FillRegionProcessor<Color>>(this.img.ProcessorApplications[0].processor);
Assert.IsType<DrawPathProcessor<Color>>(this.img.ProcessorApplications[1].processor);
Assert.IsType<FillRegionProcessor<Color32>>(this.img.ProcessorApplications[0].processor);
Assert.IsType<DrawPathProcessor<Color32>>(this.img.ProcessorApplications[1].processor);
}
[Fact]
@ -225,19 +225,19 @@ namespace ImageSharp.Tests.Drawing.Text
{
this.img.MetaData.VerticalResolution = 1;
this.img.MetaData.HorizontalResolution = 1;
this.img.DrawText("1", this.Font, Brushes.Solid(Color.Red), Vector2.Zero, new TextGraphicsOptions(true) {
this.img.DrawText("1", this.Font, Brushes.Solid(Color32.Red), Vector2.Zero, new TextGraphicsOptions(true) {
UseImageResolution = false
});
this.img.DrawText("1", this.Font, Brushes.Solid(Color.Red), Vector2.Zero, new TextGraphicsOptions(true)
this.img.DrawText("1", this.Font, Brushes.Solid(Color32.Red), Vector2.Zero, new TextGraphicsOptions(true)
{
UseImageResolution = true
});
Assert.NotEmpty(this.img.ProcessorApplications);
Assert.Equal(2, this.img.ProcessorApplications.Count);
FillRegionProcessor<Color> ownResolution = Assert.IsType<FillRegionProcessor<Color>>(this.img.ProcessorApplications[0].processor);
FillRegionProcessor<Color> imgResolution = Assert.IsType<FillRegionProcessor<Color>>(this.img.ProcessorApplications[1].processor);
FillRegionProcessor<Color32> ownResolution = Assert.IsType<FillRegionProcessor<Color32>>(this.img.ProcessorApplications[0].processor);
FillRegionProcessor<Color32> imgResolution = Assert.IsType<FillRegionProcessor<Color32>>(this.img.ProcessorApplications[1].processor);
ShapeRegion ownRegion = Assert.IsType<ShapeRegion>(ownResolution.Region);
ShapeRegion imgRegion = Assert.IsType<ShapeRegion>(imgResolution.Region);

4
tests/ImageSharp.Tests/Drawing/Text/OutputText.cs

@ -32,8 +32,8 @@ namespace ImageSharp.Tests.Drawing.Text
//draws 2 overlapping triangle glyphs twice 1 set on each line
using (Image img = new Image(100, 200))
{
img.Fill(Color.DarkBlue)
.DrawText("AB\nAB", new Font(this.Font, 50), Color.Red, new Vector2(0, 0));
img.Fill(Color32.DarkBlue)
.DrawText("AB\nAB", new Font(this.Font, 50), Color32.Red, new Vector2(0, 0));
img.Save($"{this.CreateOutputDirectory("Drawing", "Text")}/AB.png");
}
}

6
tests/ImageSharp.Tests/Formats/Jpg/JpegProfilingBenchmarks.cs

@ -69,9 +69,9 @@ namespace ImageSharp.Tests
.Concat(new[] { TestImages.Jpeg.Baseline.Calliphora, TestImages.Jpeg.Baseline.Cmyk })
.ToArray();
Image<Color>[] testImages =
Image<Color32>[] testImages =
testFiles.Select(
tf => TestImageProvider<Color>.File(tf, pixelTypeOverride: PixelTypes.StandardImageClass).GetImage())
tf => TestImageProvider<Color32>.File(tf, pixelTypeOverride: PixelTypes.StandardImageClass).GetImage())
.ToArray();
using (MemoryStream ms = new MemoryStream())
@ -79,7 +79,7 @@ namespace ImageSharp.Tests
this.Measure(executionCount,
() =>
{
foreach (Image<Color> img in testImages)
foreach (Image<Color32> img in testImages)
{
JpegEncoder encoder = new JpegEncoder();
JpegEncoderOptions options = new JpegEncoderOptions { Quality = quality, Subsample = subsample };

100
tests/ImageSharp.Tests/Image/ImageLoadTests.cs

@ -20,7 +20,7 @@ namespace ImageSharp.Tests
{
private readonly Mock<IFileSystem> fileSystem;
private readonly IDecoderOptions decoderOptions;
private Image<Color> returnImage;
private Image<Color32> returnImage;
private Mock<IImageDecoder> localDecoder;
private Mock<IImageFormat> localFormat;
private readonly string FilePath;
@ -44,7 +44,7 @@ namespace ImageSharp.Tests
this.localFormat.Setup(x => x.IsSupportedFileFormat(It.IsAny<byte[]>())).Returns(true);
this.localFormat.Setup(x => x.SupportedExtensions).Returns(new string[] { "png", "jpg" });
this.localDecoder.Setup(x => x.Decode<Color>(It.IsAny<Configuration>(), It.IsAny<Stream>(), It.IsAny<IDecoderOptions>()))
this.localDecoder.Setup(x => x.Decode<Color32>(It.IsAny<Configuration>(), It.IsAny<Stream>(), It.IsAny<IDecoderOptions>()))
.Callback<Configuration, Stream, IDecoderOptions>((c, s, o) => {
using (var ms = new MemoryStream())
@ -103,10 +103,10 @@ namespace ImageSharp.Tests
[Fact]
public void LoadFromStreamWithType()
{
Image<Color> img = Image.Load<Color>(this.DataStream);
Image<Color32> img = Image.Load<Color32>(this.DataStream);
Assert.NotNull(img);
Assert.Equal(TestFormat.GlobalTestFormat.Sample<Color>(), img);
Assert.Equal(TestFormat.GlobalTestFormat.Sample<Color32>(), img);
Assert.Equal(TestFormat.GlobalTestFormat, img.CurrentImageFormat);
TestFormat.GlobalTestFormat.VerifyDecodeCall(this.Marker, null, Configuration.Default);
@ -128,10 +128,10 @@ namespace ImageSharp.Tests
[Fact]
public void LoadFromStreamWithTypeAndOptions()
{
Image<Color> img = Image.Load<Color>(this.DataStream, this.decoderOptions);
Image<Color32> img = Image.Load<Color32>(this.DataStream, this.decoderOptions);
Assert.NotNull(img);
Assert.Equal(TestFormat.GlobalTestFormat.Sample<Color>(), img);
Assert.Equal(TestFormat.GlobalTestFormat.Sample<Color32>(), img);
Assert.Equal(TestFormat.GlobalTestFormat, img.CurrentImageFormat);
TestFormat.GlobalTestFormat.VerifyDecodeCall(this.Marker, this.decoderOptions, Configuration.Default);
@ -147,7 +147,7 @@ namespace ImageSharp.Tests
Assert.NotNull(img);
Assert.Equal(this.localFormat.Object, img.CurrentImageFormat);
this.localDecoder.Verify(x => x.Decode<Color>(this.LocalConfiguration, stream, null));
this.localDecoder.Verify(x => x.Decode<Color32>(this.LocalConfiguration, stream, null));
}
@ -155,13 +155,13 @@ namespace ImageSharp.Tests
public void LoadFromStreamWithTypeAndConfig()
{
Stream stream = new MemoryStream();
Image<Color> img = Image.Load<Color>(this.LocalConfiguration, stream);
Image<Color32> img = Image.Load<Color32>(this.LocalConfiguration, stream);
Assert.NotNull(img);
Assert.Equal(this.returnImage, img);
Assert.Equal(this.localFormat.Object, img.CurrentImageFormat);
this.localDecoder.Verify(x => x.Decode<Color>(this.LocalConfiguration, stream, null));
this.localDecoder.Verify(x => x.Decode<Color32>(this.LocalConfiguration, stream, null));
}
@ -174,7 +174,7 @@ namespace ImageSharp.Tests
Assert.NotNull(img);
Assert.Equal(this.localFormat.Object, img.CurrentImageFormat);
this.localDecoder.Verify(x => x.Decode<Color>(this.LocalConfiguration, stream, this.decoderOptions));
this.localDecoder.Verify(x => x.Decode<Color32>(this.LocalConfiguration, stream, this.decoderOptions));
}
@ -182,13 +182,13 @@ namespace ImageSharp.Tests
public void LoadFromStreamWithTypeAndConfigAndOptions()
{
Stream stream = new MemoryStream();
Image<Color> img = Image.Load<Color>(this.LocalConfiguration, stream, this.decoderOptions);
Image<Color32> img = Image.Load<Color32>(this.LocalConfiguration, stream, this.decoderOptions);
Assert.NotNull(img);
Assert.Equal(this.returnImage, img);
Assert.Equal(this.localFormat.Object, img.CurrentImageFormat);
this.localDecoder.Verify(x => x.Decode<Color>(this.LocalConfiguration, stream, this.decoderOptions));
this.localDecoder.Verify(x => x.Decode<Color32>(this.LocalConfiguration, stream, this.decoderOptions));
}
@ -201,18 +201,18 @@ namespace ImageSharp.Tests
Image img = Image.Load(stream, this.localDecoder.Object);
Assert.NotNull(img);
this.localDecoder.Verify(x => x.Decode<Color>(Configuration.Default, stream, null));
this.localDecoder.Verify(x => x.Decode<Color32>(Configuration.Default, stream, null));
}
[Fact]
public void LoadFromStreamWithTypeAndDecoder()
{
Stream stream = new MemoryStream();
Image<Color> img = Image.Load<Color>(stream, this.localDecoder.Object);
Image<Color32> img = Image.Load<Color32>(stream, this.localDecoder.Object);
Assert.NotNull(img);
Assert.Equal(this.returnImage, img);
this.localDecoder.Verify(x => x.Decode<Color>(Configuration.Default, stream, null));
this.localDecoder.Verify(x => x.Decode<Color32>(Configuration.Default, stream, null));
}
[Fact]
@ -222,18 +222,18 @@ namespace ImageSharp.Tests
Image img = Image.Load(stream, this.localDecoder.Object, this.decoderOptions);
Assert.NotNull(img);
this.localDecoder.Verify(x => x.Decode<Color>(Configuration.Default, stream, this.decoderOptions));
this.localDecoder.Verify(x => x.Decode<Color32>(Configuration.Default, stream, this.decoderOptions));
}
[Fact]
public void LoadFromStreamWithTypeAndDecoderAndOptions()
{
Stream stream = new MemoryStream();
Image<Color> img = Image.Load<Color>(stream, this.localDecoder.Object, this.decoderOptions);
Image<Color32> img = Image.Load<Color32>(stream, this.localDecoder.Object, this.decoderOptions);
Assert.NotNull(img);
Assert.Equal(this.returnImage, img);
this.localDecoder.Verify(x => x.Decode<Color>(Configuration.Default, stream, this.decoderOptions));
this.localDecoder.Verify(x => x.Decode<Color32>(Configuration.Default, stream, this.decoderOptions));
}
[Fact]
@ -252,10 +252,10 @@ namespace ImageSharp.Tests
[Fact]
public void LoadFromBytesWithType()
{
Image<Color> img = Image.Load<Color>(this.DataStream.ToArray());
Image<Color32> img = Image.Load<Color32>(this.DataStream.ToArray());
Assert.NotNull(img);
Assert.Equal(TestFormat.GlobalTestFormat.Sample<Color>(), img);
Assert.Equal(TestFormat.GlobalTestFormat.Sample<Color32>(), img);
Assert.Equal(TestFormat.GlobalTestFormat, img.CurrentImageFormat);
TestFormat.GlobalTestFormat.VerifyDecodeCall(this.Marker, null, Configuration.Default);
@ -277,10 +277,10 @@ namespace ImageSharp.Tests
[Fact]
public void LoadFromBytesWithTypeAndOptions()
{
Image<Color> img = Image.Load<Color>(this.DataStream.ToArray(), this.decoderOptions);
Image<Color32> img = Image.Load<Color32>(this.DataStream.ToArray(), this.decoderOptions);
Assert.NotNull(img);
Assert.Equal(TestFormat.GlobalTestFormat.Sample<Color>(), img);
Assert.Equal(TestFormat.GlobalTestFormat.Sample<Color32>(), img);
Assert.Equal(TestFormat.GlobalTestFormat, img.CurrentImageFormat);
TestFormat.GlobalTestFormat.VerifyDecodeCall(this.Marker, this.decoderOptions, Configuration.Default);
@ -295,7 +295,7 @@ namespace ImageSharp.Tests
Assert.NotNull(img);
Assert.Equal(this.localFormat.Object, img.CurrentImageFormat);
this.localDecoder.Verify(x => x.Decode<Color>(this.LocalConfiguration, It.IsAny<Stream>(), null));
this.localDecoder.Verify(x => x.Decode<Color32>(this.LocalConfiguration, It.IsAny<Stream>(), null));
Assert.Equal(this.DataStream.ToArray(), this.DecodedData);
}
@ -303,14 +303,14 @@ namespace ImageSharp.Tests
[Fact]
public void LoadFromBytesWithTypeAndConfig()
{
Image<Color> img = Image.Load<Color>(this.LocalConfiguration, this.DataStream.ToArray());
Image<Color32> img = Image.Load<Color32>(this.LocalConfiguration, this.DataStream.ToArray());
Assert.NotNull(img);
Assert.Equal(this.returnImage, img);
Assert.Equal(this.localFormat.Object, img.CurrentImageFormat);
this.localDecoder.Verify(x => x.Decode<Color>(this.LocalConfiguration, It.IsAny<Stream>(), null));
this.localDecoder.Verify(x => x.Decode<Color32>(this.LocalConfiguration, It.IsAny<Stream>(), null));
Assert.Equal(this.DataStream.ToArray(), this.DecodedData);
}
@ -323,7 +323,7 @@ namespace ImageSharp.Tests
Assert.NotNull(img);
Assert.Equal(this.localFormat.Object, img.CurrentImageFormat);
this.localDecoder.Verify(x => x.Decode<Color>(this.LocalConfiguration, It.IsAny<Stream>(), this.decoderOptions));
this.localDecoder.Verify(x => x.Decode<Color32>(this.LocalConfiguration, It.IsAny<Stream>(), this.decoderOptions));
Assert.Equal(this.DataStream.ToArray(), this.DecodedData);
}
@ -331,13 +331,13 @@ namespace ImageSharp.Tests
[Fact]
public void LoadFromBytesWithTypeAndConfigAndOptions()
{
Image<Color> img = Image.Load<Color>(this.LocalConfiguration, this.DataStream.ToArray(), this.decoderOptions);
Image<Color32> img = Image.Load<Color32>(this.LocalConfiguration, this.DataStream.ToArray(), this.decoderOptions);
Assert.NotNull(img);
Assert.Equal(this.returnImage, img);
Assert.Equal(this.localFormat.Object, img.CurrentImageFormat);
this.localDecoder.Verify(x => x.Decode<Color>(this.LocalConfiguration, It.IsAny<Stream>(), this.decoderOptions));
this.localDecoder.Verify(x => x.Decode<Color32>(this.LocalConfiguration, It.IsAny<Stream>(), this.decoderOptions));
Assert.Equal(this.DataStream.ToArray(), this.DecodedData);
}
@ -349,18 +349,18 @@ namespace ImageSharp.Tests
Image img = Image.Load(this.DataStream.ToArray(), this.localDecoder.Object);
Assert.NotNull(img);
this.localDecoder.Verify(x => x.Decode<Color>(Configuration.Default, It.IsAny<Stream>(), null));
this.localDecoder.Verify(x => x.Decode<Color32>(Configuration.Default, It.IsAny<Stream>(), null));
Assert.Equal(this.DataStream.ToArray(), this.DecodedData);
}
[Fact]
public void LoadFromBytesWithTypeAndDecoder()
{
Image<Color> img = Image.Load<Color>(this.DataStream.ToArray(), this.localDecoder.Object);
Image<Color32> img = Image.Load<Color32>(this.DataStream.ToArray(), this.localDecoder.Object);
Assert.NotNull(img);
Assert.Equal(this.returnImage, img);
this.localDecoder.Verify(x => x.Decode<Color>(Configuration.Default, It.IsAny<Stream>(), null));
this.localDecoder.Verify(x => x.Decode<Color32>(Configuration.Default, It.IsAny<Stream>(), null));
Assert.Equal(this.DataStream.ToArray(), this.DecodedData);
}
@ -370,18 +370,18 @@ namespace ImageSharp.Tests
Image img = Image.Load(this.DataStream.ToArray(), this.localDecoder.Object, this.decoderOptions);
Assert.NotNull(img);
this.localDecoder.Verify(x => x.Decode<Color>(Configuration.Default, It.IsAny<Stream>(), this.decoderOptions));
this.localDecoder.Verify(x => x.Decode<Color32>(Configuration.Default, It.IsAny<Stream>(), this.decoderOptions));
Assert.Equal(this.DataStream.ToArray(), this.DecodedData);
}
[Fact]
public void LoadFromBytesWithTypeAndDecoderAndOptions()
{
Image<Color> img = Image.Load<Color>(this.DataStream.ToArray(), this.localDecoder.Object, this.decoderOptions);
Image<Color32> img = Image.Load<Color32>(this.DataStream.ToArray(), this.localDecoder.Object, this.decoderOptions);
Assert.NotNull(img);
Assert.Equal(this.returnImage, img);
this.localDecoder.Verify(x => x.Decode<Color>(Configuration.Default, It.IsAny<Stream>(), this.decoderOptions));
this.localDecoder.Verify(x => x.Decode<Color32>(Configuration.Default, It.IsAny<Stream>(), this.decoderOptions));
Assert.Equal(this.DataStream.ToArray(), this.DecodedData);
}
@ -401,10 +401,10 @@ namespace ImageSharp.Tests
[Fact]
public void LoadFromFileWithType()
{
Image<Color> img = Image.Load<Color>(this.DataStream);
Image<Color32> img = Image.Load<Color32>(this.DataStream);
Assert.NotNull(img);
Assert.Equal(TestFormat.GlobalTestFormat.Sample<Color>(), img);
Assert.Equal(TestFormat.GlobalTestFormat.Sample<Color32>(), img);
Assert.Equal(TestFormat.GlobalTestFormat, img.CurrentImageFormat);
TestFormat.GlobalTestFormat.VerifyDecodeCall(this.Marker, null, Configuration.Default);
@ -426,10 +426,10 @@ namespace ImageSharp.Tests
[Fact]
public void LoadFromFileWithTypeAndOptions()
{
Image<Color> img = Image.Load<Color>(this.DataStream, this.decoderOptions);
Image<Color32> img = Image.Load<Color32>(this.DataStream, this.decoderOptions);
Assert.NotNull(img);
Assert.Equal(TestFormat.GlobalTestFormat.Sample<Color>(), img);
Assert.Equal(TestFormat.GlobalTestFormat.Sample<Color32>(), img);
Assert.Equal(TestFormat.GlobalTestFormat, img.CurrentImageFormat);
TestFormat.GlobalTestFormat.VerifyDecodeCall(this.Marker, this.decoderOptions, Configuration.Default);
@ -444,20 +444,20 @@ namespace ImageSharp.Tests
Assert.NotNull(img);
Assert.Equal(this.localFormat.Object, img.CurrentImageFormat);
this.localDecoder.Verify(x => x.Decode<Color>(this.LocalConfiguration, this.DataStream, null));
this.localDecoder.Verify(x => x.Decode<Color32>(this.LocalConfiguration, this.DataStream, null));
}
[Fact]
public void LoadFromFileWithTypeAndConfig()
{
Image<Color> img = Image.Load<Color>(this.LocalConfiguration, this.FilePath);
Image<Color32> img = Image.Load<Color32>(this.LocalConfiguration, this.FilePath);
Assert.NotNull(img);
Assert.Equal(this.returnImage, img);
Assert.Equal(this.localFormat.Object, img.CurrentImageFormat);
this.localDecoder.Verify(x => x.Decode<Color>(this.LocalConfiguration, this.DataStream, null));
this.localDecoder.Verify(x => x.Decode<Color32>(this.LocalConfiguration, this.DataStream, null));
}
@ -469,20 +469,20 @@ namespace ImageSharp.Tests
Assert.NotNull(img);
Assert.Equal(this.localFormat.Object, img.CurrentImageFormat);
this.localDecoder.Verify(x => x.Decode<Color>(this.LocalConfiguration, this.DataStream, this.decoderOptions));
this.localDecoder.Verify(x => x.Decode<Color32>(this.LocalConfiguration, this.DataStream, this.decoderOptions));
}
[Fact]
public void LoadFromFileWithTypeAndConfigAndOptions()
{
Image<Color> img = Image.Load<Color>(this.LocalConfiguration, this.FilePath, this.decoderOptions);
Image<Color32> img = Image.Load<Color32>(this.LocalConfiguration, this.FilePath, this.decoderOptions);
Assert.NotNull(img);
Assert.Equal(this.returnImage, img);
Assert.Equal(this.localFormat.Object, img.CurrentImageFormat);
this.localDecoder.Verify(x => x.Decode<Color>(this.LocalConfiguration, this.DataStream, this.decoderOptions));
this.localDecoder.Verify(x => x.Decode<Color32>(this.LocalConfiguration, this.DataStream, this.decoderOptions));
}
@ -493,17 +493,17 @@ namespace ImageSharp.Tests
Image img = Image.Load(this.FilePath, this.localDecoder.Object);
Assert.NotNull(img);
this.localDecoder.Verify(x => x.Decode<Color>(Configuration.Default, this.DataStream, null));
this.localDecoder.Verify(x => x.Decode<Color32>(Configuration.Default, this.DataStream, null));
}
[Fact]
public void LoadFromFileWithTypeAndDecoder()
{
Image<Color> img = Image.Load<Color>(this.FilePath, this.localDecoder.Object);
Image<Color32> img = Image.Load<Color32>(this.FilePath, this.localDecoder.Object);
Assert.NotNull(img);
Assert.Equal(this.returnImage, img);
this.localDecoder.Verify(x => x.Decode<Color>(Configuration.Default, this.DataStream, null));
this.localDecoder.Verify(x => x.Decode<Color32>(Configuration.Default, this.DataStream, null));
}
[Fact]
@ -512,17 +512,17 @@ namespace ImageSharp.Tests
Image img = Image.Load(this.FilePath, this.localDecoder.Object, this.decoderOptions);
Assert.NotNull(img);
this.localDecoder.Verify(x => x.Decode<Color>(Configuration.Default, this.DataStream, this.decoderOptions));
this.localDecoder.Verify(x => x.Decode<Color32>(Configuration.Default, this.DataStream, this.decoderOptions));
}
[Fact]
public void LoadFromFileWithTypeAndDecoderAndOptions()
{
Image<Color> img = Image.Load<Color>(this.FilePath, this.localDecoder.Object, this.decoderOptions);
Image<Color32> img = Image.Load<Color32>(this.FilePath, this.localDecoder.Object, this.decoderOptions);
Assert.NotNull(img);
Assert.Equal(this.returnImage, img);
this.localDecoder.Verify(x => x.Decode<Color>(Configuration.Default, this.DataStream, this.decoderOptions));
this.localDecoder.Verify(x => x.Decode<Color32>(Configuration.Default, this.DataStream, this.decoderOptions));
}
public void Dispose()

24
tests/ImageSharp.Tests/Image/ImageSaveTests.cs

@ -59,7 +59,7 @@ namespace ImageSharp.Tests
this.fileSystem.Setup(x => x.Create("path.png")).Returns(stream);
this.Image.Save("path.png");
this.encoder.Verify(x => x.Encode<Color>(this.Image, stream, null));
this.encoder.Verify(x => x.Encode<Color32>(this.Image, stream, null));
}
[Fact]
@ -70,7 +70,7 @@ namespace ImageSharp.Tests
this.Image.Save("path.jpg", this.encoderOptions);
this.encoder.Verify(x => x.Encode<Color>(this.Image, stream, this.encoderOptions));
this.encoder.Verify(x => x.Encode<Color32>(this.Image, stream, this.encoderOptions));
}
[Fact]
@ -81,7 +81,7 @@ namespace ImageSharp.Tests
this.Image.Save("path.jpg", this.encoderNotInFormat.Object);
this.encoderNotInFormat.Verify(x => x.Encode<Color>(this.Image, stream, null));
this.encoderNotInFormat.Verify(x => x.Encode<Color32>(this.Image, stream, null));
}
[Fact]
@ -92,7 +92,7 @@ namespace ImageSharp.Tests
this.Image.Save("path.jpg", this.encoderNotInFormat.Object, this.encoderOptions);
this.encoderNotInFormat.Verify(x => x.Encode<Color>(this.Image, stream, this.encoderOptions));
this.encoderNotInFormat.Verify(x => x.Encode<Color32>(this.Image, stream, this.encoderOptions));
}
@ -105,7 +105,7 @@ namespace ImageSharp.Tests
this.Image.Save("path.jpg", this.encoderNotInFormat.Object);
this.encoderNotInFormat.Verify(x => x.Encode<Color>(this.Image, stream, null));
this.encoderNotInFormat.Verify(x => x.Encode<Color32>(this.Image, stream, null));
}
[Fact]
@ -116,7 +116,7 @@ namespace ImageSharp.Tests
this.Image.Save("path.jpg", this.encoderNotInFormat.Object, this.encoderOptions);
this.encoderNotInFormat.Verify(x => x.Encode<Color>(this.Image, stream, this.encoderOptions));
this.encoderNotInFormat.Verify(x => x.Encode<Color32>(this.Image, stream, this.encoderOptions));
}
[Fact]
@ -125,7 +125,7 @@ namespace ImageSharp.Tests
Stream stream = new MemoryStream();
this.Image.Save(stream);
this.encoder.Verify(x => x.Encode<Color>(this.Image, stream, null));
this.encoder.Verify(x => x.Encode<Color32>(this.Image, stream, null));
}
[Fact]
@ -135,7 +135,7 @@ namespace ImageSharp.Tests
this.Image.Save(stream, this.encoderOptions);
this.encoder.Verify(x => x.Encode<Color>(this.Image, stream, this.encoderOptions));
this.encoder.Verify(x => x.Encode<Color32>(this.Image, stream, this.encoderOptions));
}
[Fact]
@ -145,7 +145,7 @@ namespace ImageSharp.Tests
this.Image.Save(stream, this.encoderNotInFormat.Object);
this.encoderNotInFormat.Verify(x => x.Encode<Color>(this.Image, stream, null));
this.encoderNotInFormat.Verify(x => x.Encode<Color32>(this.Image, stream, null));
}
[Fact]
@ -155,7 +155,7 @@ namespace ImageSharp.Tests
this.Image.Save(stream, this.encoderNotInFormat.Object, this.encoderOptions);
this.encoderNotInFormat.Verify(x => x.Encode<Color>(this.Image, stream, this.encoderOptions));
this.encoderNotInFormat.Verify(x => x.Encode<Color32>(this.Image, stream, this.encoderOptions));
}
[Fact]
@ -165,7 +165,7 @@ namespace ImageSharp.Tests
this.Image.Save(stream, this.formatNotRegistered.Object);
this.encoderNotInFormat.Verify(x => x.Encode<Color>(this.Image, stream, null));
this.encoderNotInFormat.Verify(x => x.Encode<Color32>(this.Image, stream, null));
}
[Fact]
@ -175,7 +175,7 @@ namespace ImageSharp.Tests
this.Image.Save(stream, this.formatNotRegistered.Object, this.encoderOptions);
this.encoderNotInFormat.Verify(x => x.Encode<Color>(this.Image, stream, this.encoderOptions));
this.encoderNotInFormat.Verify(x => x.Encode<Color32>(this.Image, stream, this.encoderOptions));
}
public void Dispose()

16
tests/ImageSharp.Tests/Image/PixelAccessorTests.cs

@ -125,7 +125,7 @@ namespace ImageSharp.Tests
[Fact]
public void CopyFromZYX()
{
using (Image<Color> image = new Image<Color>(1, 1))
using (Image<Color32> image = new Image<Color32>(1, 1))
{
CopyFromZYX(image);
}
@ -134,7 +134,7 @@ namespace ImageSharp.Tests
[Fact]
public void CopyFromZYXW()
{
using (Image<Color> image = new Image<Color>(1, 1))
using (Image<Color32> image = new Image<Color32>(1, 1))
{
CopyFromZYXW(image);
}
@ -143,7 +143,7 @@ namespace ImageSharp.Tests
[Fact]
public void CopyToZYX()
{
using (Image<Color> image = new Image<Color>(1, 1))
using (Image<Color32> image = new Image<Color32>(1, 1))
{
CopyToZYX(image);
}
@ -152,7 +152,7 @@ namespace ImageSharp.Tests
[Fact]
public void CopyToZYXW()
{
using (Image<Color> image = new Image<Color>(1, 1))
using (Image<Color32> image = new Image<Color32>(1, 1))
{
CopyToZYXW(image);
}
@ -176,7 +176,7 @@ namespace ImageSharp.Tests
pixels.CopyFrom(row, 0);
Color color = (Color)(object)pixels[0, 0];
Color32 color = (Color32)(object)pixels[0, 0];
Assert.Equal(red, color.R);
Assert.Equal(green, color.G);
Assert.Equal(blue, color.B);
@ -204,7 +204,7 @@ namespace ImageSharp.Tests
pixels.CopyFrom(row, 0);
Color color = (Color)(object)pixels[0, 0];
Color32 color = (Color32)(object)pixels[0, 0];
Assert.Equal(red, color.R);
Assert.Equal(green, color.G);
Assert.Equal(blue, color.B);
@ -224,7 +224,7 @@ namespace ImageSharp.Tests
using (PixelArea<TColor> row = new PixelArea<TColor>(1, ComponentOrder.Zyx))
{
pixels[0, 0] = (TColor)(object)new Color(red, green, blue);
pixels[0, 0] = (TColor)(object)new Color32(red, green, blue);
pixels.CopyTo(row, 0);
@ -247,7 +247,7 @@ namespace ImageSharp.Tests
using (PixelArea<TColor> row = new PixelArea<TColor>(1, ComponentOrder.Zyxw))
{
pixels[0, 0] = (TColor)(object)new Color(red, green, blue, alpha);
pixels[0, 0] = (TColor)(object)new Color32(red, green, blue, alpha);
pixels.CopyTo(row, 0);

2
tests/ImageSharp.Tests/MetaData/Profiles/Exif/ExifProfileTests.cs

@ -243,7 +243,7 @@ namespace ImageSharp.Tests
TestProfile(profile);
Image<Color> thumbnail = profile.CreateThumbnail<Color>();
Image<Color32> thumbnail = profile.CreateThumbnail<Color32>();
Assert.NotNull(thumbnail);
Assert.Equal(256, thumbnail.Width);
Assert.Equal(170, thumbnail.Height);

2
tests/ImageSharp.Tests/Processors/Filters/BackgroundColorTest.cs

@ -21,7 +21,7 @@ namespace ImageSharp.Tests
using (Image image = file.CreateImage())
using (FileStream output = File.OpenWrite($"{path}/{file.FileName}"))
{
image.BackgroundColor(Color.HotPink).Save(output);
image.BackgroundColor(Color32.HotPink).Save(output);
}
}
}

2
tests/ImageSharp.Tests/Processors/Filters/GlowTest.cs

@ -37,7 +37,7 @@ namespace ImageSharp.Tests
using (Image image = file.CreateImage())
using (FileStream output = File.OpenWrite($"{path}/{filename}"))
{
image.Glow(Color.HotPink).Save(output);
image.Glow(Color32.HotPink).Save(output);
}
}
}

6
tests/ImageSharp.Tests/Processors/Filters/ResizeProfilingBenchmarks.cs

@ -36,13 +36,13 @@ namespace ImageSharp.Tests
// [Fact]
public void PrintWeightsData()
{
ResizeProcessor<Color> proc = new ResizeProcessor<Color>(new BicubicResampler(), 200, 200);
ResizeProcessor<Color32> proc = new ResizeProcessor<Color32>(new BicubicResampler(), 200, 200);
ResamplingWeightedProcessor<Color>.WeightsBuffer weights = proc.PrecomputeWeights(200, 500);
ResamplingWeightedProcessor<Color32>.WeightsBuffer weights = proc.PrecomputeWeights(200, 500);
StringBuilder bld = new StringBuilder();
foreach (ResamplingWeightedProcessor<Color>.WeightsWindow window in weights.Weights)
foreach (ResamplingWeightedProcessor<Color32>.WeightsWindow window in weights.Weights)
{
for (int i = 0; i < window.Length; i++)
{

2
tests/ImageSharp.Tests/Processors/Filters/VignetteTest.cs

@ -37,7 +37,7 @@ namespace ImageSharp.Tests
using (Image image = file.CreateImage())
using (FileStream output = File.OpenWrite($"{path}/{filename}"))
{
image.Vignette(Color.HotPink).Save(output);
image.Vignette(Color32.HotPink).Save(output);
}
}
}

8
tests/ImageSharp.Tests/TestUtilities/Factories/ImageFactory.cs

@ -5,13 +5,13 @@
namespace ImageSharp.Tests
{
public class ImageFactory : GenericFactory<Color>
public class ImageFactory : GenericFactory<Color32>
{
public override Image<Color> CreateImage(byte[] bytes) => Image.Load(bytes);
public override Image<Color32> CreateImage(byte[] bytes) => Image.Load(bytes);
public override Image<Color> CreateImage(int width, int height) => new Image(width, height);
public override Image<Color32> CreateImage(int width, int height) => new Image(width, height);
public override Image<Color> CreateImage(Image<Color> other)
public override Image<Color32> CreateImage(Image<Color32> other)
{
Image img = (Image)other;
return new Image(img);

6
tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestPatternProvider.cs

@ -147,9 +147,9 @@ namespace ImageSharp.Tests
int bottom = pixels.Height;
int height = (int)Math.Ceiling(pixels.Height / 6f);
Vector4 red = Color.Red.ToVector4(); // use real color so we can see har it translates in the test pattern
Vector4 green = Color.Green.ToVector4(); // use real color so we can see har it translates in the test pattern
Vector4 blue = Color.Blue.ToVector4(); // use real color so we can see har it translates in the test pattern
Vector4 red = Color32.Red.ToVector4(); // use real color so we can see har it translates in the test pattern
Vector4 green = Color32.Green.ToVector4(); // use real color so we can see har it translates in the test pattern
Vector4 blue = Color32.Blue.ToVector4(); // use real color so we can see har it translates in the test pattern
TColor c = default(TColor);

8
tests/ImageSharp.Tests/TestUtilities/TestUtilityExtensions.cs

@ -18,7 +18,7 @@ namespace ImageSharp.Tests
{
private static readonly Dictionary<Type, PixelTypes> ClrTypes2PixelTypes = new Dictionary<Type, PixelTypes>();
private static readonly Assembly ImageSharpAssembly = typeof(Color).GetTypeInfo().Assembly;
private static readonly Assembly ImageSharpAssembly = typeof(Color32).GetTypeInfo().Assembly;
private static readonly Dictionary<PixelTypes, Type> PixelTypes2ClrTypes = new Dictionary<PixelTypes, Type>();
@ -28,8 +28,8 @@ namespace ImageSharp.Tests
static TestUtilityExtensions()
{
string nameSpace = typeof(Color).FullName;
nameSpace = nameSpace.Substring(0, nameSpace.Length - typeof(Color).Name.Length - 1);
string nameSpace = typeof(Color32).FullName;
nameSpace = nameSpace.Substring(0, nameSpace.Length - typeof(Color32).Name.Length - 1);
foreach (PixelTypes pt in AllConcretePixelTypes.Where(pt => pt != PixelTypes.StandardImageClass))
{
string typeName = $"{nameSpace}.{pt.ToString()}";
@ -42,7 +42,7 @@ namespace ImageSharp.Tests
PixelTypes2ClrTypes[pt] = t;
ClrTypes2PixelTypes[t] = pt;
}
PixelTypes2ClrTypes[PixelTypes.StandardImageClass] = typeof(Color);
PixelTypes2ClrTypes[PixelTypes.StandardImageClass] = typeof(Color32);
}
public static bool HasFlag(this PixelTypes pixelTypes, PixelTypes flag) => (pixelTypes & flag) == flag;

4
tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs

@ -151,7 +151,7 @@ namespace ImageSharp.Tests
public static readonly TheoryData<object> BasicData = new TheoryData<object>()
{
TestImageProvider<Color>.Blank(10, 20),
TestImageProvider<Color32>.Blank(10, 20),
TestImageProvider<HalfVector4>.Blank(
10,
20),
@ -169,7 +169,7 @@ namespace ImageSharp.Tests
public static readonly TheoryData<object> FileData = new TheoryData<object>()
{
TestImageProvider<Color>.File(
TestImageProvider<Color32>.File(
TestImages.Bmp.Car),
TestImageProvider<HalfVector4>.File(
TestImages.Bmp.F)

18
tests/ImageSharp.Tests/TestUtilities/Tests/TestUtilityExtensionsTests.cs

@ -51,10 +51,10 @@ namespace ImageSharp.Tests
[Fact]
public void Baz()
{
Type type = typeof(Color).GetTypeInfo().Assembly.GetType("ImageSharp.Color");
Type type = typeof(Color32).GetTypeInfo().Assembly.GetType("ImageSharp.Color");
this.Output.WriteLine(type.ToString());
Type fake = typeof(Color).GetTypeInfo().Assembly.GetType("ImageSharp.dsaada_DASqewrr");
Type fake = typeof(Color32).GetTypeInfo().Assembly.GetType("ImageSharp.dsaada_DASqewrr");
Assert.Null(fake);
}
@ -84,17 +84,17 @@ namespace ImageSharp.Tests
}
[Theory]
[InlineData(PixelTypes.Color, typeof(Color))]
[InlineData(PixelTypes.Color, typeof(Color32))]
[InlineData(PixelTypes.Argb, typeof(Argb))]
[InlineData(PixelTypes.HalfVector4, typeof(HalfVector4))]
[InlineData(PixelTypes.StandardImageClass, typeof(Color))]
[InlineData(PixelTypes.StandardImageClass, typeof(Color32))]
public void ToType(PixelTypes pt, Type expectedType)
{
Assert.Equal(pt.ToType(), expectedType);
}
[Theory]
[InlineData(typeof(Color), PixelTypes.Color)]
[InlineData(typeof(Color32), PixelTypes.Color)]
[InlineData(typeof(Argb), PixelTypes.Argb)]
public void GetPixelType(Type clrType, PixelTypes expectedPixelType)
{
@ -120,9 +120,9 @@ namespace ImageSharp.Tests
AssertContainsPixelType<Alpha8>(PixelTypes.Alpha8, expanded);
AssertContainsPixelType<Bgr565>(PixelTypes.Bgr565, expanded);
AssertContainsPixelType<Color>(PixelTypes.Color, expanded);
AssertContainsPixelType<Color32>(PixelTypes.Color, expanded);
AssertContainsPixelType<HalfVector2>(PixelTypes.HalfVector2, expanded);
AssertContainsPixelType<Color>(PixelTypes.StandardImageClass, expanded);
AssertContainsPixelType<Color32>(PixelTypes.StandardImageClass, expanded);
}
[Fact]
@ -131,8 +131,8 @@ namespace ImageSharp.Tests
KeyValuePair<PixelTypes, Type>[] expanded = PixelTypes.All.ExpandAllTypes().ToArray();
Assert.True(expanded.Length >= TestUtilityExtensions.GetAllPixelTypes().Length - 2);
AssertContainsPixelType<Color>(PixelTypes.Color, expanded);
AssertContainsPixelType<Color>(PixelTypes.StandardImageClass, expanded);
AssertContainsPixelType<Color32>(PixelTypes.Color, expanded);
AssertContainsPixelType<Color32>(PixelTypes.StandardImageClass, expanded);
}
}
}
Loading…
Cancel
Save