Browse Source

Rename to Color and ColorVector

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

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

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

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

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

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

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

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

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

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

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

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

@ -6,16 +6,16 @@
namespace ImageSharp.Drawing.Pens namespace ImageSharp.Drawing.Pens
{ {
/// <summary> /// <summary>
/// Represents a <see cref="Pen{TColor}"/> in the <see cref="Color32"/> color space. /// Represents a <see cref="Pen{TColor}"/> in the <see cref="Color"/> color space.
/// </summary> /// </summary>
public class Pen : Pen<Color32> public class Pen : Pen<Color>
{ {
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Pen"/> class. /// Initializes a new instance of the <see cref="Pen"/> class.
/// </summary> /// </summary>
/// <param name="color">The color.</param> /// <param name="color">The color.</param>
/// <param name="width">The width.</param> /// <param name="width">The width.</param>
public Pen(Color32 color, float width) public Pen(Color color, float width)
: base(color, width) : base(color, width)
{ {
} }
@ -25,7 +25,7 @@ namespace ImageSharp.Drawing.Pens
/// </summary> /// </summary>
/// <param name="brush">The brush.</param> /// <param name="brush">The brush.</param>
/// <param name="width">The width.</param> /// <param name="width">The width.</param>
public Pen(IBrush<Color32> brush, float width) public Pen(IBrush<Color> brush, float width)
: base(brush, width) : base(brush, width)
{ {
} }
@ -36,7 +36,7 @@ namespace ImageSharp.Drawing.Pens
/// <param name="brush">The brush.</param> /// <param name="brush">The brush.</param>
/// <param name="width">The width.</param> /// <param name="width">The width.</param>
/// <param name="pattern">The pattern.</param> /// <param name="pattern">The pattern.</param>
public Pen(IBrush<Color32> brush, float width, float[] pattern) public Pen(IBrush<Color> brush, float width, float[] pattern)
: base(brush, width, pattern) : base(brush, width, pattern)
{ {
} }
@ -45,7 +45,7 @@ namespace ImageSharp.Drawing.Pens
/// Initializes a new instance of the <see cref="Pen"/> class. /// Initializes a new instance of the <see cref="Pen"/> class.
/// </summary> /// </summary>
/// <param name="pen">The pen.</param> /// <param name="pen">The pen.</param>
internal Pen(Pen<Color32> pen) internal Pen(Pen<Color> pen)
: base(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="color">The color.</param>
/// <param name="width">The width.</param> /// <param name="width">The width.</param>
/// <returns>The Pen</returns> /// <returns>The Pen</returns>
public static Pen Solid(Color32 color, float width) => new Pen(color, width); public static Pen Solid(Color color, float width) => new Pen(color, width);
/// <summary> /// <summary>
/// Create a solid pen with out any drawing patterns /// 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="brush">The brush.</param>
/// <param name="width">The width.</param> /// <param name="width">The width.</param>
/// <returns>The Pen</returns> /// <returns>The Pen</returns>
public static Pen Solid(IBrush<Color32> brush, float width) => new Pen(brush, width); public static Pen Solid(IBrush<Color> brush, float width) => new Pen(brush, width);
/// <summary> /// <summary>
/// Create a pen with a 'Dash' drawing patterns /// Create a pen with a 'Dash' drawing patterns
@ -32,7 +32,7 @@ namespace ImageSharp.Drawing.Pens
/// <param name="color">The color.</param> /// <param name="color">The color.</param>
/// <param name="width">The width.</param> /// <param name="width">The width.</param>
/// <returns>The Pen</returns> /// <returns>The Pen</returns>
public static Pen Dash(Color32 color, float width) => new Pen(Pens<Color32>.Dash(color, width)); public static Pen Dash(Color color, float width) => new Pen(Pens<Color>.Dash(color, width));
/// <summary> /// <summary>
/// Create a pen with a 'Dash' drawing patterns /// Create a pen with a 'Dash' drawing patterns
@ -40,7 +40,7 @@ namespace ImageSharp.Drawing.Pens
/// <param name="brush">The brush.</param> /// <param name="brush">The brush.</param>
/// <param name="width">The width.</param> /// <param name="width">The width.</param>
/// <returns>The Pen</returns> /// <returns>The Pen</returns>
public static Pen Dash(IBrush<Color32> brush, float width) => new Pen(Pens<Color32>.Dash(brush, width)); public static Pen Dash(IBrush<Color> brush, float width) => new Pen(Pens<Color>.Dash(brush, width));
/// <summary> /// <summary>
/// Create a pen with a 'Dot' drawing patterns /// Create a pen with a 'Dot' drawing patterns
@ -48,7 +48,7 @@ namespace ImageSharp.Drawing.Pens
/// <param name="color">The color.</param> /// <param name="color">The color.</param>
/// <param name="width">The width.</param> /// <param name="width">The width.</param>
/// <returns>The Pen</returns> /// <returns>The Pen</returns>
public static Pen Dot(Color32 color, float width) => new Pen(Pens<Color32>.Dot(color, width)); public static Pen Dot(Color color, float width) => new Pen(Pens<Color>.Dot(color, width));
/// <summary> /// <summary>
/// Create a pen with a 'Dot' drawing patterns /// Create a pen with a 'Dot' drawing patterns
@ -56,7 +56,7 @@ namespace ImageSharp.Drawing.Pens
/// <param name="brush">The brush.</param> /// <param name="brush">The brush.</param>
/// <param name="width">The width.</param> /// <param name="width">The width.</param>
/// <returns>The Pen</returns> /// <returns>The Pen</returns>
public static Pen Dot(IBrush<Color32> brush, float width) => new Pen(Pens<Color32>.Dot(brush, width)); public static Pen Dot(IBrush<Color> brush, float width) => new Pen(Pens<Color>.Dot(brush, width));
/// <summary> /// <summary>
/// Create a pen with a 'Dash Dot' drawing patterns /// 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="color">The color.</param>
/// <param name="width">The width.</param> /// <param name="width">The width.</param>
/// <returns>The Pen</returns> /// <returns>The Pen</returns>
public static Pen DashDot(Color32 color, float width) => new Pen(Pens<Color32>.DashDot(color, width)); public static Pen DashDot(Color color, float width) => new Pen(Pens<Color>.DashDot(color, width));
/// <summary> /// <summary>
/// Create a pen with a 'Dash Dot' drawing patterns /// 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="brush">The brush.</param>
/// <param name="width">The width.</param> /// <param name="width">The width.</param>
/// <returns>The Pen</returns> /// <returns>The Pen</returns>
public static Pen DashDot(IBrush<Color32> brush, float width) => new Pen(Pens<Color32>.DashDot(brush, width)); public static Pen DashDot(IBrush<Color> brush, float width) => new Pen(Pens<Color>.DashDot(brush, width));
/// <summary> /// <summary>
/// Create a pen with a 'Dash Dot Dot' drawing patterns /// 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="color">The color.</param>
/// <param name="width">The width.</param> /// <param name="width">The width.</param>
/// <returns>The Pen</returns> /// <returns>The Pen</returns>
public static Pen DashDotDot(Color32 color, float width) => new Pen(Pens<Color32>.DashDotDot(color, width)); public static Pen DashDotDot(Color color, float width) => new Pen(Pens<Color>.DashDotDot(color, width));
/// <summary> /// <summary>
/// Create a pen with a 'Dash Dot Dot' drawing patterns /// 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="brush">The brush.</param>
/// <param name="width">The width.</param> /// <param name="width">The width.</param>
/// <returns>The Pen</returns> /// <returns>The Pen</returns>
public static Pen DashDotDot(IBrush<Color32> brush, float width) => new Pen(Pens<Color32>.DashDotDot(brush, width)); public static Pen DashDotDot(IBrush<Color> brush, float width) => new Pen(Pens<Color>.DashDotDot(brush, width));
} }
} }

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

@ -1,11 +1,17 @@
namespace ImageSharp // <copyright file="Color.BulkOperations.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;
using System.Numerics; using System.Numerics;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
/// <summary> /// <summary>
/// Unpacked pixel type containing four 16-bit unsigned normalized values ranging from 0 to 1. /// Unpacked pixel 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. /// The color components are stored in red, green, blue, and alpha order.
/// </summary> /// </summary>
/// <remarks> /// <remarks>
@ -19,17 +25,265 @@
/// </summary> /// </summary>
internal class BulkOperations : BulkPixelOperations<Color> internal class BulkOperations : BulkPixelOperations<Color>
{ {
/// <summary>
/// SIMD optimized bulk implementation of <see cref="IPixel.PackFromVector4(Vector4)"/>
/// that works only with `count` divisible by <see cref="Vector{UInt32}.Count"/>.
/// </summary>
/// <param name="sourceColors">The <see cref="BufferSpan{T}"/> to the source colors.</param>
/// <param name="destVectors">The <see cref="BufferSpan{T}"/> to the dstination vectors.</param>
/// <param name="count">The number of pixels to convert.</param>
/// <remarks>
/// Implementation adapted from:
/// <see>
/// <cref>http://stackoverflow.com/a/5362789</cref>
/// </see>
/// TODO: We can replace this implementation in the future using new Vector API-s:
/// <see>
/// <cref>https://github.com/dotnet/corefx/issues/15957</cref>
/// </see>
/// </remarks>
internal static unsafe void ToVector4SimdAligned(BufferSpan<Color> sourceColors, BufferSpan<Vector4> destVectors, int count)
{
if (!Vector.IsHardwareAccelerated)
{
throw new InvalidOperationException(
"Color32.BulkOperations.ToVector4SimdAligned() should not be called when Vector.IsHardwareAccelerated == false!");
}
int vecSize = Vector<uint>.Count;
DebugGuard.IsTrue(
count % vecSize == 0,
nameof(count),
"Argument 'count' should divisible by Vector<uint>.Count!");
Vector<float> bVec = new Vector<float>(256.0f / 255.0f);
Vector<float> magicFloat = new Vector<float>(32768.0f);
Vector<uint> magicInt = new Vector<uint>(1191182336); // reinterpreded value of 32768.0f
Vector<uint> mask = new Vector<uint>(255);
int unpackedRawCount = count * 4;
ref uint src = ref Unsafe.As<Color, uint>(ref sourceColors.DangerousGetPinnableReference());
using (Buffer<uint> tempBuf = new Buffer<uint>(
unpackedRawCount + Vector<uint>.Count))
{
uint[] temp = tempBuf.Array;
float[] fTemp = Unsafe.As<float[]>(temp);
ref UnpackedRGBA tempBase = ref Unsafe.As<uint, UnpackedRGBA>(ref tempBuf[0]);
for (int i = 0; i < count; i++)
{
uint sVal = Unsafe.Add(ref src, i);
ref UnpackedRGBA dst = ref Unsafe.Add(ref tempBase, i);
// This call is the bottleneck now:
dst.Load(sVal);
}
for (int i = 0; i < unpackedRawCount; i += vecSize)
{
Vector<uint> vi = new Vector<uint>(temp, i);
vi &= mask;
vi |= magicInt;
Vector<float> vf = Vector.AsVectorSingle(vi);
vf = (vf - magicFloat) * bVec;
vf.CopyTo(fTemp, i);
}
BufferSpan.Copy(tempBuf.Span.AsBytes(), destVectors.AsBytes(), unpackedRawCount * sizeof(uint));
}
}
/// <inheritdoc /> /// <inheritdoc />
internal override void ToVector4(BufferSpan<Color> sourceColors, BufferSpan<Vector4> destVectors, int count) internal override void ToVector4(BufferSpan<Color> sourceColors, BufferSpan<Vector4> destVectors, int count)
{ {
ref Vector4 sourceRef = ref Unsafe.As<Color, Vector4>(ref sourceColors.DangerousGetPinnableReference()); if (count < 256 || !Vector.IsHardwareAccelerated)
ref Vector4 destRef = ref destVectors.DangerousGetPinnableReference(); {
// Doesn't worth to bother with SIMD:
base.ToVector4(sourceColors, destVectors, count);
return;
}
int remainder = count % Vector<uint>.Count;
int alignedCount = count - remainder;
if (alignedCount > 0)
{
ToVector4SimdAligned(sourceColors, destVectors, alignedCount);
}
if (remainder > 0)
{
sourceColors = sourceColors.Slice(alignedCount);
destVectors = destVectors.Slice(alignedCount);
base.ToVector4(sourceColors, destVectors, remainder);
}
}
/// <inheritdoc />
internal override void PackFromXyzBytes(BufferSpan<byte> sourceBytes, BufferSpan<Color> destColors, int count)
{
ref RGB24 sourceRef = ref Unsafe.As<byte, RGB24>(ref sourceBytes.DangerousGetPinnableReference());
ref Color destRef = ref destColors.DangerousGetPinnableReference();
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
ref Vector4 sp = ref Unsafe.Add(ref sourceRef, i); ref RGB24 sp = ref Unsafe.Add(ref sourceRef, i);
ref Vector4 dp = ref Unsafe.Add(ref destRef, i); ref Color dp = ref Unsafe.Add(ref destRef, i);
dp = sp;
Unsafe.As<Color, RGB24>(ref dp) = sp;
dp.A = 255;
}
}
/// <inheritdoc />
internal override void ToXyzBytes(BufferSpan<Color> sourceColors, BufferSpan<byte> destBytes, int count)
{
ref Color sourceRef = ref sourceColors.DangerousGetPinnableReference();
ref RGB24 destRef = ref Unsafe.As<byte, RGB24>(ref destBytes.DangerousGetPinnableReference());
for (int i = 0; i < count; i++)
{
ref Color sp = ref Unsafe.Add(ref sourceRef, i);
ref RGB24 dp = ref Unsafe.Add(ref destRef, i);
dp = Unsafe.As<Color, RGB24>(ref sp);
}
}
/// <inheritdoc />
internal override unsafe void PackFromXyzwBytes(BufferSpan<byte> sourceBytes, BufferSpan<Color> destColors, int count)
{
BufferSpan.Copy(sourceBytes, destColors.AsBytes(), count * sizeof(Color));
}
/// <inheritdoc />
internal override unsafe void ToXyzwBytes(BufferSpan<Color> sourceColors, BufferSpan<byte> destBytes, int count)
{
BufferSpan.Copy(sourceColors.AsBytes(), destBytes, count * sizeof(Color));
}
/// <inheritdoc />
internal override void PackFromZyxBytes(BufferSpan<byte> sourceBytes, BufferSpan<Color> destColors, int count)
{
ref RGB24 sourceRef = ref Unsafe.As<byte, RGB24>(ref sourceBytes.DangerousGetPinnableReference());
ref Color destRef = ref destColors.DangerousGetPinnableReference();
for (int i = 0; i < count; i++)
{
ref RGB24 sp = ref Unsafe.Add(ref sourceRef, i);
ref Color dp = ref Unsafe.Add(ref destRef, i);
Unsafe.As<Color, RGB24>(ref dp) = sp.ToZyx();
dp.A = 255;
}
}
/// <inheritdoc />
internal override void ToZyxBytes(BufferSpan<Color> sourceColors, BufferSpan<byte> destBytes, int count)
{
ref Color sourceRef = ref sourceColors.DangerousGetPinnableReference();
ref RGB24 destRef = ref Unsafe.As<byte, RGB24>(ref destBytes.DangerousGetPinnableReference());
for (int i = 0; i < count; i++)
{
ref Color sp = ref Unsafe.Add(ref sourceRef, i);
ref RGB24 dp = ref Unsafe.Add(ref destRef, i);
dp = Unsafe.As<Color, RGB24>(ref sp).ToZyx();
}
}
/// <inheritdoc />
internal override void PackFromZyxwBytes(BufferSpan<byte> sourceBytes, BufferSpan<Color> destColors, int count)
{
ref RGBA32 sourceRef = ref Unsafe.As<byte, RGBA32>(ref sourceBytes.DangerousGetPinnableReference());
ref Color destRef = ref destColors.DangerousGetPinnableReference();
for (int i = 0; i < count; i++)
{
ref RGBA32 sp = ref Unsafe.Add(ref sourceRef, i);
ref Color dp = ref Unsafe.Add(ref destRef, i);
RGBA32 zyxw = sp.ToZyxw();
dp = Unsafe.As<RGBA32, Color>(ref zyxw);
}
}
/// <inheritdoc />
internal override void ToZyxwBytes(BufferSpan<Color> sourceColors, BufferSpan<byte> destBytes, int count)
{
ref Color sourceRef = ref sourceColors.DangerousGetPinnableReference();
ref RGBA32 destRef = ref Unsafe.As<byte, RGBA32>(ref destBytes.DangerousGetPinnableReference());
for (int i = 0; i < count; i++)
{
ref RGBA32 sp = ref Unsafe.As<Color, RGBA32>(ref Unsafe.Add(ref sourceRef, i));
ref RGBA32 dp = ref Unsafe.Add(ref destRef, i);
dp = sp.ToZyxw();
}
}
/// <summary>
/// Helper struct to manipulate 3-byte RGB data.
/// </summary>
[StructLayout(LayoutKind.Sequential)]
private struct RGB24
{
private byte x;
private byte y;
private byte z;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public RGB24 ToZyx() => new RGB24 { x = this.z, y = this.y, z = this.x };
}
/// <summary>
/// Helper struct to manipulate 4-byte RGBA data.
/// </summary>
[StructLayout(LayoutKind.Sequential)]
private struct RGBA32
{
private byte x;
private byte y;
private byte z;
private byte w;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public RGBA32 ToZyxw() => new RGBA32 { x = this.z, y = this.y, z = this.x, w = this.w };
}
/// <summary>
/// Value type to store <see cref="Color"/>-s unpacked into multiple <see cref="uint"/>-s.
/// </summary>
[StructLayout(LayoutKind.Sequential)]
private struct UnpackedRGBA
{
private uint r;
private uint g;
private uint b;
private uint a;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Load(uint p)
{
this.r = p;
this.g = p >> GreenShift;
this.b = p >> BlueShift;
this.a = p >> AlphaShift;
} }
} }
} }

728
src/ImageSharp/Colors/Color.Definitions.cs

@ -0,0 +1,728 @@
// <copyright file="Color.Definitions.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;
}
}

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

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

247
src/ImageSharp/Colors/Color.cs

@ -7,17 +7,43 @@ namespace ImageSharp
{ {
using System.Numerics; using System.Numerics;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
/// <summary> /// <summary>
/// Unpacked pixel type containing four 16-bit unsigned normalized values ranging from 0 to 1. /// Unpacked pixel 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. /// The color components are stored in red, green, blue, and alpha order.
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// This struct is fully mutable. This is done (against the guidelines) for the sake of performance, /// 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. /// as it avoids the need to create new values for modification operations.
/// </remarks> /// </remarks>
[StructLayout(LayoutKind.Explicit)]
public partial struct Color : IPixel<Color> public partial struct Color : IPixel<Color>
{ {
/// <summary>
/// Gets or sets the red component.
/// </summary>
[FieldOffset(0)]
public byte R;
/// <summary>
/// Gets or sets the green component.
/// </summary>
[FieldOffset(1)]
public byte G;
/// <summary>
/// Gets or sets the blue component.
/// </summary>
[FieldOffset(2)]
public byte B;
/// <summary>
/// Gets or sets the alpha component.
/// </summary>
[FieldOffset(3)]
public byte A;
/// <summary> /// <summary>
/// The shift count for the red component /// The shift count for the red component
/// </summary> /// </summary>
@ -48,11 +74,6 @@ namespace ImageSharp
/// </summary> /// </summary>
private static readonly Vector4 Half = new Vector4(0.5F); private static readonly Vector4 Half = new Vector4(0.5F);
/// <summary>
/// The backing vector for SIMD support.
/// </summary>
private Vector4 backingVector;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Color"/> struct. /// Initializes a new instance of the <see cref="Color"/> struct.
/// </summary> /// </summary>
@ -63,7 +84,10 @@ namespace ImageSharp
public Color(byte r, byte g, byte b, byte a = 255) public Color(byte r, byte g, byte b, byte a = 255)
: this() : this()
{ {
this.backingVector = new Vector4(r, g, b, a) / MaxBytes; this.R = r;
this.G = g;
this.B = b;
this.A = a;
} }
/// <summary> /// <summary>
@ -76,7 +100,7 @@ namespace ImageSharp
public Color(float r, float g, float b, float a = 1) public Color(float r, float g, float b, float a = 1)
: this() : this()
{ {
this.backingVector = new Vector4(r, g, b, a); this = Pack(r, g, b, a);
} }
/// <summary> /// <summary>
@ -88,7 +112,7 @@ namespace ImageSharp
public Color(Vector3 vector) public Color(Vector3 vector)
: this() : this()
{ {
this.backingVector = new Vector4(vector, 1); this = Pack(ref vector);
} }
/// <summary> /// <summary>
@ -100,79 +124,7 @@ namespace ImageSharp
public Color(Vector4 vector) public Color(Vector4 vector)
: this() : this()
{ {
this.backingVector = vector; this = Pack(ref vector);
}
/// <summary>
/// Gets or sets the red component.
/// </summary>
public float R
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get
{
return this.backingVector.X;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
set
{
this.backingVector.X = value;
}
}
/// <summary>
/// Gets or sets the green component.
/// </summary>
public float G
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get
{
return this.backingVector.Y;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
set
{
this.backingVector.Y = value;
}
}
/// <summary>
/// Gets or sets the blue component.
/// </summary>
public float B
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get
{
return this.backingVector.Z;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
set
{
this.backingVector.Z = value;
}
}
/// <summary>
/// Gets or sets the alpha component.
/// </summary>
public float A
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get
{
return this.backingVector.W;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
set
{
this.backingVector.W = value;
}
} }
/// <summary> /// <summary>
@ -190,7 +142,10 @@ namespace ImageSharp
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator ==(Color left, Color right) public static bool operator ==(Color left, Color right)
{ {
return left.backingVector == right.backingVector; return left.R == right.R
&& left.G == right.G
&& left.B == right.B
&& left.A == right.A;
} }
/// <summary> /// <summary>
@ -204,7 +159,10 @@ namespace ImageSharp
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator !=(Color left, Color right) public static bool operator !=(Color left, Color right)
{ {
return left.backingVector != right.backingVector; return left.R != right.R
&& left.G != right.G
&& left.B != right.B
&& left.A != right.A;
} }
/// <summary> /// <summary>
@ -223,13 +181,16 @@ namespace ImageSharp
} }
/// <inheritdoc /> /// <inheritdoc />
public BulkPixelOperations<Color> CreateBulkOperations() => new Color.BulkOperations(); public BulkPixelOperations<Color> CreateBulkOperations() => new BulkOperations();
/// <inheritdoc/> /// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public void PackFromBytes(byte x, byte y, byte z, byte w) public void PackFromBytes(byte x, byte y, byte z, byte w)
{ {
this.backingVector = new Vector4(x, y, z, w) / MaxBytes; this.R = x;
this.G = y;
this.B = z;
this.A = w;
} }
/// <summary> /// <summary>
@ -238,9 +199,7 @@ namespace ImageSharp
/// <returns>A hexadecimal string representation of the value.</returns> /// <returns>A hexadecimal string representation of the value.</returns>
public string ToHex() public string ToHex()
{ {
Vector4 vector = this.backingVector * MaxBytes; uint hexOrder = Pack(this.A, this.B, this.G, this.R);
vector += Half;
uint hexOrder = (uint)((byte)vector.X << RedShift | (byte)vector.Y << GreenShift | (byte)vector.Z << BlueShift | (byte)vector.W << AlphaShift);
return hexOrder.ToString("X8"); return hexOrder.ToString("X8");
} }
@ -248,60 +207,52 @@ namespace ImageSharp
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToXyzBytes(byte[] bytes, int startIndex) public void ToXyzBytes(byte[] bytes, int startIndex)
{ {
Vector4 vector = Vector4.Clamp(this.backingVector, Vector4.Zero, Vector4.One) * MaxBytes; bytes[startIndex] = this.R;
vector += Half; bytes[startIndex + 1] = this.G;
bytes[startIndex] = (byte)vector.X; bytes[startIndex + 2] = this.B;
bytes[startIndex + 1] = (byte)vector.Y;
bytes[startIndex + 2] = (byte)vector.Z;
} }
/// <inheritdoc/> /// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToXyzwBytes(byte[] bytes, int startIndex) public void ToXyzwBytes(byte[] bytes, int startIndex)
{ {
Vector4 vector = Vector4.Clamp(this.backingVector, Vector4.Zero, Vector4.One) * MaxBytes; bytes[startIndex] = this.R;
vector += Half; bytes[startIndex + 1] = this.G;
bytes[startIndex] = (byte)vector.X; bytes[startIndex + 2] = this.B;
bytes[startIndex + 1] = (byte)vector.Y; bytes[startIndex + 3] = this.A;
bytes[startIndex + 2] = (byte)vector.Z;
bytes[startIndex + 2] = (byte)vector.W;
} }
/// <inheritdoc/> /// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToZyxBytes(byte[] bytes, int startIndex) public void ToZyxBytes(byte[] bytes, int startIndex)
{ {
Vector4 vector = Vector4.Clamp(this.backingVector, Vector4.Zero, Vector4.One) * MaxBytes; bytes[startIndex] = this.B;
vector += Half; bytes[startIndex + 1] = this.G;
bytes[startIndex] = (byte)vector.Z; bytes[startIndex + 2] = this.R;
bytes[startIndex + 1] = (byte)vector.Y;
bytes[startIndex + 2] = (byte)vector.X;
} }
/// <inheritdoc/> /// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToZyxwBytes(byte[] bytes, int startIndex) public void ToZyxwBytes(byte[] bytes, int startIndex)
{ {
Vector4 vector = Vector4.Clamp(this.backingVector, Vector4.Zero, Vector4.One) * MaxBytes; bytes[startIndex] = this.B;
vector += Half; bytes[startIndex + 1] = this.G;
bytes[startIndex] = (byte)vector.Z; bytes[startIndex + 2] = this.R;
bytes[startIndex + 1] = (byte)vector.Y; bytes[startIndex + 3] = this.A;
bytes[startIndex + 2] = (byte)vector.X;
bytes[startIndex + 2] = (byte)vector.W;
} }
/// <inheritdoc/> /// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public void PackFromVector4(Vector4 vector) public void PackFromVector4(Vector4 vector)
{ {
this.backingVector = vector; this = Pack(ref vector);
} }
/// <inheritdoc/> /// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public Vector4 ToVector4() public Vector4 ToVector4()
{ {
return this.backingVector; return new Vector4(this.R, this.G, this.B, this.A) / MaxBytes;
} }
/// <inheritdoc/> /// <inheritdoc/>
@ -314,7 +265,10 @@ namespace ImageSharp
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool Equals(Color other) public bool Equals(Color other)
{ {
return this.backingVector == other.backingVector; return this.R == other.R
&& this.G == other.G
&& this.B == other.B
&& this.A == other.A;
} }
/// <summary> /// <summary>
@ -329,7 +283,70 @@ namespace ImageSharp
/// <inheritdoc/> /// <inheritdoc/>
public override int GetHashCode() public override int GetHashCode()
{ {
return this.backingVector.GetHashCode(); unchecked
{
int hashCode = this.R.GetHashCode();
hashCode = (hashCode * 397) ^ this.G.GetHashCode();
hashCode = (hashCode * 397) ^ this.B.GetHashCode();
hashCode = (hashCode * 397) ^ this.A.GetHashCode();
return hashCode;
}
}
/// <summary>
/// Packs the four floats into a <see cref="uint"/>.
/// </summary>
/// <param name="x">The x-component</param>
/// <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="uint"/></returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static uint Pack(byte x, byte y, byte z, byte w)
{
return (uint)(x << RedShift | y << GreenShift | z << BlueShift | w << AlphaShift);
}
/// <summary>
/// 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>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static Color 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);
}
/// <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>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static Color Pack(ref Vector3 vector)
{
Vector4 value = new Vector4(vector, 1);
return Pack(ref value);
}
/// <summary>
/// Packs the four floats into a <see cref="uint"/>.
/// </summary>
/// <param name="x">The x-component</param>
/// <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>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static Color Pack(float x, float y, float z, float w)
{
Vector4 value = new Vector4(x, y, z, w);
return Pack(ref value);
} }
} }
} }

291
src/ImageSharp/Colors/Color32.BulkOperations.cs

@ -1,291 +0,0 @@
// <copyright file="Color32.BulkOperations.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.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
/// <summary>
/// Unpacked pixel 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>
/// <see cref="BulkPixelOperations{TColor}"/> implementation optimized for <see cref="Color32"/>.
/// </summary>
internal class BulkOperations : BulkPixelOperations<Color32>
{
/// <summary>
/// SIMD optimized bulk implementation of <see cref="IPixel.PackFromVector4(Vector4)"/>
/// that works only with `count` divisible by <see cref="Vector{UInt32}.Count"/>.
/// </summary>
/// <param name="sourceColors">The <see cref="BufferSpan{T}"/> to the source colors.</param>
/// <param name="destVectors">The <see cref="BufferSpan{T}"/> to the dstination vectors.</param>
/// <param name="count">The number of pixels to convert.</param>
/// <remarks>
/// Implementation adapted from:
/// <see>
/// <cref>http://stackoverflow.com/a/5362789</cref>
/// </see>
/// TODO: We can replace this implementation in the future using new Vector API-s:
/// <see>
/// <cref>https://github.com/dotnet/corefx/issues/15957</cref>
/// </see>
/// </remarks>
internal static unsafe void ToVector4SimdAligned(BufferSpan<Color32> sourceColors, BufferSpan<Vector4> destVectors, int count)
{
if (!Vector.IsHardwareAccelerated)
{
throw new InvalidOperationException(
"Color32.BulkOperations.ToVector4SimdAligned() should not be called when Vector.IsHardwareAccelerated == false!");
}
int vecSize = Vector<uint>.Count;
DebugGuard.IsTrue(
count % vecSize == 0,
nameof(count),
"Argument 'count' should divisible by Vector<uint>.Count!");
Vector<float> bVec = new Vector<float>(256.0f / 255.0f);
Vector<float> magicFloat = new Vector<float>(32768.0f);
Vector<uint> magicInt = new Vector<uint>(1191182336); // reinterpreded value of 32768.0f
Vector<uint> mask = new Vector<uint>(255);
int unpackedRawCount = count * 4;
ref uint src = ref Unsafe.As<Color32, uint>(ref sourceColors.DangerousGetPinnableReference());
using (Buffer<uint> tempBuf = new Buffer<uint>(
unpackedRawCount + Vector<uint>.Count))
{
uint[] temp = tempBuf.Array;
float[] fTemp = Unsafe.As<float[]>(temp);
ref UnpackedRGBA tempBase = ref Unsafe.As<uint, UnpackedRGBA>(ref tempBuf[0]);
for (int i = 0; i < count; i++)
{
uint sVal = Unsafe.Add(ref src, i);
ref UnpackedRGBA dst = ref Unsafe.Add(ref tempBase, i);
// This call is the bottleneck now:
dst.Load(sVal);
}
for (int i = 0; i < unpackedRawCount; i += vecSize)
{
Vector<uint> vi = new Vector<uint>(temp, i);
vi &= mask;
vi |= magicInt;
Vector<float> vf = Vector.AsVectorSingle(vi);
vf = (vf - magicFloat) * bVec;
vf.CopyTo(fTemp, i);
}
BufferSpan.Copy(tempBuf.Span.AsBytes(), destVectors.AsBytes(), unpackedRawCount * sizeof(uint));
}
}
/// <inheritdoc />
internal override void ToVector4(BufferSpan<Color32> sourceColors, BufferSpan<Vector4> destVectors, int count)
{
if (count < 256 || !Vector.IsHardwareAccelerated)
{
// Doesn't worth to bother with SIMD:
base.ToVector4(sourceColors, destVectors, count);
return;
}
int remainder = count % Vector<uint>.Count;
int alignedCount = count - remainder;
if (alignedCount > 0)
{
ToVector4SimdAligned(sourceColors, destVectors, alignedCount);
}
if (remainder > 0)
{
sourceColors = sourceColors.Slice(alignedCount);
destVectors = destVectors.Slice(alignedCount);
base.ToVector4(sourceColors, destVectors, remainder);
}
}
/// <inheritdoc />
internal override void PackFromXyzBytes(BufferSpan<byte> sourceBytes, BufferSpan<Color32> destColors, int count)
{
ref RGB24 sourceRef = ref Unsafe.As<byte, RGB24>(ref sourceBytes.DangerousGetPinnableReference());
ref Color32 destRef = ref destColors.DangerousGetPinnableReference();
for (int i = 0; i < count; i++)
{
ref RGB24 sp = ref Unsafe.Add(ref sourceRef, i);
ref Color32 dp = ref Unsafe.Add(ref destRef, i);
Unsafe.As<Color32, RGB24>(ref dp) = sp;
dp.A = 255;
}
}
/// <inheritdoc />
internal override void ToXyzBytes(BufferSpan<Color32> sourceColors, BufferSpan<byte> destBytes, int count)
{
ref Color32 sourceRef = ref sourceColors.DangerousGetPinnableReference();
ref RGB24 destRef = ref Unsafe.As<byte, RGB24>(ref destBytes.DangerousGetPinnableReference());
for (int i = 0; i < count; i++)
{
ref Color32 sp = ref Unsafe.Add(ref sourceRef, i);
ref RGB24 dp = ref Unsafe.Add(ref destRef, i);
dp = Unsafe.As<Color32, RGB24>(ref sp);
}
}
/// <inheritdoc />
internal override unsafe void PackFromXyzwBytes(BufferSpan<byte> sourceBytes, BufferSpan<Color32> destColors, int count)
{
BufferSpan.Copy(sourceBytes, destColors.AsBytes(), count * sizeof(Color32));
}
/// <inheritdoc />
internal override unsafe void ToXyzwBytes(BufferSpan<Color32> sourceColors, BufferSpan<byte> destBytes, int count)
{
BufferSpan.Copy(sourceColors.AsBytes(), destBytes, count * sizeof(Color32));
}
/// <inheritdoc />
internal override void PackFromZyxBytes(BufferSpan<byte> sourceBytes, BufferSpan<Color32> destColors, int count)
{
ref RGB24 sourceRef = ref Unsafe.As<byte, RGB24>(ref sourceBytes.DangerousGetPinnableReference());
ref Color32 destRef = ref destColors.DangerousGetPinnableReference();
for (int i = 0; i < count; i++)
{
ref RGB24 sp = ref Unsafe.Add(ref sourceRef, i);
ref Color32 dp = ref Unsafe.Add(ref destRef, i);
Unsafe.As<Color32, RGB24>(ref dp) = sp.ToZyx();
dp.A = 255;
}
}
/// <inheritdoc />
internal override void ToZyxBytes(BufferSpan<Color32> sourceColors, BufferSpan<byte> destBytes, int count)
{
ref Color32 sourceRef = ref sourceColors.DangerousGetPinnableReference();
ref RGB24 destRef = ref Unsafe.As<byte, RGB24>(ref destBytes.DangerousGetPinnableReference());
for (int i = 0; i < count; i++)
{
ref Color32 sp = ref Unsafe.Add(ref sourceRef, i);
ref RGB24 dp = ref Unsafe.Add(ref destRef, i);
dp = Unsafe.As<Color32, RGB24>(ref sp).ToZyx();
}
}
/// <inheritdoc />
internal override void PackFromZyxwBytes(BufferSpan<byte> sourceBytes, BufferSpan<Color32> destColors, int count)
{
ref RGBA32 sourceRef = ref Unsafe.As<byte, RGBA32>(ref sourceBytes.DangerousGetPinnableReference());
ref Color32 destRef = ref destColors.DangerousGetPinnableReference();
for (int i = 0; i < count; i++)
{
ref RGBA32 sp = ref Unsafe.Add(ref sourceRef, i);
ref Color32 dp = ref Unsafe.Add(ref destRef, i);
RGBA32 zyxw = sp.ToZyxw();
dp = Unsafe.As<RGBA32, Color32>(ref zyxw);
}
}
/// <inheritdoc />
internal override void ToZyxwBytes(BufferSpan<Color32> sourceColors, BufferSpan<byte> destBytes, int count)
{
ref Color32 sourceRef = ref sourceColors.DangerousGetPinnableReference();
ref RGBA32 destRef = ref Unsafe.As<byte, RGBA32>(ref destBytes.DangerousGetPinnableReference());
for (int i = 0; i < count; i++)
{
ref RGBA32 sp = ref Unsafe.As<Color32, RGBA32>(ref Unsafe.Add(ref sourceRef, i));
ref RGBA32 dp = ref Unsafe.Add(ref destRef, i);
dp = sp.ToZyxw();
}
}
/// <summary>
/// Helper struct to manipulate 3-byte RGB data.
/// </summary>
[StructLayout(LayoutKind.Sequential)]
private struct RGB24
{
private byte x;
private byte y;
private byte z;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public RGB24 ToZyx() => new RGB24 { x = this.z, y = this.y, z = this.x };
}
/// <summary>
/// Helper struct to manipulate 4-byte RGBA data.
/// </summary>
[StructLayout(LayoutKind.Sequential)]
private struct RGBA32
{
private byte x;
private byte y;
private byte z;
private byte w;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public RGBA32 ToZyxw() => new RGBA32 { x = this.z, y = this.y, z = this.x, w = this.w };
}
/// <summary>
/// Value type to store <see cref="Color32"/>-s unpacked into multiple <see cref="uint"/>-s.
/// </summary>
[StructLayout(LayoutKind.Sequential)]
private struct UnpackedRGBA
{
private uint r;
private uint g;
private uint b;
private uint a;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Load(uint p)
{
this.r = p;
this.g = p >> GreenShift;
this.b = p >> BlueShift;
this.a = p >> AlphaShift;
}
}
}
}
}

179
src/ImageSharp/Colors/Color32Constants.cs

@ -1,179 +0,0 @@
// <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

@ -1,728 +0,0 @@
// <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

@ -0,0 +1,179 @@
// <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();
}
}
}

27
src/ImageSharp/Colors/ColorVector.BulkOperations.cs

@ -0,0 +1,27 @@
namespace ImageSharp
{
using System.Numerics;
/// <summary>
/// Unpacked pixel type containing four 16-bit unsigned normalized values typically ranging from 0 to 1.
/// 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 ColorVector
{
/// <summary>
/// <see cref="BulkPixelOperations{TColor}"/> implementation optimized for <see cref="ColorVector"/>.
/// </summary>
internal class BulkOperations : BulkPixelOperations<ColorVector>
{
/// <inheritdoc />
internal override unsafe void ToVector4(BufferSpan<ColorVector> sourceColors, BufferSpan<Vector4> destVectors, int count)
{
BufferSpan.Copy(sourceColors.AsBytes(), destVectors.AsBytes(), count * sizeof(Vector4));
}
}
}
}

728
src/ImageSharp/Colors/ColorVector.Definitions.cs

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

295
src/ImageSharp/Colors/Color32.cs → src/ImageSharp/Colors/ColorVector.cs

@ -1,4 +1,4 @@
// <copyright file="Color.cs" company="James Jackson-South"> // <copyright file="ColorVector.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors. // Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright> // </copyright>
@ -7,43 +7,17 @@ namespace ImageSharp
{ {
using System.Numerics; using System.Numerics;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
/// <summary> /// <summary>
/// Unpacked pixel type containing four 8-bit unsigned normalized values ranging from 0 to 255. /// Unpacked pixel type containing four 16-bit unsigned normalized values typically ranging from 0 to 1.
/// The color components are stored in red, green, blue, and alpha order. /// The color components are stored in red, green, blue, and alpha order.
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// This struct is fully mutable. This is done (against the guidelines) for the sake of performance, /// 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. /// as it avoids the need to create new values for modification operations.
/// </remarks> /// </remarks>
[StructLayout(LayoutKind.Explicit)] public partial struct ColorVector : IPixel<ColorVector>
public partial struct Color32 : IPixel<Color32>
{ {
/// <summary>
/// Gets or sets the red component.
/// </summary>
[FieldOffset(0)]
public byte R;
/// <summary>
/// Gets or sets the green component.
/// </summary>
[FieldOffset(1)]
public byte G;
/// <summary>
/// Gets or sets the blue component.
/// </summary>
[FieldOffset(2)]
public byte B;
/// <summary>
/// Gets or sets the alpha component.
/// </summary>
[FieldOffset(3)]
public byte A;
/// <summary> /// <summary>
/// The shift count for the red component /// The shift count for the red component
/// </summary> /// </summary>
@ -75,122 +49,187 @@ namespace ImageSharp
private static readonly Vector4 Half = new Vector4(0.5F); private static readonly Vector4 Half = new Vector4(0.5F);
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Color32"/> struct. /// The backing vector for SIMD support.
/// </summary>
private Vector4 backingVector;
/// <summary>
/// Initializes a new instance of the <see cref="ColorVector"/> struct.
/// </summary> /// </summary>
/// <param name="r">The red component.</param> /// <param name="r">The red component.</param>
/// <param name="g">The green component.</param> /// <param name="g">The green component.</param>
/// <param name="b">The blue component.</param> /// <param name="b">The blue component.</param>
/// <param name="a">The alpha component.</param> /// <param name="a">The alpha component.</param>
public Color32(byte r, byte g, byte b, byte a = 255) public ColorVector(byte r, byte g, byte b, byte a = 255)
: this() : this()
{ {
this.R = r; this.backingVector = new Vector4(r, g, b, a) / MaxBytes;
this.G = g;
this.B = b;
this.A = a;
} }
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Color32"/> struct. /// Initializes a new instance of the <see cref="ColorVector"/> struct.
/// </summary> /// </summary>
/// <param name="r">The red component.</param> /// <param name="r">The red component.</param>
/// <param name="g">The green component.</param> /// <param name="g">The green component.</param>
/// <param name="b">The blue component.</param> /// <param name="b">The blue component.</param>
/// <param name="a">The alpha component.</param> /// <param name="a">The alpha component.</param>
public Color32(float r, float g, float b, float a = 1) public ColorVector(float r, float g, float b, float a = 1)
: this() : this()
{ {
this = Pack(r, g, b, a); this.backingVector = new Vector4(r, g, b, a);
} }
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Color32"/> struct. /// Initializes a new instance of the <see cref="ColorVector"/> struct.
/// </summary> /// </summary>
/// <param name="vector"> /// <param name="vector">
/// The vector containing the components for the packed vector. /// The vector containing the components for the packed vector.
/// </param> /// </param>
public Color32(Vector3 vector) public ColorVector(Vector3 vector)
: this() : this()
{ {
this = Pack(ref vector); this.backingVector = new Vector4(vector, 1);
} }
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Color32"/> struct. /// Initializes a new instance of the <see cref="ColorVector"/> struct.
/// </summary> /// </summary>
/// <param name="vector"> /// <param name="vector">
/// The vector containing the components for the packed vector. /// The vector containing the components for the packed vector.
/// </param> /// </param>
public Color32(Vector4 vector) public ColorVector(Vector4 vector)
: this() : this()
{ {
this = Pack(ref vector); this.backingVector = vector;
}
/// <summary>
/// Gets or sets the red component.
/// </summary>
public float R
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get
{
return this.backingVector.X;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
set
{
this.backingVector.X = value;
}
}
/// <summary>
/// Gets or sets the green component.
/// </summary>
public float G
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get
{
return this.backingVector.Y;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
set
{
this.backingVector.Y = value;
}
}
/// <summary>
/// Gets or sets the blue component.
/// </summary>
public float B
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get
{
return this.backingVector.Z;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
set
{
this.backingVector.Z = value;
}
}
/// <summary>
/// Gets or sets the alpha component.
/// </summary>
public float A
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get
{
return this.backingVector.W;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
set
{
this.backingVector.W = value;
}
} }
/// <summary> /// <summary>
/// Compares two <see cref="Color32"/> objects for equality. /// Compares two <see cref="ColorVector"/> objects for equality.
/// </summary> /// </summary>
/// <param name="left"> /// <param name="left">
/// The <see cref="Color32"/> on the left side of the operand. /// The <see cref="ColorVector"/> on the left side of the operand.
/// </param> /// </param>
/// <param name="right"> /// <param name="right">
/// The <see cref="Color32"/> on the right side of the operand. /// The <see cref="ColorVector"/> on the right side of the operand.
/// </param> /// </param>
/// <returns> /// <returns>
/// True if the <paramref name="left"/> parameter is equal to the <paramref name="right"/> parameter; otherwise, false. /// True if the <paramref name="left"/> parameter is equal to the <paramref name="right"/> parameter; otherwise, false.
/// </returns> /// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator ==(Color32 left, Color32 right) public static bool operator ==(ColorVector left, ColorVector right)
{ {
return left.R == right.R return left.backingVector == right.backingVector;
&& left.G == right.G
&& left.B == right.B
&& left.A == right.A;
} }
/// <summary> /// <summary>
/// Compares two <see cref="Color32"/> objects for equality. /// Compares two <see cref="ColorVector"/> objects for equality.
/// </summary> /// </summary>
/// <param name="left">The <see cref="Color32"/> on the left side of the operand.</param> /// <param name="left">The <see cref="ColorVector"/> on the left side of the operand.</param>
/// <param name="right">The <see cref="Color32"/> on the right side of the operand.</param> /// <param name="right">The <see cref="ColorVector"/> on the right side of the operand.</param>
/// <returns> /// <returns>
/// True if the <paramref name="left"/> parameter is not equal to the <paramref name="right"/> parameter; otherwise, false. /// True if the <paramref name="left"/> parameter is not equal to the <paramref name="right"/> parameter; otherwise, false.
/// </returns> /// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator !=(Color32 left, Color32 right) public static bool operator !=(ColorVector left, ColorVector right)
{ {
return left.R != right.R return left.backingVector != right.backingVector;
&& left.G != right.G
&& left.B != right.B
&& left.A != right.A;
} }
/// <summary> /// <summary>
/// Creates a new instance of the <see cref="Color32"/> struct. /// Creates a new instance of the <see cref="ColorVector"/> struct.
/// </summary> /// </summary>
/// <param name="hex"> /// <param name="hex">
/// The hexadecimal representation of the combined color components arranged /// The hexadecimal representation of the combined color components arranged
/// in rgb, rgba, rrggbb, or rrggbbaa format to match web syntax. /// in rgb, rgba, rrggbb, or rrggbbaa format to match web syntax.
/// </param> /// </param>
/// <returns> /// <returns>
/// The <see cref="Color32"/>. /// The <see cref="ColorVector"/>.
/// </returns> /// </returns>
public static Color32 FromHex(string hex) public static ColorVector FromHex(string hex)
{ {
return ColorBuilder<Color32>.FromHex(hex); return ColorBuilder<ColorVector>.FromHex(hex);
} }
/// <inheritdoc /> /// <inheritdoc />
public BulkPixelOperations<Color32> CreateBulkOperations() => new BulkOperations(); public BulkPixelOperations<ColorVector> CreateBulkOperations() => new ColorVector.BulkOperations();
/// <inheritdoc/> /// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public void PackFromBytes(byte x, byte y, byte z, byte w) public void PackFromBytes(byte x, byte y, byte z, byte w)
{ {
this.R = x; this.backingVector = new Vector4(x, y, z, w) / MaxBytes;
this.G = y;
this.B = z;
this.A = w;
} }
/// <summary> /// <summary>
@ -199,7 +238,9 @@ namespace ImageSharp
/// <returns>A hexadecimal string representation of the value.</returns> /// <returns>A hexadecimal string representation of the value.</returns>
public string ToHex() public string ToHex()
{ {
uint hexOrder = Pack(this.A, this.B, this.G, this.R); Vector4 vector = this.backingVector * MaxBytes;
vector += Half;
uint hexOrder = (uint)((byte)vector.X << RedShift | (byte)vector.Y << GreenShift | (byte)vector.Z << BlueShift | (byte)vector.W << AlphaShift);
return hexOrder.ToString("X8"); return hexOrder.ToString("X8");
} }
@ -207,68 +248,73 @@ namespace ImageSharp
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToXyzBytes(byte[] bytes, int startIndex) public void ToXyzBytes(byte[] bytes, int startIndex)
{ {
bytes[startIndex] = this.R; Vector4 vector = Vector4.Clamp(this.backingVector, Vector4.Zero, Vector4.One) * MaxBytes;
bytes[startIndex + 1] = this.G; vector += Half;
bytes[startIndex + 2] = this.B; bytes[startIndex] = (byte)vector.X;
bytes[startIndex + 1] = (byte)vector.Y;
bytes[startIndex + 2] = (byte)vector.Z;
} }
/// <inheritdoc/> /// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToXyzwBytes(byte[] bytes, int startIndex) public void ToXyzwBytes(byte[] bytes, int startIndex)
{ {
bytes[startIndex] = this.R; Vector4 vector = Vector4.Clamp(this.backingVector, Vector4.Zero, Vector4.One) * MaxBytes;
bytes[startIndex + 1] = this.G; vector += Half;
bytes[startIndex + 2] = this.B; bytes[startIndex] = (byte)vector.X;
bytes[startIndex + 3] = this.A; bytes[startIndex + 1] = (byte)vector.Y;
bytes[startIndex + 2] = (byte)vector.Z;
bytes[startIndex + 2] = (byte)vector.W;
} }
/// <inheritdoc/> /// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToZyxBytes(byte[] bytes, int startIndex) public void ToZyxBytes(byte[] bytes, int startIndex)
{ {
bytes[startIndex] = this.B; Vector4 vector = Vector4.Clamp(this.backingVector, Vector4.Zero, Vector4.One) * MaxBytes;
bytes[startIndex + 1] = this.G; vector += Half;
bytes[startIndex + 2] = this.R; bytes[startIndex] = (byte)vector.Z;
bytes[startIndex + 1] = (byte)vector.Y;
bytes[startIndex + 2] = (byte)vector.X;
} }
/// <inheritdoc/> /// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToZyxwBytes(byte[] bytes, int startIndex) public void ToZyxwBytes(byte[] bytes, int startIndex)
{ {
bytes[startIndex] = this.B; Vector4 vector = Vector4.Clamp(this.backingVector, Vector4.Zero, Vector4.One) * MaxBytes;
bytes[startIndex + 1] = this.G; vector += Half;
bytes[startIndex + 2] = this.R; bytes[startIndex] = (byte)vector.Z;
bytes[startIndex + 3] = this.A; bytes[startIndex + 1] = (byte)vector.Y;
bytes[startIndex + 2] = (byte)vector.X;
bytes[startIndex + 2] = (byte)vector.W;
} }
/// <inheritdoc/> /// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public void PackFromVector4(Vector4 vector) public void PackFromVector4(Vector4 vector)
{ {
this = Pack(ref vector); this.backingVector = vector;
} }
/// <inheritdoc/> /// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public Vector4 ToVector4() public Vector4 ToVector4()
{ {
return new Vector4(this.R, this.G, this.B, this.A) / MaxBytes; return this.backingVector;
} }
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
return (obj is Color32) && this.Equals((Color32)obj); return (obj is ColorVector) && this.Equals((ColorVector)obj);
} }
/// <inheritdoc/> /// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool Equals(Color32 other) public bool Equals(ColorVector other)
{ {
return this.R == other.R return this.backingVector == other.backingVector;
&& this.G == other.G
&& this.B == other.B
&& this.A == other.A;
} }
/// <summary> /// <summary>
@ -283,70 +329,7 @@ namespace ImageSharp
/// <inheritdoc/> /// <inheritdoc/>
public override int GetHashCode() public override int GetHashCode()
{ {
unchecked return this.backingVector.GetHashCode();
{
int hashCode = this.R.GetHashCode();
hashCode = (hashCode * 397) ^ this.G.GetHashCode();
hashCode = (hashCode * 397) ^ this.B.GetHashCode();
hashCode = (hashCode * 397) ^ this.A.GetHashCode();
return hashCode;
}
}
/// <summary>
/// Packs the four floats into a <see cref="uint"/>.
/// </summary>
/// <param name="x">The x-component</param>
/// <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="uint"/></returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static uint Pack(byte x, byte y, byte z, byte w)
{
return (uint)(x << RedShift | y << GreenShift | z << BlueShift | w << AlphaShift);
}
/// <summary>
/// Packs a <see cref="Vector4"/> into a uint.
/// </summary>
/// <param name="vector">The vector containing the values to pack.</param>
/// <returns>The <see cref="Color32"/></returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static Color32 Pack(ref Vector4 vector)
{
vector *= MaxBytes;
vector += Half;
vector = Vector4.Clamp(vector, Vector4.Zero, MaxBytes);
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="Color32"/></returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static Color32 Pack(ref Vector3 vector)
{
Vector4 value = new Vector4(vector, 1);
return Pack(ref value);
}
/// <summary>
/// Packs the four floats into a <see cref="uint"/>.
/// </summary>
/// <param name="x">The x-component</param>
/// <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="Color32"/></returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static Color32 Pack(float x, float y, float z, float w)
{
Vector4 value = new Vector4(x, y, z, w);
return Pack(ref value);
} }
} }
} }

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

8
src/ImageSharp/Colors/ComponentOrder.cs

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

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

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

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

@ -79,16 +79,16 @@ namespace ImageSharp.Colors.Spaces
public bool IsEmpty => this.Equals(Empty); public bool IsEmpty => this.Equals(Empty);
/// <summary> /// <summary>
/// Allows the implicit conversion of an instance of <see cref="Color32"/> to a /// Allows the implicit conversion of an instance of <see cref="Color"/> to a
/// <see cref="Bgra32"/>. /// <see cref="Bgra32"/>.
/// </summary> /// </summary>
/// <param name="color"> /// <param name="color">
/// The instance of <see cref="Color32"/> to convert. /// The instance of <see cref="Color"/> to convert.
/// </param> /// </param>
/// <returns> /// <returns>
/// An instance of <see cref="Bgra32"/>. /// An instance of <see cref="Bgra32"/>.
/// </returns> /// </returns>
public static implicit operator Bgra32(Color32 color) public static implicit operator Bgra32(Color color)
{ {
return new Bgra32(color.B, color.G, color.R, color.A); 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); public bool IsEmpty => this.Equals(Empty);
/// <summary> /// <summary>
/// Allows the implicit conversion of an instance of <see cref="Color32"/> to a /// Allows the implicit conversion of an instance of <see cref="Color"/> to a
/// <see cref="CieLab"/>. /// <see cref="CieLab"/>.
/// </summary> /// </summary>
/// <param name="color"> /// <param name="color">
/// The instance of <see cref="Color32"/> to convert. /// The instance of <see cref="Color"/> to convert.
/// </param> /// </param>
/// <returns> /// <returns>
/// An instance of <see cref="CieLab"/>. /// An instance of <see cref="CieLab"/>.
/// </returns> /// </returns>
public static implicit operator CieLab(Color32 color) public static implicit operator CieLab(Color color)
{ {
// First convert to CIE XYZ // First convert to CIE XYZ
Vector4 vector = color.ToVector4().Expand(); 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); public bool IsEmpty => this.Equals(Empty);
/// <summary> /// <summary>
/// Allows the implicit conversion of an instance of <see cref="Color32"/> to a /// Allows the implicit conversion of an instance of <see cref="Color"/> to a
/// <see cref="CieXyz"/>. /// <see cref="CieXyz"/>.
/// </summary> /// </summary>
/// <param name="color"> /// <param name="color">
/// The instance of <see cref="Color32"/> to convert. /// The instance of <see cref="Color"/> to convert.
/// </param> /// </param>
/// <returns> /// <returns>
/// An instance of <see cref="CieXyz"/>. /// An instance of <see cref="CieXyz"/>.
/// </returns> /// </returns>
public static implicit operator CieXyz(Color32 color) public static implicit operator CieXyz(Color color)
{ {
Vector4 vector = color.ToVector4().Expand(); 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); public bool IsEmpty => this.Equals(Empty);
/// <summary> /// <summary>
/// Allows the implicit conversion of an instance of <see cref="Color32"/> to a /// Allows the implicit conversion of an instance of <see cref="Color"/> to a
/// <see cref="Cmyk"/>. /// <see cref="Cmyk"/>.
/// </summary> /// </summary>
/// <param name="color"> /// <param name="color">
@ -87,7 +87,7 @@ namespace ImageSharp.Colors.Spaces
/// <returns> /// <returns>
/// An instance of <see cref="Cmyk"/>. /// An instance of <see cref="Cmyk"/>.
/// </returns> /// </returns>
public static implicit operator Cmyk(Color32 color) public static implicit operator Cmyk(Color color)
{ {
float c = 1f - (color.R / 255F); float c = 1f - (color.R / 255F);
float m = 1f - (color.G / 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); public bool IsEmpty => this.Equals(Empty);
/// <summary> /// <summary>
/// Allows the implicit conversion of an instance of <see cref="Color32"/> to a /// Allows the implicit conversion of an instance of <see cref="Color"/> to a
/// <see cref="Hsl"/>. /// <see cref="Hsl"/>.
/// </summary> /// </summary>
/// <param name="color">The instance of <see cref="Color32"/> to convert.</param> /// <param name="color">The instance of <see cref="Color"/> to convert.</param>
/// <returns> /// <returns>
/// An instance of <see cref="Hsl"/>. /// An instance of <see cref="Hsl"/>.
/// </returns> /// </returns>
public static implicit operator Hsl(Color32 color) public static implicit operator Hsl(Color color)
{ {
float r = color.R / 255F; float r = color.R / 255F;
float g = color.G / 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); public bool IsEmpty => this.Equals(Empty);
/// <summary> /// <summary>
/// Allows the implicit conversion of an instance of <see cref="Color32"/> to a /// Allows the implicit conversion of an instance of <see cref="Color"/> to a
/// <see cref="Hsv"/>. /// <see cref="Hsv"/>.
/// </summary> /// </summary>
/// <param name="color">The instance of <see cref="Color32"/> to convert.</param> /// <param name="color">The instance of <see cref="Color"/> to convert.</param>
/// <returns> /// <returns>
/// An instance of <see cref="Hsv"/>. /// An instance of <see cref="Hsv"/>.
/// </returns> /// </returns>
public static implicit operator Hsv(Color32 color) public static implicit operator Hsv(Color color)
{ {
float r = color.R / 255F; float r = color.R / 255F;
float g = color.G / 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); public bool IsEmpty => this.Equals(Empty);
/// <summary> /// <summary>
/// Allows the implicit conversion of an instance of <see cref="Color32"/> to a /// Allows the implicit conversion of an instance of <see cref="Color"/> to a
/// <see cref="YCbCr"/>. /// <see cref="YCbCr"/>.
/// </summary> /// </summary>
/// <param name="color"> /// <param name="color">
/// The instance of <see cref="Color32"/> to convert. /// The instance of <see cref="Color"/> to convert.
/// </param> /// </param>
/// <returns> /// <returns>
/// An instance of <see cref="YCbCr"/>. /// An instance of <see cref="YCbCr"/>.
/// </returns> /// </returns>
public static implicit operator YCbCr(Color32 color) public static implicit operator YCbCr(Color color)
{ {
byte r = color.R; byte r = color.R;
byte g = color.G; 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://www.4p8.com/eric.brasseur/gamma.html#formulas"/>
/// <see href="http://entropymine.com/imageworsener/srgbformula/"/> /// <see href="http://entropymine.com/imageworsener/srgbformula/"/>
/// </summary> /// </summary>
/// <param name="gamma">The <see cref="Color32"/> whose signal to expand.</param> /// <param name="gamma">The <see cref="Color"/> whose signal to expand.</param>
/// <returns>The <see cref="Vector4"/>.</returns> /// <returns>The <see cref="Vector4"/>.</returns>
public static Vector4 Expand(this Vector4 gamma) 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. /// The configuration providing initialization code which allows extending the library.
/// </param> /// </param>
/// <returns> /// <returns>
/// A new <see cref="Image{TColor}"/> unless <typeparamref name="TColor"/> is <see cref="Color32"/> in which case it returns <see cref="Image" /> /// A new <see cref="Image{TColor}"/> unless <typeparamref name="TColor"/> is <see cref="Color"/> in which case it returns <see cref="Image" />
/// </returns> /// </returns>
internal static Image<TColor> Create<TColor>(int width, int height, ImageMetaData metadata, Configuration configuration) internal static Image<TColor> Create<TColor>(int width, int height, ImageMetaData metadata, Configuration configuration)
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>
{ {
if (typeof(TColor) == typeof(Color32)) if (typeof(TColor) == typeof(Color))
{ {
return new Image(width, height, metadata, configuration) as Image<TColor>; 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. /// The configuration providing initialization code which allows extending the library.
/// </param> /// </param>
/// <returns> /// <returns>
/// A new <see cref="Image{TColor}"/> unless <typeparamref name="TColor"/> is <see cref="Color32"/> in which case it returns <see cref="Image" /> /// A new <see cref="Image{TColor}"/> unless <typeparamref name="TColor"/> is <see cref="Color"/> in which case it returns <see cref="Image" />
/// </returns> /// </returns>
internal static Image<TColor> Create<TColor>(int width, int height, Configuration configuration) internal static Image<TColor> Create<TColor>(int width, int height, Configuration configuration)
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>

2
src/ImageSharp/Image.FromFile.cs

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

4
src/ImageSharp/Image.FromStream.cs

@ -83,7 +83,7 @@ namespace ImageSharp
/// <returns>The image</returns> /// <returns>The image</returns>
public static Image Load(Configuration config, Stream stream, IDecoderOptions options) public static Image Load(Configuration config, Stream stream, IDecoderOptions options)
{ {
Image<Color32> image = Load<Color32>(config, stream, options); Image<Color> image = Load<Color>(config, stream, options);
return image as Image ?? new Image(image); return image as Image ?? new Image(image);
} }
@ -100,7 +100,7 @@ namespace ImageSharp
/// <returns>The image</returns> /// <returns>The image</returns>
public static Image Load(Stream stream, IImageDecoder decoder, IDecoderOptions options) public static Image Load(Stream stream, IImageDecoder decoder, IDecoderOptions options)
{ {
Image<Color32> image = new Image(Load<Color32>(stream, decoder, options)); Image<Color> image = new Image(Load<Color>(stream, decoder, options));
return image as Image ?? new Image(image); 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. /// packed into a single unsigned integer value.
/// </summary> /// </summary>
[DebuggerDisplay("Image: {Width}x{Height}")] [DebuggerDisplay("Image: {Width}x{Height}")]
public sealed partial class Image : Image<Color32> public sealed partial class Image : Image<Color>
{ {
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Image"/> class /// Initializes a new instance of the <see cref="Image"/> class
@ -49,7 +49,7 @@ namespace ImageSharp
/// </summary> /// </summary>
/// <param name="other">The other image, where the clone should be made from.</param> /// <param name="other">The other image, where the clone should be made from.</param>
/// <exception cref="System.ArgumentNullException"><paramref name="other"/> is null.</exception> /// <exception cref="System.ArgumentNullException"><paramref name="other"/> is null.</exception>
public Image(Image<Color32> other) public Image(Image<Color> other)
: base(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="matrix">The matrix.</param>
/// <param name="compand">Whether to compand the color during processing.</param> /// <param name="compand">Whether to compand the color during processing.</param>
/// <returns> /// <returns>
/// The <see cref="Color32"/>. /// The <see cref="Color"/>.
/// </returns> /// </returns>
private TColor ApplyMatrix(TColor color, Matrix4x4 matrix, bool compand) 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) if (palette == null)
{ {
Color32[] constants = Color32Constants.WebSafeColors; Color[] constants = ColorConstants.WebSafeColors;
TColor[] safe = new TColor[constants.Length + 1]; TColor[] safe = new TColor[constants.Length + 1];
for (int i = 0; i < constants.Length; i++) for (int i = 0; i < constants.Length; i++)

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

@ -14,7 +14,7 @@
/// </summary> /// </summary>
public unsafe class PackFromVector4ReferenceVsPointer public unsafe class PackFromVector4ReferenceVsPointer
{ {
private Buffer<ImageSharp.Color32> destination; private Buffer<ImageSharp.Color> destination;
private Buffer<Vector4> source; private Buffer<Vector4> source;
@ -24,7 +24,7 @@
[Setup] [Setup]
public void Setup() public void Setup()
{ {
this.destination = new Buffer<ImageSharp.Color32>(this.Count); this.destination = new Buffer<ImageSharp.Color>(this.Count);
this.source = new Buffer<Vector4>(this.Count * 4); this.source = new Buffer<Vector4>(this.Count * 4);
this.source.Pin(); this.source.Pin();
this.destination.Pin(); this.destination.Pin();
@ -43,12 +43,12 @@
Vector4* sp = (Vector4*)this.source.Pin(); Vector4* sp = (Vector4*)this.source.Pin();
byte* dp = (byte*)this.destination.Pin(); byte* dp = (byte*)this.destination.Pin();
int count = this.Count; int count = this.Count;
int size = sizeof(ImageSharp.Color32); int size = sizeof(ImageSharp.Color);
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
Vector4 v = Unsafe.Read<Vector4>(sp); Vector4 v = Unsafe.Read<Vector4>(sp);
ImageSharp.Color32 c = default(ImageSharp.Color32); ImageSharp.Color c = default(ImageSharp.Color);
c.PackFromVector4(v); c.PackFromVector4(v);
Unsafe.Write(dp, c); Unsafe.Write(dp, c);
@ -61,7 +61,7 @@
public void PackUsingReferences() public void PackUsingReferences()
{ {
ref Vector4 sp = ref this.source.Array[0]; ref Vector4 sp = ref this.source.Array[0];
ref ImageSharp.Color32 dp = ref this.destination.Array[0]; ref ImageSharp.Color dp = ref this.destination.Array[0];
int count = this.Count; int count = this.Count;
for (int i = 0; i < count; i++) 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 BenchmarkDotNet.Attributes;
using Color32 = ImageSharp.Color32; using Color = ImageSharp.Color;
public abstract class PackFromXyzw<TColor> public abstract class PackFromXyzw<TColor>
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>
@ -57,7 +57,7 @@ namespace ImageSharp.Benchmarks.Color.Bulk
} }
} }
public class PackFromXyzw_Color : PackFromXyzw<Color32> public class PackFromXyzw_Color : PackFromXyzw<Color>
{ {
} }
} }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

2
tests/ImageSharp.Benchmarks/Samplers/Resize.cs

@ -11,7 +11,7 @@ namespace ImageSharp.Benchmarks
using BenchmarkDotNet.Attributes; using BenchmarkDotNet.Attributes;
using CoreSize = ImageSharp.Size; using CoreSize = ImageSharp.Size;
using CoreImage = ImageSharp.Image; using CoreImage = ImageSharp.Image;
using CoreVectorImage = ImageSharp.Image<ImageSharp.Color>; using CoreVectorImage = ImageSharp.Image<ImageSharp.ColorVector>;
public class Resize : BenchmarkBase public class Resize : BenchmarkBase
{ {

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -18,7 +18,7 @@ namespace ImageSharp.Tests
[Fact] [Fact]
public void PixelDataPoolRentsMinimumSize() public void PixelDataPoolRentsMinimumSize()
{ {
Color32[] pixels = PixelDataPool<Color32>.Rent(1024); Color[] pixels = PixelDataPool<Color>.Rent(1024);
Assert.True(pixels.Length >= 1024); Assert.True(pixels.Length >= 1024);
} }
@ -26,9 +26,9 @@ namespace ImageSharp.Tests
[Fact] [Fact]
public void PixelDataPoolDoesNotThrowWhenReturningNonPooled() public void PixelDataPoolDoesNotThrowWhenReturningNonPooled()
{ {
Color32[] pixels = new Color32[1024]; Color[] pixels = new Color[1024];
PixelDataPool<Color32>.Return(pixels); PixelDataPool<Color>.Return(pixels);
Assert.True(pixels.Length >= 1024); Assert.True(pixels.Length >= 1024);
} }
@ -39,7 +39,7 @@ namespace ImageSharp.Tests
public void CalculateMaxArrayLength(bool isRawData) public void CalculateMaxArrayLength(bool isRawData)
{ {
int max = isRawData ? PixelDataPool<int>.CalculateMaxArrayLength() int max = isRawData ? PixelDataPool<int>.CalculateMaxArrayLength()
: PixelDataPool<Color32>.CalculateMaxArrayLength(); : PixelDataPool<Color>.CalculateMaxArrayLength();
Assert.Equal(max < int.MaxValue, !isRawData); 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")) using (FileStream output = File.OpenWrite($"{path}/Simple.png"))
{ {
image.BackgroundColor(Color32.Blue) image.BackgroundColor(Color.Blue)
.DrawBeziers(Color32.HotPink, 5, .DrawBeziers(Color.HotPink, 5,
new[] { new[] {
new Vector2(10, 400), new Vector2(10, 400),
new Vector2(30, 10), new Vector2(30, 10),
@ -34,21 +34,21 @@ namespace ImageSharp.Tests.Drawing
.Save(output); .Save(output);
} }
using (PixelAccessor<Color32> sourcePixels = image.Lock()) using (PixelAccessor<Color> sourcePixels = image.Lock())
{ {
//top of curve //top of curve
Assert.Equal(Color32.HotPink, sourcePixels[138, 115]); Assert.Equal(Color.HotPink, sourcePixels[138, 115]);
//start points //start points
Assert.Equal(Color32.HotPink, sourcePixels[10, 400]); Assert.Equal(Color.HotPink, sourcePixels[10, 400]);
Assert.Equal(Color32.HotPink, sourcePixels[300, 400]); Assert.Equal(Color.HotPink, sourcePixels[300, 400]);
//curve points should not be never be set //curve points should not be never be set
Assert.Equal(Color32.Blue, sourcePixels[30, 10]); Assert.Equal(Color.Blue, sourcePixels[30, 10]);
Assert.Equal(Color32.Blue, sourcePixels[240, 30]); Assert.Equal(Color.Blue, sourcePixels[240, 30]);
// inside shape should be empty // inside shape should be empty
Assert.Equal(Color32.Blue, sourcePixels[200, 250]); Assert.Equal(Color.Blue, sourcePixels[200, 250]);
} }
} }
} }
@ -59,13 +59,13 @@ namespace ImageSharp.Tests.Drawing
{ {
string path = this.CreateOutputDirectory("Drawing", "BezierLine"); string path = this.CreateOutputDirectory("Drawing", "BezierLine");
Color32 color = new Color32(Color32.HotPink.R, Color32.HotPink.G, Color32.HotPink.B, 150); Color color = new Color(Color.HotPink.R, Color.HotPink.G, Color.HotPink.B, 150);
using (Image image = new Image(500, 500)) using (Image image = new Image(500, 500))
{ {
using (FileStream output = File.OpenWrite($"{path}/Opacity.png")) using (FileStream output = File.OpenWrite($"{path}/Opacity.png"))
{ {
image.BackgroundColor(Color32.Blue) image.BackgroundColor(Color.Blue)
.DrawBeziers(color, .DrawBeziers(color,
10, 10,
new[] { new[] {
@ -78,9 +78,9 @@ namespace ImageSharp.Tests.Drawing
} }
//shift background color towards forground color by the opacity amount //shift background color towards forground color by the opacity amount
Color32 mergedColor = new Color32(Vector4.Lerp(Color32.Blue.ToVector4(), Color32.HotPink.ToVector4(), 150f / 255f)); Color mergedColor = new Color(Vector4.Lerp(Color.Blue.ToVector4(), Color.HotPink.ToVector4(), 150f / 255f));
using (PixelAccessor<Color32> sourcePixels = image.Lock()) using (PixelAccessor<Color> sourcePixels = image.Lock())
{ {
//top of curve //top of curve
Assert.Equal(mergedColor, sourcePixels[138, 115]); Assert.Equal(mergedColor, sourcePixels[138, 115]);
@ -90,11 +90,11 @@ namespace ImageSharp.Tests.Drawing
Assert.Equal(mergedColor, sourcePixels[300, 400]); Assert.Equal(mergedColor, sourcePixels[300, 400]);
//curve points should not be never be set //curve points should not be never be set
Assert.Equal(Color32.Blue, sourcePixels[30, 10]); Assert.Equal(Color.Blue, sourcePixels[30, 10]);
Assert.Equal(Color32.Blue, sourcePixels[240, 30]); Assert.Equal(Color.Blue, sourcePixels[240, 30]);
// inside shape should be empty // inside shape should be empty
Assert.Equal(Color32.Blue, sourcePixels[200, 250]); Assert.Equal(Color.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")) using (FileStream output = File.OpenWrite($"{path}/Simple.png"))
{ {
image image
.BackgroundColor(Color32.Blue) .BackgroundColor(Color.Blue)
.Draw(Color32.HotPink, 5, p) .Draw(Color.HotPink, 5, p)
.Save(output); .Save(output);
} }
using (PixelAccessor<Color32> sourcePixels = image.Lock()) using (PixelAccessor<Color> sourcePixels = image.Lock())
{ {
Assert.Equal(Color32.HotPink, sourcePixels[9, 9]); Assert.Equal(Color.HotPink, sourcePixels[9, 9]);
Assert.Equal(Color32.HotPink, sourcePixels[199, 149]); Assert.Equal(Color.HotPink, sourcePixels[199, 149]);
Assert.Equal(Color32.Blue, sourcePixels[50, 50]); Assert.Equal(Color.Blue, sourcePixels[50, 50]);
} }
} }
} }
@ -60,7 +60,7 @@ namespace ImageSharp.Tests.Drawing
{ {
string path = this.CreateOutputDirectory("Drawing", "Path"); string path = this.CreateOutputDirectory("Drawing", "Path");
Color32 color = new Color32(Color32.HotPink.R, Color32.HotPink.G, Color32.HotPink.B, 150); Color color = new Color(Color.HotPink.R, Color.HotPink.G, Color.HotPink.B, 150);
LinearLineSegment linerSegemnt = new LinearLineSegment( LinearLineSegment linerSegemnt = new LinearLineSegment(
@ -81,21 +81,21 @@ namespace ImageSharp.Tests.Drawing
using (FileStream output = File.OpenWrite($"{path}/Opacity.png")) using (FileStream output = File.OpenWrite($"{path}/Opacity.png"))
{ {
image image
.BackgroundColor(Color32.Blue) .BackgroundColor(Color.Blue)
.Draw(color, 10, p) .Draw(color, 10, p)
.Save(output); .Save(output);
} }
//shift background color towards forground color by the opacity amount //shift background color towards forground color by the opacity amount
Color32 mergedColor = new Color32(Vector4.Lerp(Color32.Blue.ToVector4(), Color32.HotPink.ToVector4(), 150f / 255f)); Color mergedColor = new Color(Vector4.Lerp(Color.Blue.ToVector4(), Color.HotPink.ToVector4(), 150f / 255f));
using (PixelAccessor<Color32> sourcePixels = image.Lock()) using (PixelAccessor<Color> sourcePixels = image.Lock())
{ {
Assert.Equal(mergedColor, sourcePixels[9, 9]); Assert.Equal(mergedColor, sourcePixels[9, 9]);
Assert.Equal(mergedColor, sourcePixels[199, 149]); Assert.Equal(mergedColor, sourcePixels[199, 149]);
Assert.Equal(Color32.Blue, sourcePixels[50, 50]); Assert.Equal(Color.Blue, sourcePixels[50, 50]);
} }
} }
} }

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

@ -15,7 +15,7 @@ namespace ImageSharp.Tests.Drawing
public class FillPatternBrushTests : FileTestBase public class FillPatternBrushTests : FileTestBase
{ {
private void Test(string name, Color32 background, IBrush<Color32> brush, Color32[,] expectedPattern) private void Test(string name, Color background, IBrush<Color> brush, Color[,] expectedPattern)
{ {
string path = this.CreateOutputDirectory("Fill", "PatternBrush"); string path = this.CreateOutputDirectory("Fill", "PatternBrush");
using (Image image = new Image(20, 20)) using (Image image = new Image(20, 20))
@ -29,11 +29,11 @@ namespace ImageSharp.Tests.Drawing
image.Save(output); image.Save(output);
} }
using (PixelAccessor<Color32> sourcePixels = image.Lock()) using (PixelAccessor<Color> sourcePixels = image.Lock())
{ {
// lets pick random spots to start checking // lets pick random spots to start checking
Random r = new Random(); Random r = new Random();
Fast2DArray<Color32> expectedPatternFast = new Fast2DArray<Color32>(expectedPattern); Fast2DArray<Color> expectedPatternFast = new Fast2DArray<Color>(expectedPattern);
int xStride = expectedPatternFast.Width; int xStride = expectedPatternFast.Width;
int yStride = expectedPatternFast.Height; int yStride = expectedPatternFast.Height;
int offsetX = r.Next(image.Width / xStride) * xStride; int offsetX = r.Next(image.Width / xStride) * xStride;
@ -44,8 +44,8 @@ namespace ImageSharp.Tests.Drawing
{ {
int actualX = x + offsetX; int actualX = x + offsetX;
int actualY = y + offsetY; int actualY = y + offsetY;
Color32 expected = expectedPatternFast[y, x]; // inverted pattern Color expected = expectedPatternFast[y, x]; // inverted pattern
Color32 actual = sourcePixels[actualX, actualY]; Color actual = sourcePixels[actualX, actualY];
if (expected != actual) if (expected != actual)
{ {
Assert.True(false, $"Expected {expected} but found {actual} at ({actualX},{actualY})"); Assert.True(false, $"Expected {expected} but found {actual} at ({actualX},{actualY})");
@ -63,73 +63,73 @@ namespace ImageSharp.Tests.Drawing
[Fact] [Fact]
public void ImageShouldBeFloodFilledWithPercent10() public void ImageShouldBeFloodFilledWithPercent10()
{ {
this.Test("Percent10", Color32.Blue, Brushes.Percent10(Color32.HotPink, Color32.LimeGreen), this.Test("Percent10", Color.Blue, Brushes.Percent10(Color.HotPink, Color.LimeGreen),
new[,] new[,]
{ {
{ Color32.HotPink , Color32.LimeGreen, Color32.LimeGreen, Color32.LimeGreen}, { Color.HotPink , Color.LimeGreen, Color.LimeGreen, Color.LimeGreen},
{ Color32.LimeGreen, Color32.LimeGreen, Color32.LimeGreen, Color32.LimeGreen}, { Color.LimeGreen, Color.LimeGreen, Color.LimeGreen, Color.LimeGreen},
{ Color32.LimeGreen, Color32.LimeGreen, Color32.HotPink , Color32.LimeGreen}, { Color.LimeGreen, Color.LimeGreen, Color.HotPink , Color.LimeGreen},
{ Color32.LimeGreen, Color32.LimeGreen, Color32.LimeGreen, Color32.LimeGreen} { Color.LimeGreen, Color.LimeGreen, Color.LimeGreen, Color.LimeGreen}
}); });
} }
[Fact] [Fact]
public void ImageShouldBeFloodFilledWithPercent10Transparent() public void ImageShouldBeFloodFilledWithPercent10Transparent()
{ {
Test("Percent10_Transparent", Color32.Blue, Brushes.Percent10(Color32.HotPink), Test("Percent10_Transparent", Color.Blue, Brushes.Percent10(Color.HotPink),
new Color32[,] { new Color[,] {
{ Color32.HotPink , Color32.Blue, Color32.Blue, Color32.Blue}, { Color.HotPink , Color.Blue, Color.Blue, Color.Blue},
{ Color32.Blue, Color32.Blue, Color32.Blue, Color32.Blue}, { Color.Blue, Color.Blue, Color.Blue, Color.Blue},
{ Color32.Blue, Color32.Blue, Color32.HotPink , Color32.Blue}, { Color.Blue, Color.Blue, Color.HotPink , Color.Blue},
{ Color32.Blue, Color32.Blue, Color32.Blue, Color32.Blue} { Color.Blue, Color.Blue, Color.Blue, Color.Blue}
}); });
} }
[Fact] [Fact]
public void ImageShouldBeFloodFilledWithPercent20() public void ImageShouldBeFloodFilledWithPercent20()
{ {
Test("Percent20", Color32.Blue, Brushes.Percent20(Color32.HotPink, Color32.LimeGreen), Test("Percent20", Color.Blue, Brushes.Percent20(Color.HotPink, Color.LimeGreen),
new Color32[,] { new Color[,] {
{ Color32.HotPink , Color32.LimeGreen, Color32.LimeGreen, Color32.LimeGreen}, { Color.HotPink , Color.LimeGreen, Color.LimeGreen, Color.LimeGreen},
{ Color32.LimeGreen, Color32.LimeGreen, Color32.HotPink , Color32.LimeGreen}, { Color.LimeGreen, Color.LimeGreen, Color.HotPink , Color.LimeGreen},
{ Color32.HotPink , Color32.LimeGreen, Color32.LimeGreen, Color32.LimeGreen}, { Color.HotPink , Color.LimeGreen, Color.LimeGreen, Color.LimeGreen},
{ Color32.LimeGreen, Color32.LimeGreen, Color32.HotPink , Color32.LimeGreen} { Color.LimeGreen, Color.LimeGreen, Color.HotPink , Color.LimeGreen}
}); });
} }
[Fact] [Fact]
public void ImageShouldBeFloodFilledWithPercent20_transparent() public void ImageShouldBeFloodFilledWithPercent20_transparent()
{ {
Test("Percent20_Transparent", Color32.Blue, Brushes.Percent20(Color32.HotPink), Test("Percent20_Transparent", Color.Blue, Brushes.Percent20(Color.HotPink),
new Color32[,] { new Color[,] {
{ Color32.HotPink , Color32.Blue, Color32.Blue, Color32.Blue}, { Color.HotPink , Color.Blue, Color.Blue, Color.Blue},
{ Color32.Blue, Color32.Blue, Color32.HotPink , Color32.Blue}, { Color.Blue, Color.Blue, Color.HotPink , Color.Blue},
{ Color32.HotPink , Color32.Blue, Color32.Blue, Color32.Blue}, { Color.HotPink , Color.Blue, Color.Blue, Color.Blue},
{ Color32.Blue, Color32.Blue, Color32.HotPink , Color32.Blue} { Color.Blue, Color.Blue, Color.HotPink , Color.Blue}
}); });
} }
[Fact] [Fact]
public void ImageShouldBeFloodFilledWithHorizontal() public void ImageShouldBeFloodFilledWithHorizontal()
{ {
Test("Horizontal", Color32.Blue, Brushes.Horizontal(Color32.HotPink, Color32.LimeGreen), Test("Horizontal", Color.Blue, Brushes.Horizontal(Color.HotPink, Color.LimeGreen),
new Color32[,] { new Color[,] {
{ Color32.LimeGreen , Color32.LimeGreen, Color32.LimeGreen, Color32.LimeGreen}, { Color.LimeGreen , Color.LimeGreen, Color.LimeGreen, Color.LimeGreen},
{ Color32.HotPink, Color32.HotPink, Color32.HotPink , Color32.HotPink}, { Color.HotPink, Color.HotPink, Color.HotPink , Color.HotPink},
{ Color32.LimeGreen , Color32.LimeGreen, Color32.LimeGreen, Color32.LimeGreen}, { Color.LimeGreen , Color.LimeGreen, Color.LimeGreen, Color.LimeGreen},
{ Color32.LimeGreen, Color32.LimeGreen, Color32.LimeGreen , Color32.LimeGreen} { Color.LimeGreen, Color.LimeGreen, Color.LimeGreen , Color.LimeGreen}
}); });
} }
[Fact] [Fact]
public void ImageShouldBeFloodFilledWithHorizontal_transparent() public void ImageShouldBeFloodFilledWithHorizontal_transparent()
{ {
Test("Horizontal_Transparent", Color32.Blue, Brushes.Horizontal(Color32.HotPink), Test("Horizontal_Transparent", Color.Blue, Brushes.Horizontal(Color.HotPink),
new Color32[,] { new Color[,] {
{ Color32.Blue , Color32.Blue, Color32.Blue, Color32.Blue}, { Color.Blue , Color.Blue, Color.Blue, Color.Blue},
{ Color32.HotPink, Color32.HotPink, Color32.HotPink , Color32.HotPink}, { Color.HotPink, Color.HotPink, Color.HotPink , Color.HotPink},
{ Color32.Blue , Color32.Blue, Color32.Blue, Color32.Blue}, { Color.Blue , Color.Blue, Color.Blue, Color.Blue},
{ Color32.Blue, Color32.Blue, Color32.Blue , Color32.Blue} { Color.Blue, Color.Blue, Color.Blue , Color.Blue}
}); });
} }
@ -138,96 +138,96 @@ namespace ImageSharp.Tests.Drawing
[Fact] [Fact]
public void ImageShouldBeFloodFilledWithMin() public void ImageShouldBeFloodFilledWithMin()
{ {
Test("Min", Color32.Blue, Brushes.Min(Color32.HotPink, Color32.LimeGreen), Test("Min", Color.Blue, Brushes.Min(Color.HotPink, Color.LimeGreen),
new Color32[,] { new Color[,] {
{ Color32.LimeGreen , Color32.LimeGreen, Color32.LimeGreen, Color32.LimeGreen}, { Color.LimeGreen , Color.LimeGreen, Color.LimeGreen, Color.LimeGreen},
{ Color32.LimeGreen , Color32.LimeGreen, Color32.LimeGreen, Color32.LimeGreen}, { Color.LimeGreen , Color.LimeGreen, Color.LimeGreen, Color.LimeGreen},
{ Color32.LimeGreen, Color32.LimeGreen, Color32.LimeGreen , Color32.LimeGreen}, { Color.LimeGreen, Color.LimeGreen, Color.LimeGreen , Color.LimeGreen},
{ Color32.HotPink, Color32.HotPink, Color32.HotPink , Color32.HotPink} { Color.HotPink, Color.HotPink, Color.HotPink , Color.HotPink}
}); });
} }
[Fact] [Fact]
public void ImageShouldBeFloodFilledWithMin_transparent() public void ImageShouldBeFloodFilledWithMin_transparent()
{ {
Test("Min_Transparent", Color32.Blue, Brushes.Min(Color32.HotPink), Test("Min_Transparent", Color.Blue, Brushes.Min(Color.HotPink),
new Color32[,] { new Color[,] {
{ Color32.Blue , Color32.Blue, Color32.Blue, Color32.Blue}, { Color.Blue , Color.Blue, Color.Blue, Color.Blue},
{ Color32.Blue , Color32.Blue, Color32.Blue, Color32.Blue}, { Color.Blue , Color.Blue, Color.Blue, Color.Blue},
{ Color32.Blue, Color32.Blue, Color32.Blue , Color32.Blue}, { Color.Blue, Color.Blue, Color.Blue , Color.Blue},
{ Color32.HotPink, Color32.HotPink, Color32.HotPink , Color32.HotPink}, { Color.HotPink, Color.HotPink, Color.HotPink , Color.HotPink},
}); });
} }
[Fact] [Fact]
public void ImageShouldBeFloodFilledWithVertical() public void ImageShouldBeFloodFilledWithVertical()
{ {
Test("Vertical", Color32.Blue, Brushes.Vertical(Color32.HotPink, Color32.LimeGreen), Test("Vertical", Color.Blue, Brushes.Vertical(Color.HotPink, Color.LimeGreen),
new Color32[,] { new Color[,] {
{ Color32.LimeGreen, Color32.HotPink, Color32.LimeGreen, Color32.LimeGreen}, { Color.LimeGreen, Color.HotPink, Color.LimeGreen, Color.LimeGreen},
{ Color32.LimeGreen, Color32.HotPink, Color32.LimeGreen, Color32.LimeGreen}, { Color.LimeGreen, Color.HotPink, Color.LimeGreen, Color.LimeGreen},
{ Color32.LimeGreen, Color32.HotPink, Color32.LimeGreen, Color32.LimeGreen}, { Color.LimeGreen, Color.HotPink, Color.LimeGreen, Color.LimeGreen},
{ Color32.LimeGreen, Color32.HotPink, Color32.LimeGreen, Color32.LimeGreen} { Color.LimeGreen, Color.HotPink, Color.LimeGreen, Color.LimeGreen}
}); });
} }
[Fact] [Fact]
public void ImageShouldBeFloodFilledWithVertical_transparent() public void ImageShouldBeFloodFilledWithVertical_transparent()
{ {
Test("Vertical_Transparent", Color32.Blue, Brushes.Vertical(Color32.HotPink), Test("Vertical_Transparent", Color.Blue, Brushes.Vertical(Color.HotPink),
new Color32[,] { new Color[,] {
{ Color32.Blue, Color32.HotPink, Color32.Blue, Color32.Blue}, { Color.Blue, Color.HotPink, Color.Blue, Color.Blue},
{ Color32.Blue, Color32.HotPink, Color32.Blue, Color32.Blue}, { Color.Blue, Color.HotPink, Color.Blue, Color.Blue},
{ Color32.Blue, Color32.HotPink, Color32.Blue, Color32.Blue}, { Color.Blue, Color.HotPink, Color.Blue, Color.Blue},
{ Color32.Blue, Color32.HotPink, Color32.Blue, Color32.Blue} { Color.Blue, Color.HotPink, Color.Blue, Color.Blue}
}); });
} }
[Fact] [Fact]
public void ImageShouldBeFloodFilledWithForwardDiagonal() public void ImageShouldBeFloodFilledWithForwardDiagonal()
{ {
Test("ForwardDiagonal", Color32.Blue, Brushes.ForwardDiagonal(Color32.HotPink, Color32.LimeGreen), Test("ForwardDiagonal", Color.Blue, Brushes.ForwardDiagonal(Color.HotPink, Color.LimeGreen),
new Color32[,] { new Color[,] {
{ Color32.LimeGreen, Color32.LimeGreen, Color32.LimeGreen, Color32.HotPink}, { Color.LimeGreen, Color.LimeGreen, Color.LimeGreen, Color.HotPink},
{ Color32.LimeGreen, Color32.LimeGreen, Color32.HotPink, Color32.LimeGreen}, { Color.LimeGreen, Color.LimeGreen, Color.HotPink, Color.LimeGreen},
{ Color32.LimeGreen, Color32.HotPink, Color32.LimeGreen, Color32.LimeGreen}, { Color.LimeGreen, Color.HotPink, Color.LimeGreen, Color.LimeGreen},
{ Color32.HotPink, Color32.LimeGreen, Color32.LimeGreen, Color32.LimeGreen} { Color.HotPink, Color.LimeGreen, Color.LimeGreen, Color.LimeGreen}
}); });
} }
[Fact] [Fact]
public void ImageShouldBeFloodFilledWithForwardDiagonal_transparent() public void ImageShouldBeFloodFilledWithForwardDiagonal_transparent()
{ {
Test("ForwardDiagonal_Transparent", Color32.Blue, Brushes.ForwardDiagonal(Color32.HotPink), Test("ForwardDiagonal_Transparent", Color.Blue, Brushes.ForwardDiagonal(Color.HotPink),
new Color32[,] { new Color[,] {
{ Color32.Blue, Color32.Blue, Color32.Blue, Color32.HotPink}, { Color.Blue, Color.Blue, Color.Blue, Color.HotPink},
{ Color32.Blue, Color32.Blue, Color32.HotPink, Color32.Blue}, { Color.Blue, Color.Blue, Color.HotPink, Color.Blue},
{ Color32.Blue, Color32.HotPink, Color32.Blue, Color32.Blue}, { Color.Blue, Color.HotPink, Color.Blue, Color.Blue},
{ Color32.HotPink, Color32.Blue, Color32.Blue, Color32.Blue} { Color.HotPink, Color.Blue, Color.Blue, Color.Blue}
}); });
} }
[Fact] [Fact]
public void ImageShouldBeFloodFilledWithBackwardDiagonal() public void ImageShouldBeFloodFilledWithBackwardDiagonal()
{ {
Test("BackwardDiagonal", Color32.Blue, Brushes.BackwardDiagonal(Color32.HotPink, Color32.LimeGreen), Test("BackwardDiagonal", Color.Blue, Brushes.BackwardDiagonal(Color.HotPink, Color.LimeGreen),
new Color32[,] { new Color[,] {
{ Color32.HotPink, Color32.LimeGreen, Color32.LimeGreen, Color32.LimeGreen}, { Color.HotPink, Color.LimeGreen, Color.LimeGreen, Color.LimeGreen},
{ Color32.LimeGreen, Color32.HotPink, Color32.LimeGreen, Color32.LimeGreen}, { Color.LimeGreen, Color.HotPink, Color.LimeGreen, Color.LimeGreen},
{ Color32.LimeGreen, Color32.LimeGreen, Color32.HotPink, Color32.LimeGreen}, { Color.LimeGreen, Color.LimeGreen, Color.HotPink, Color.LimeGreen},
{ Color32.LimeGreen, Color32.LimeGreen, Color32.LimeGreen, Color32.HotPink} { Color.LimeGreen, Color.LimeGreen, Color.LimeGreen, Color.HotPink}
}); });
} }
[Fact] [Fact]
public void ImageShouldBeFloodFilledWithBackwardDiagonal_transparent() public void ImageShouldBeFloodFilledWithBackwardDiagonal_transparent()
{ {
Test("BackwardDiagonal_Transparent", Color32.Blue, Brushes.BackwardDiagonal(Color32.HotPink), Test("BackwardDiagonal_Transparent", Color.Blue, Brushes.BackwardDiagonal(Color.HotPink),
new Color32[,] { new Color[,] {
{ Color32.HotPink, Color32.Blue, Color32.Blue, Color32.Blue}, { Color.HotPink, Color.Blue, Color.Blue, Color.Blue},
{ Color32.Blue, Color32.HotPink, Color32.Blue, Color32.Blue}, { Color.Blue, Color.HotPink, Color.Blue, Color.Blue},
{ Color32.Blue, Color32.Blue, Color32.HotPink, Color32.Blue}, { Color.Blue, Color.Blue, Color.HotPink, Color.Blue},
{ Color32.Blue, Color32.Blue, Color32.Blue, Color32.HotPink} { Color.Blue, Color.Blue, Color.Blue, Color.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); ImageSharp.Rectangle bounds = new ImageSharp.Rectangle(0, 0, 1, 1);
Mock<IBrush<Color32>> brush = new Mock<IBrush<Color32>>(); Mock<IBrush<Color>> brush = new Mock<IBrush<Color>>();
Mock<Region> region = new Mock<Region>(); Mock<Region> region = new Mock<Region>();
region.Setup(x => x.Bounds).Returns(bounds); region.Setup(x => x.Bounds).Returns(bounds);
GraphicsOptions options = new GraphicsOptions(antialias) { GraphicsOptions options = new GraphicsOptions(antialias) {
AntialiasSubpixelDepth = 1 AntialiasSubpixelDepth = 1
}; };
FillRegionProcessor<Color32> processor = new FillRegionProcessor<Color32>(brush.Object, region.Object, options); FillRegionProcessor<Color> processor = new FillRegionProcessor<Color>(brush.Object, region.Object, options);
Image img = new Image(1, 1); Image img = new Image(1, 1);
processor.Apply(img, bounds); 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")) using (FileStream output = File.OpenWrite($"{path}/DefaultBack.png"))
{ {
image image
.Fill(Color32.HotPink) .Fill(Color.HotPink)
.Save(output); .Save(output);
} }
using (PixelAccessor<Color32> sourcePixels = image.Lock()) using (PixelAccessor<Color> sourcePixels = image.Lock())
{ {
Assert.Equal(Color32.HotPink, sourcePixels[9, 9]); Assert.Equal(Color.HotPink, sourcePixels[9, 9]);
Assert.Equal(Color32.HotPink, sourcePixels[199, 149]); Assert.Equal(Color.HotPink, sourcePixels[199, 149]);
} }
} }
} }
@ -46,16 +46,16 @@ namespace ImageSharp.Tests.Drawing
using (FileStream output = File.OpenWrite($"{path}/Simple.png")) using (FileStream output = File.OpenWrite($"{path}/Simple.png"))
{ {
image image
.BackgroundColor(Color32.Blue) .BackgroundColor(Color.Blue)
.Fill(Color32.HotPink) .Fill(Color.HotPink)
.Save(output); .Save(output);
} }
using (PixelAccessor<Color32> sourcePixels = image.Lock()) using (PixelAccessor<Color> sourcePixels = image.Lock())
{ {
Assert.Equal(Color32.HotPink, sourcePixels[9, 9]); Assert.Equal(Color.HotPink, sourcePixels[9, 9]);
Assert.Equal(Color32.HotPink, sourcePixels[199, 149]); Assert.Equal(Color.HotPink, sourcePixels[199, 149]);
} }
} }
} }
@ -66,20 +66,20 @@ namespace ImageSharp.Tests.Drawing
string path = this.CreateOutputDirectory("Fill", "SolidBrush"); string path = this.CreateOutputDirectory("Fill", "SolidBrush");
using (Image image = new Image(500, 500)) using (Image image = new Image(500, 500))
{ {
Color32 color = new Color32(Color32.HotPink.R, Color32.HotPink.G, Color32.HotPink.B, 150); Color color = new Color(Color.HotPink.R, Color.HotPink.G, Color.HotPink.B, 150);
using (FileStream output = File.OpenWrite($"{path}/Opacity.png")) using (FileStream output = File.OpenWrite($"{path}/Opacity.png"))
{ {
image image
.BackgroundColor(Color32.Blue) .BackgroundColor(Color.Blue)
.Fill(color) .Fill(color)
.Save(output); .Save(output);
} }
//shift background color towards forground color by the opacity amount //shift background color towards forground color by the opacity amount
Color32 mergedColor = new Color32(Vector4.Lerp(Color32.Blue.ToVector4(), Color32.HotPink.ToVector4(), 150f / 255f)); Color mergedColor = new Color(Vector4.Lerp(Color.Blue.ToVector4(), Color.HotPink.ToVector4(), 150f / 255f));
using (PixelAccessor<Color32> sourcePixels = image.Lock()) using (PixelAccessor<Color> sourcePixels = image.Lock())
{ {
Assert.Equal(mergedColor, sourcePixels[9, 9]); Assert.Equal(mergedColor, sourcePixels[9, 9]);
Assert.Equal(mergedColor, sourcePixels[199, 149]); 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")) using (FileStream output = File.OpenWrite($"{path}/Simple.png"))
{ {
image image
.BackgroundColor(Color32.Blue) .BackgroundColor(Color.Blue)
.Draw(Color32.HotPink, 5, simplePath.Clip(hole1)) .Draw(Color.HotPink, 5, simplePath.Clip(hole1))
.Save(output); .Save(output);
} }
using (PixelAccessor<Color32> sourcePixels = image.Lock()) using (PixelAccessor<Color> sourcePixels = image.Lock())
{ {
Assert.Equal(Color32.HotPink, sourcePixels[10, 10]); Assert.Equal(Color.HotPink, sourcePixels[10, 10]);
Assert.Equal(Color32.HotPink, sourcePixels[200, 150]); Assert.Equal(Color.HotPink, sourcePixels[200, 150]);
Assert.Equal(Color32.HotPink, sourcePixels[50, 300]); Assert.Equal(Color.HotPink, sourcePixels[50, 300]);
Assert.Equal(Color32.HotPink, sourcePixels[37, 85]); Assert.Equal(Color.HotPink, sourcePixels[37, 85]);
Assert.Equal(Color32.HotPink, sourcePixels[93, 85]); Assert.Equal(Color.HotPink, sourcePixels[93, 85]);
Assert.Equal(Color32.HotPink, sourcePixels[65, 137]); Assert.Equal(Color.HotPink, sourcePixels[65, 137]);
Assert.Equal(Color32.Blue, sourcePixels[2, 2]); Assert.Equal(Color.Blue, sourcePixels[2, 2]);
//inside hole //inside hole
Assert.Equal(Color32.Blue, sourcePixels[57, 99]); Assert.Equal(Color.Blue, sourcePixels[57, 99]);
//inside shape //inside shape
Assert.Equal(Color32.Blue, sourcePixels[100, 192]); Assert.Equal(Color.Blue, sourcePixels[100, 192]);
} }
} }
} }
@ -86,18 +86,18 @@ namespace ImageSharp.Tests.Drawing
using (FileStream output = File.OpenWrite($"{path}/SimpleVanishHole.png")) using (FileStream output = File.OpenWrite($"{path}/SimpleVanishHole.png"))
{ {
image image
.BackgroundColor(Color32.Blue) .BackgroundColor(Color.Blue)
.Draw(Color32.HotPink, 5, simplePath.Clip(hole1)) .Draw(Color.HotPink, 5, simplePath.Clip(hole1))
.Save(output); .Save(output);
} }
using (PixelAccessor<Color32> sourcePixels = image.Lock()) using (PixelAccessor<Color> sourcePixels = image.Lock())
{ {
Assert.Equal(Color32.HotPink, sourcePixels[10, 10]); Assert.Equal(Color.HotPink, sourcePixels[10, 10]);
Assert.Equal(Color32.HotPink, sourcePixels[200, 150]); Assert.Equal(Color.HotPink, sourcePixels[200, 150]);
Assert.Equal(Color32.HotPink, sourcePixels[50, 300]); Assert.Equal(Color.HotPink, sourcePixels[50, 300]);
//Assert.Equal(Color.HotPink, sourcePixels[37, 85]); //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.HotPink, sourcePixels[65, 137]);
Assert.Equal(Color32.Blue, sourcePixels[2, 2]); Assert.Equal(Color.Blue, sourcePixels[2, 2]);
//inside hole //inside hole
Assert.Equal(Color32.Blue, sourcePixels[57, 99]); Assert.Equal(Color.Blue, sourcePixels[57, 99]);
//inside shape //inside shape
Assert.Equal(Color32.Blue, sourcePixels[100, 192]); Assert.Equal(Color.Blue, sourcePixels[100, 192]);
} }
} }
} }
@ -137,28 +137,28 @@ namespace ImageSharp.Tests.Drawing
using (FileStream output = File.OpenWrite($"{path}/SimpleOverlapping.png")) using (FileStream output = File.OpenWrite($"{path}/SimpleOverlapping.png"))
{ {
image image
.BackgroundColor(Color32.Blue) .BackgroundColor(Color.Blue)
.Draw(Color32.HotPink, 5, simplePath.Clip(hole1)) .Draw(Color.HotPink, 5, simplePath.Clip(hole1))
.Save(output); .Save(output);
} }
using (PixelAccessor<Color32> sourcePixels = image.Lock()) using (PixelAccessor<Color> sourcePixels = image.Lock())
{ {
Assert.Equal(Color32.HotPink, sourcePixels[10, 10]); Assert.Equal(Color.HotPink, sourcePixels[10, 10]);
Assert.Equal(Color32.HotPink, sourcePixels[200, 150]); Assert.Equal(Color.HotPink, sourcePixels[200, 150]);
Assert.Equal(Color32.HotPink, sourcePixels[50, 300]); Assert.Equal(Color.HotPink, sourcePixels[50, 300]);
Assert.Equal(Color32.Blue, sourcePixels[130, 41]); Assert.Equal(Color.Blue, sourcePixels[130, 41]);
Assert.Equal(Color32.Blue, sourcePixels[2, 2]); Assert.Equal(Color.Blue, sourcePixels[2, 2]);
//inside hole //inside hole
Assert.Equal(Color32.Blue, sourcePixels[57, 99]); Assert.Equal(Color.Blue, sourcePixels[57, 99]);
//inside shape //inside shape
Assert.Equal(Color32.Blue, sourcePixels[100, 192]); Assert.Equal(Color.Blue, sourcePixels[100, 192]);
} }
} }
} }
@ -183,8 +183,8 @@ namespace ImageSharp.Tests.Drawing
using (FileStream output = File.OpenWrite($"{path}/Dashed.png")) using (FileStream output = File.OpenWrite($"{path}/Dashed.png"))
{ {
image image
.BackgroundColor(Color32.Blue) .BackgroundColor(Color.Blue)
.Draw(Pens.Dash(Color32.HotPink, 5), simplePath.Clip(hole1)) .Draw(Pens.Dash(Color.HotPink, 5), simplePath.Clip(hole1))
.Save(output); .Save(output);
} }
} }
@ -204,22 +204,22 @@ namespace ImageSharp.Tests.Drawing
new Vector2(37, 85), new Vector2(37, 85),
new Vector2(93, 85), new Vector2(93, 85),
new Vector2(65, 137))); new Vector2(65, 137)));
Color32 color = new Color32(Color32.HotPink.R, Color32.HotPink.G, Color32.HotPink.B, 150); Color color = new Color(Color.HotPink.R, Color.HotPink.G, Color.HotPink.B, 150);
using (Image image = new Image(500, 500)) using (Image image = new Image(500, 500))
{ {
using (FileStream output = File.OpenWrite($"{path}/Opacity.png")) using (FileStream output = File.OpenWrite($"{path}/Opacity.png"))
{ {
image image
.BackgroundColor(Color32.Blue) .BackgroundColor(Color.Blue)
.Draw(color, 5, simplePath.Clip(hole1)) .Draw(color, 5, simplePath.Clip(hole1))
.Save(output); .Save(output);
} }
//shift background color towards forground color by the opacity amount //shift background color towards forground color by the opacity amount
Color32 mergedColor = new Color32(Vector4.Lerp(Color32.Blue.ToVector4(), Color32.HotPink.ToVector4(), 150f / 255f)); Color mergedColor = new Color(Vector4.Lerp(Color.Blue.ToVector4(), Color.HotPink.ToVector4(), 150f / 255f));
using (PixelAccessor<Color32> sourcePixels = image.Lock()) using (PixelAccessor<Color> sourcePixels = image.Lock())
{ {
Assert.Equal(mergedColor, sourcePixels[10, 10]); Assert.Equal(mergedColor, sourcePixels[10, 10]);
@ -234,14 +234,14 @@ namespace ImageSharp.Tests.Drawing
Assert.Equal(mergedColor, sourcePixels[65, 137]); Assert.Equal(mergedColor, sourcePixels[65, 137]);
Assert.Equal(Color32.Blue, sourcePixels[2, 2]); Assert.Equal(Color.Blue, sourcePixels[2, 2]);
//inside hole //inside hole
Assert.Equal(Color32.Blue, sourcePixels[57, 99]); Assert.Equal(Color.Blue, sourcePixels[57, 99]);
//inside shape //inside shape
Assert.Equal(Color32.Blue, sourcePixels[100, 192]); Assert.Equal(Color.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")) using (FileStream output = File.OpenWrite($"{path}/Simple.png"))
{ {
image image
.BackgroundColor(Color32.Blue) .BackgroundColor(Color.Blue)
.DrawLines(Color32.HotPink, 5, .DrawLines(Color.HotPink, 5,
new[] { new[] {
new Vector2(10, 10), new Vector2(10, 10),
new Vector2(200, 150), new Vector2(200, 150),
@ -33,13 +33,13 @@ namespace ImageSharp.Tests.Drawing
.Save(output); .Save(output);
} }
using (PixelAccessor<Color32> sourcePixels = image.Lock()) using (PixelAccessor<Color> sourcePixels = image.Lock())
{ {
Assert.Equal(Color32.HotPink, sourcePixels[9, 9]); Assert.Equal(Color.HotPink, sourcePixels[9, 9]);
Assert.Equal(Color32.HotPink, sourcePixels[199, 149]); Assert.Equal(Color.HotPink, sourcePixels[199, 149]);
Assert.Equal(Color32.Blue, sourcePixels[50, 50]); Assert.Equal(Color.Blue, sourcePixels[50, 50]);
} }
} }
} }
@ -53,8 +53,8 @@ namespace ImageSharp.Tests.Drawing
using (FileStream output = File.OpenWrite($"{path}/Simple_noantialias.png")) using (FileStream output = File.OpenWrite($"{path}/Simple_noantialias.png"))
{ {
image image
.BackgroundColor(Color32.Blue) .BackgroundColor(Color.Blue)
.DrawLines(Color32.HotPink, 5, .DrawLines(Color.HotPink, 5,
new[] { new[] {
new Vector2(10, 10), new Vector2(10, 10),
new Vector2(200, 150), new Vector2(200, 150),
@ -64,13 +64,13 @@ namespace ImageSharp.Tests.Drawing
.Save(output); .Save(output);
} }
using (PixelAccessor<Color32> sourcePixels = image.Lock()) using (PixelAccessor<Color> sourcePixels = image.Lock())
{ {
Assert.Equal(Color32.HotPink, sourcePixels[9, 9]); Assert.Equal(Color.HotPink, sourcePixels[9, 9]);
Assert.Equal(Color32.HotPink, sourcePixels[199, 149]); Assert.Equal(Color.HotPink, sourcePixels[199, 149]);
Assert.Equal(Color32.Blue, sourcePixels[50, 50]); Assert.Equal(Color.Blue, sourcePixels[50, 50]);
} }
} }
} }
@ -84,8 +84,8 @@ namespace ImageSharp.Tests.Drawing
using (FileStream output = File.OpenWrite($"{path}/Dashed.png")) using (FileStream output = File.OpenWrite($"{path}/Dashed.png"))
{ {
image image
.BackgroundColor(Color32.Blue) .BackgroundColor(Color.Blue)
.DrawLines(Pens.Dash(Color32.HotPink, 5), .DrawLines(Pens.Dash(Color.HotPink, 5),
new[] { new[] {
new Vector2(10, 10), new Vector2(10, 10),
new Vector2(200, 150), new Vector2(200, 150),
@ -105,8 +105,8 @@ namespace ImageSharp.Tests.Drawing
using (FileStream output = File.OpenWrite($"{path}/Dot.png")) using (FileStream output = File.OpenWrite($"{path}/Dot.png"))
{ {
image image
.BackgroundColor(Color32.Blue) .BackgroundColor(Color.Blue)
.DrawLines(Pens.Dot(Color32.HotPink, 5), .DrawLines(Pens.Dot(Color.HotPink, 5),
new[] { new[] {
new Vector2(10, 10), new Vector2(10, 10),
new Vector2(200, 150), new Vector2(200, 150),
@ -126,8 +126,8 @@ namespace ImageSharp.Tests.Drawing
using (FileStream output = File.OpenWrite($"{path}/DashDot.png")) using (FileStream output = File.OpenWrite($"{path}/DashDot.png"))
{ {
image image
.BackgroundColor(Color32.Blue) .BackgroundColor(Color.Blue)
.DrawLines(Pens.DashDot(Color32.HotPink, 5), .DrawLines(Pens.DashDot(Color.HotPink, 5),
new[] { new[] {
new Vector2(10, 10), new Vector2(10, 10),
new Vector2(200, 150), new Vector2(200, 150),
@ -147,8 +147,8 @@ namespace ImageSharp.Tests.Drawing
using (FileStream output = File.OpenWrite($"{path}/DashDotDot.png")) using (FileStream output = File.OpenWrite($"{path}/DashDotDot.png"))
{ {
image image
.BackgroundColor(Color32.Blue) .BackgroundColor(Color.Blue)
.DrawLines(Pens.DashDotDot(Color32.HotPink, 5), new[] { .DrawLines(Pens.DashDotDot(Color.HotPink, 5), new[] {
new Vector2(10, 10), new Vector2(10, 10),
new Vector2(200, 150), new Vector2(200, 150),
new Vector2(50, 300) new Vector2(50, 300)
@ -162,7 +162,7 @@ namespace ImageSharp.Tests.Drawing
{ {
string path = this.CreateOutputDirectory("Drawing", "Lines"); string path = this.CreateOutputDirectory("Drawing", "Lines");
Color32 color = new Color32(Color32.HotPink.R, Color32.HotPink.G, Color32.HotPink.B, 150); Color color = new Color(Color.HotPink.R, Color.HotPink.G, Color.HotPink.B, 150);
Image image = new Image(500, 500); Image image = new Image(500, 500);
@ -170,7 +170,7 @@ namespace ImageSharp.Tests.Drawing
using (FileStream output = File.OpenWrite($"{path}/Opacity.png")) using (FileStream output = File.OpenWrite($"{path}/Opacity.png"))
{ {
image image
.BackgroundColor(Color32.Blue) .BackgroundColor(Color.Blue)
.DrawLines(color, 10, new[] { .DrawLines(color, 10, new[] {
new Vector2(10, 10), new Vector2(10, 10),
new Vector2(200, 150), new Vector2(200, 150),
@ -180,15 +180,15 @@ namespace ImageSharp.Tests.Drawing
} }
//shift background color towards forground color by the opacity amount //shift background color towards forground color by the opacity amount
Color32 mergedColor = new Color32(Vector4.Lerp(Color32.Blue.ToVector4(), Color32.HotPink.ToVector4(), 150f/255f)); Color mergedColor = new Color(Vector4.Lerp(Color.Blue.ToVector4(), Color.HotPink.ToVector4(), 150f/255f));
using (PixelAccessor<Color32> sourcePixels = image.Lock()) using (PixelAccessor<Color> sourcePixels = image.Lock())
{ {
Assert.Equal(mergedColor, sourcePixels[9, 9]); Assert.Equal(mergedColor, sourcePixels[9, 9]);
Assert.Equal(mergedColor, sourcePixels[199, 149]); Assert.Equal(mergedColor, sourcePixels[199, 149]);
Assert.Equal(Color32.Blue, sourcePixels[50, 50]); Assert.Equal(Color.Blue, sourcePixels[50, 50]);
} }
} }
@ -202,8 +202,8 @@ namespace ImageSharp.Tests.Drawing
using (FileStream output = File.OpenWrite($"{path}/Rectangle.png")) using (FileStream output = File.OpenWrite($"{path}/Rectangle.png"))
{ {
image image
.BackgroundColor(Color32.Blue) .BackgroundColor(Color.Blue)
.DrawLines(Color32.HotPink, 10, new[] { .DrawLines(Color.HotPink, 10, new[] {
new Vector2(10, 10), new Vector2(10, 10),
new Vector2(200, 10), new Vector2(200, 10),
new Vector2(200, 150), new Vector2(200, 150),
@ -212,15 +212,15 @@ namespace ImageSharp.Tests.Drawing
.Save(output); .Save(output);
} }
using (PixelAccessor<Color32> sourcePixels = image.Lock()) using (PixelAccessor<Color> sourcePixels = image.Lock())
{ {
Assert.Equal(Color32.HotPink, sourcePixels[8, 8]); Assert.Equal(Color.HotPink, sourcePixels[8, 8]);
Assert.Equal(Color32.HotPink, sourcePixels[198, 10]); Assert.Equal(Color.HotPink, sourcePixels[198, 10]);
Assert.Equal(Color32.Blue, sourcePixels[10, 50]); Assert.Equal(Color.Blue, sourcePixels[10, 50]);
Assert.Equal(Color32.Blue, sourcePixels[50, 50]); Assert.Equal(Color.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; float thickness = 7.2f;
GraphicsOptions noneDefault = new GraphicsOptions(); GraphicsOptions noneDefault = new GraphicsOptions();
Color32 color = Color32.HotPink; Color color = Color.HotPink;
SolidBrush brush = Brushes.Solid(Color32.HotPink); SolidBrush brush = Brushes.Solid(Color.HotPink);
Pen pen = new Pen(Color32.Firebrick, 99.9f); Pen pen = new Pen(Color.Firebrick, 99.9f);
Vector2[] points = new Vector2[] { Vector2[] points = new Vector2[] {
new Vector2(10,10), new Vector2(10,10),
new Vector2(20,10), new Vector2(20,10),
@ -45,7 +45,7 @@ namespace ImageSharp.Tests.Drawing.Paths
img.DrawBeziers(brush, thickness, points); img.DrawBeziers(brush, thickness, points);
Assert.NotEmpty(img.ProcessorApplications); Assert.NotEmpty(img.ProcessorApplications);
DrawPathProcessor<Color32> processor = Assert.IsType<DrawPathProcessor<Color32>>(img.ProcessorApplications[0].processor); DrawPathProcessor<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor);
Assert.Equal(GraphicsOptions.Default, processor.Options); Assert.Equal(GraphicsOptions.Default, processor.Options);
@ -56,7 +56,7 @@ namespace ImageSharp.Tests.Drawing.Paths
BezierLineSegment segment = Assert.IsType<BezierLineSegment>(vector.LineSegments[0]); BezierLineSegment segment = Assert.IsType<BezierLineSegment>(vector.LineSegments[0]);
Pen<Color32> pen = Assert.IsType<Pen<Color32>>(processor.Pen); Pen<Color> pen = Assert.IsType<Pen<Color>>(processor.Pen);
Assert.Equal(brush, pen.Brush); Assert.Equal(brush, pen.Brush);
Assert.Equal(thickness, pen.Width); Assert.Equal(thickness, pen.Width);
} }
@ -67,7 +67,7 @@ namespace ImageSharp.Tests.Drawing.Paths
img.DrawBeziers(brush, thickness, points, noneDefault); img.DrawBeziers(brush, thickness, points, noneDefault);
Assert.NotEmpty(img.ProcessorApplications); Assert.NotEmpty(img.ProcessorApplications);
DrawPathProcessor<Color32> processor = Assert.IsType<DrawPathProcessor<Color32>>(img.ProcessorApplications[0].processor); DrawPathProcessor<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor);
Assert.Equal(noneDefault, processor.Options); 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); SixLabors.Shapes.Path vector = Assert.IsType<SixLabors.Shapes.Path>(path.Path);
BezierLineSegment segment = Assert.IsType<BezierLineSegment>(vector.LineSegments[0]); BezierLineSegment segment = Assert.IsType<BezierLineSegment>(vector.LineSegments[0]);
Pen<Color32> pen = Assert.IsType<Pen<Color32>>(processor.Pen); Pen<Color> pen = Assert.IsType<Pen<Color>>(processor.Pen);
Assert.Equal(brush, pen.Brush); Assert.Equal(brush, pen.Brush);
Assert.Equal(thickness, pen.Width); Assert.Equal(thickness, pen.Width);
} }
@ -87,7 +87,7 @@ namespace ImageSharp.Tests.Drawing.Paths
img.DrawBeziers(color, thickness, points); img.DrawBeziers(color, thickness, points);
Assert.NotEmpty(img.ProcessorApplications); Assert.NotEmpty(img.ProcessorApplications);
DrawPathProcessor<Color32> processor = Assert.IsType<DrawPathProcessor<Color32>>(img.ProcessorApplications[0].processor); DrawPathProcessor<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor);
Assert.Equal(GraphicsOptions.Default, processor.Options); 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); SixLabors.Shapes.Path vector = Assert.IsType<SixLabors.Shapes.Path>(path.Path);
BezierLineSegment segment = Assert.IsType<BezierLineSegment>(vector.LineSegments[0]); BezierLineSegment segment = Assert.IsType<BezierLineSegment>(vector.LineSegments[0]);
Pen<Color32> pen = Assert.IsType<Pen<Color32>>(processor.Pen); Pen<Color> pen = Assert.IsType<Pen<Color>>(processor.Pen);
Assert.Equal(thickness, pen.Width); Assert.Equal(thickness, pen.Width);
SolidBrush<Color32> brush = Assert.IsType<SolidBrush<Color32>>(pen.Brush); SolidBrush<Color> brush = Assert.IsType<SolidBrush<Color>>(pen.Brush);
Assert.Equal(color, brush.Color); Assert.Equal(color, brush.Color);
} }
@ -109,7 +109,7 @@ namespace ImageSharp.Tests.Drawing.Paths
img.DrawBeziers(color, thickness, points, noneDefault); img.DrawBeziers(color, thickness, points, noneDefault);
Assert.NotEmpty(img.ProcessorApplications); Assert.NotEmpty(img.ProcessorApplications);
DrawPathProcessor<Color32> processor = Assert.IsType<DrawPathProcessor<Color32>>(img.ProcessorApplications[0].processor); DrawPathProcessor<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor);
Assert.Equal(noneDefault, processor.Options); 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); SixLabors.Shapes.Path vector = Assert.IsType<SixLabors.Shapes.Path>(path.Path);
BezierLineSegment segment = Assert.IsType<BezierLineSegment>(vector.LineSegments[0]); BezierLineSegment segment = Assert.IsType<BezierLineSegment>(vector.LineSegments[0]);
Pen<Color32> pen = Assert.IsType<Pen<Color32>>(processor.Pen); Pen<Color> pen = Assert.IsType<Pen<Color>>(processor.Pen);
Assert.Equal(thickness, pen.Width); Assert.Equal(thickness, pen.Width);
SolidBrush<Color32> brush = Assert.IsType<SolidBrush<Color32>>(pen.Brush); SolidBrush<Color> brush = Assert.IsType<SolidBrush<Color>>(pen.Brush);
Assert.Equal(color, brush.Color); Assert.Equal(color, brush.Color);
} }
@ -131,7 +131,7 @@ namespace ImageSharp.Tests.Drawing.Paths
img.DrawBeziers(pen, points); img.DrawBeziers(pen, points);
Assert.NotEmpty(img.ProcessorApplications); Assert.NotEmpty(img.ProcessorApplications);
DrawPathProcessor<Color32> processor = Assert.IsType<DrawPathProcessor<Color32>>(img.ProcessorApplications[0].processor); DrawPathProcessor<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor);
Assert.Equal(GraphicsOptions.Default, processor.Options); Assert.Equal(GraphicsOptions.Default, processor.Options);
@ -149,7 +149,7 @@ namespace ImageSharp.Tests.Drawing.Paths
img.DrawBeziers(pen, points, noneDefault); img.DrawBeziers(pen, points, noneDefault);
Assert.NotEmpty(img.ProcessorApplications); Assert.NotEmpty(img.ProcessorApplications);
DrawPathProcessor<Color32> processor = Assert.IsType<DrawPathProcessor<Color32>>(img.ProcessorApplications[0].processor); DrawPathProcessor<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor);
Assert.Equal(noneDefault, processor.Options); 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; float thickness = 7.2f;
GraphicsOptions noneDefault = new GraphicsOptions(); GraphicsOptions noneDefault = new GraphicsOptions();
Color32 color = Color32.HotPink; Color color = Color.HotPink;
SolidBrush brush = Brushes.Solid(Color32.HotPink); SolidBrush brush = Brushes.Solid(Color.HotPink);
Pen pen = new Pen(Color32.Gray, 99.9f); Pen pen = new Pen(Color.Gray, 99.9f);
Vector2[] points = new Vector2[] { Vector2[] points = new Vector2[] {
new Vector2(10,10), new Vector2(10,10),
new Vector2(20,10), new Vector2(20,10),
@ -45,7 +45,7 @@ namespace ImageSharp.Tests.Drawing.Paths
img.DrawLines(brush, thickness, points); img.DrawLines(brush, thickness, points);
Assert.NotEmpty(img.ProcessorApplications); Assert.NotEmpty(img.ProcessorApplications);
DrawPathProcessor<Color32> processor = Assert.IsType<DrawPathProcessor<Color32>>(img.ProcessorApplications[0].processor); DrawPathProcessor<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor);
Assert.Equal(GraphicsOptions.Default, processor.Options); 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); SixLabors.Shapes.Path vector = Assert.IsType<SixLabors.Shapes.Path>(path.Path);
LinearLineSegment segment = Assert.IsType<LinearLineSegment>(vector.LineSegments[0]); LinearLineSegment segment = Assert.IsType<LinearLineSegment>(vector.LineSegments[0]);
Pen<Color32> pen = Assert.IsType<Pen<Color32>>(processor.Pen); Pen<Color> pen = Assert.IsType<Pen<Color>>(processor.Pen);
Assert.Equal(brush, pen.Brush); Assert.Equal(brush, pen.Brush);
Assert.Equal(thickness, pen.Width); Assert.Equal(thickness, pen.Width);
} }
@ -65,7 +65,7 @@ namespace ImageSharp.Tests.Drawing.Paths
img.DrawLines(brush, thickness, points, noneDefault); img.DrawLines(brush, thickness, points, noneDefault);
Assert.NotEmpty(img.ProcessorApplications); Assert.NotEmpty(img.ProcessorApplications);
DrawPathProcessor<Color32> processor = Assert.IsType<DrawPathProcessor<Color32>>(img.ProcessorApplications[0].processor); DrawPathProcessor<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor);
Assert.Equal(noneDefault, processor.Options); 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); SixLabors.Shapes.Path vector = Assert.IsType<SixLabors.Shapes.Path>(path.Path);
LinearLineSegment segment = Assert.IsType<LinearLineSegment>(vector.LineSegments[0]); LinearLineSegment segment = Assert.IsType<LinearLineSegment>(vector.LineSegments[0]);
Pen<Color32> pen = Assert.IsType<Pen<Color32>>(processor.Pen); Pen<Color> pen = Assert.IsType<Pen<Color>>(processor.Pen);
Assert.Equal(brush, pen.Brush); Assert.Equal(brush, pen.Brush);
Assert.Equal(thickness, pen.Width); Assert.Equal(thickness, pen.Width);
} }
@ -85,7 +85,7 @@ namespace ImageSharp.Tests.Drawing.Paths
img.DrawLines(color, thickness, points); img.DrawLines(color, thickness, points);
Assert.NotEmpty(img.ProcessorApplications); Assert.NotEmpty(img.ProcessorApplications);
DrawPathProcessor<Color32> processor = Assert.IsType<DrawPathProcessor<Color32>>(img.ProcessorApplications[0].processor); DrawPathProcessor<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor);
Assert.Equal(GraphicsOptions.Default, processor.Options); 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); SixLabors.Shapes.Path vector = Assert.IsType<SixLabors.Shapes.Path>(path.Path);
LinearLineSegment segment = Assert.IsType<LinearLineSegment>(vector.LineSegments[0]); LinearLineSegment segment = Assert.IsType<LinearLineSegment>(vector.LineSegments[0]);
Pen<Color32> pen = Assert.IsType<Pen<Color32>>(processor.Pen); Pen<Color> pen = Assert.IsType<Pen<Color>>(processor.Pen);
Assert.Equal(thickness, pen.Width); Assert.Equal(thickness, pen.Width);
SolidBrush<Color32> brush = Assert.IsType<SolidBrush<Color32>>(pen.Brush); SolidBrush<Color> brush = Assert.IsType<SolidBrush<Color>>(pen.Brush);
Assert.Equal(color, brush.Color); Assert.Equal(color, brush.Color);
} }
@ -107,7 +107,7 @@ namespace ImageSharp.Tests.Drawing.Paths
img.DrawLines(color, thickness, points, noneDefault); img.DrawLines(color, thickness, points, noneDefault);
Assert.NotEmpty(img.ProcessorApplications); Assert.NotEmpty(img.ProcessorApplications);
DrawPathProcessor<Color32> processor = Assert.IsType<DrawPathProcessor<Color32>>(img.ProcessorApplications[0].processor); DrawPathProcessor<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor);
Assert.Equal(noneDefault, processor.Options); 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); SixLabors.Shapes.Path vector = Assert.IsType<SixLabors.Shapes.Path>(path.Path);
LinearLineSegment segment = Assert.IsType<LinearLineSegment>(vector.LineSegments[0]); LinearLineSegment segment = Assert.IsType<LinearLineSegment>(vector.LineSegments[0]);
Pen<Color32> pen = Assert.IsType<Pen<Color32>>(processor.Pen); Pen<Color> pen = Assert.IsType<Pen<Color>>(processor.Pen);
Assert.Equal(thickness, pen.Width); Assert.Equal(thickness, pen.Width);
SolidBrush<Color32> brush = Assert.IsType<SolidBrush<Color32>>(pen.Brush); SolidBrush<Color> brush = Assert.IsType<SolidBrush<Color>>(pen.Brush);
Assert.Equal(color, brush.Color); Assert.Equal(color, brush.Color);
} }
@ -129,7 +129,7 @@ namespace ImageSharp.Tests.Drawing.Paths
img.DrawLines(pen, points); img.DrawLines(pen, points);
Assert.NotEmpty(img.ProcessorApplications); Assert.NotEmpty(img.ProcessorApplications);
DrawPathProcessor<Color32> processor = Assert.IsType<DrawPathProcessor<Color32>>(img.ProcessorApplications[0].processor); DrawPathProcessor<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor);
Assert.Equal(GraphicsOptions.Default, processor.Options); Assert.Equal(GraphicsOptions.Default, processor.Options);
@ -147,7 +147,7 @@ namespace ImageSharp.Tests.Drawing.Paths
img.DrawLines(pen, points, noneDefault); img.DrawLines(pen, points, noneDefault);
Assert.NotEmpty(img.ProcessorApplications); Assert.NotEmpty(img.ProcessorApplications);
DrawPathProcessor<Color32> processor = Assert.IsType<DrawPathProcessor<Color32>>(img.ProcessorApplications[0].processor); DrawPathProcessor<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor);
Assert.Equal(noneDefault, processor.Options); 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; float thickness = 7.2f;
GraphicsOptions noneDefault = new GraphicsOptions(); GraphicsOptions noneDefault = new GraphicsOptions();
Color32 color = Color32.HotPink; Color color = Color.HotPink;
SolidBrush brush = Brushes.Solid(Color32.HotPink); SolidBrush brush = Brushes.Solid(Color.HotPink);
Pen pen = new Pen(Color32.Gray, 99.9f); Pen pen = new Pen(Color.Gray, 99.9f);
IPath path = new SixLabors.Shapes.Path(new LinearLineSegment(new Vector2[] { IPath path = new SixLabors.Shapes.Path(new LinearLineSegment(new Vector2[] {
new Vector2(10,10), new Vector2(10,10),
new Vector2(20,10), new Vector2(20,10),
@ -45,14 +45,14 @@ namespace ImageSharp.Tests.Drawing.Paths
img.Draw(brush, thickness, path); img.Draw(brush, thickness, path);
Assert.NotEmpty(img.ProcessorApplications); Assert.NotEmpty(img.ProcessorApplications);
DrawPathProcessor<Color32> processor = Assert.IsType<DrawPathProcessor<Color32>>(img.ProcessorApplications[0].processor); DrawPathProcessor<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor);
Assert.Equal(GraphicsOptions.Default, processor.Options); Assert.Equal(GraphicsOptions.Default, processor.Options);
ShapePath shapepath = Assert.IsType<ShapePath>(processor.Path); ShapePath shapepath = Assert.IsType<ShapePath>(processor.Path);
Assert.Equal(path, shapepath.Path); Assert.Equal(path, shapepath.Path);
Pen<Color32> pen = Assert.IsType<Pen<Color32>>(processor.Pen); Pen<Color> pen = Assert.IsType<Pen<Color>>(processor.Pen);
Assert.Equal(brush, pen.Brush); Assert.Equal(brush, pen.Brush);
Assert.Equal(thickness, pen.Width); Assert.Equal(thickness, pen.Width);
} }
@ -63,14 +63,14 @@ namespace ImageSharp.Tests.Drawing.Paths
img.Draw(brush, thickness, path, noneDefault); img.Draw(brush, thickness, path, noneDefault);
Assert.NotEmpty(img.ProcessorApplications); Assert.NotEmpty(img.ProcessorApplications);
DrawPathProcessor<Color32> processor = Assert.IsType<DrawPathProcessor<Color32>>(img.ProcessorApplications[0].processor); DrawPathProcessor<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor);
Assert.Equal(noneDefault, processor.Options); Assert.Equal(noneDefault, processor.Options);
ShapePath shapepath = Assert.IsType<ShapePath>(processor.Path); ShapePath shapepath = Assert.IsType<ShapePath>(processor.Path);
Assert.Equal(path, shapepath.Path); Assert.Equal(path, shapepath.Path);
Pen<Color32> pen = Assert.IsType<Pen<Color32>>(processor.Pen); Pen<Color> pen = Assert.IsType<Pen<Color>>(processor.Pen);
Assert.Equal(brush, pen.Brush); Assert.Equal(brush, pen.Brush);
Assert.Equal(thickness, pen.Width); Assert.Equal(thickness, pen.Width);
} }
@ -81,17 +81,17 @@ namespace ImageSharp.Tests.Drawing.Paths
img.Draw(color, thickness, path); img.Draw(color, thickness, path);
Assert.NotEmpty(img.ProcessorApplications); Assert.NotEmpty(img.ProcessorApplications);
DrawPathProcessor<Color32> processor = Assert.IsType<DrawPathProcessor<Color32>>(img.ProcessorApplications[0].processor); DrawPathProcessor<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor);
Assert.Equal(GraphicsOptions.Default, processor.Options); Assert.Equal(GraphicsOptions.Default, processor.Options);
ShapePath shapepath = Assert.IsType<ShapePath>(processor.Path); ShapePath shapepath = Assert.IsType<ShapePath>(processor.Path);
Assert.Equal(path, shapepath.Path); Assert.Equal(path, shapepath.Path);
Pen<Color32> pen = Assert.IsType<Pen<Color32>>(processor.Pen); Pen<Color> pen = Assert.IsType<Pen<Color>>(processor.Pen);
Assert.Equal(thickness, pen.Width); Assert.Equal(thickness, pen.Width);
SolidBrush<Color32> brush = Assert.IsType<SolidBrush<Color32>>(pen.Brush); SolidBrush<Color> brush = Assert.IsType<SolidBrush<Color>>(pen.Brush);
Assert.Equal(color, brush.Color); Assert.Equal(color, brush.Color);
} }
@ -101,17 +101,17 @@ namespace ImageSharp.Tests.Drawing.Paths
img.Draw(color, thickness, path, noneDefault); img.Draw(color, thickness, path, noneDefault);
Assert.NotEmpty(img.ProcessorApplications); Assert.NotEmpty(img.ProcessorApplications);
DrawPathProcessor<Color32> processor = Assert.IsType<DrawPathProcessor<Color32>>(img.ProcessorApplications[0].processor); DrawPathProcessor<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor);
Assert.Equal(noneDefault, processor.Options); Assert.Equal(noneDefault, processor.Options);
ShapePath shapepath = Assert.IsType<ShapePath>(processor.Path); ShapePath shapepath = Assert.IsType<ShapePath>(processor.Path);
Assert.Equal(path, shapepath.Path); Assert.Equal(path, shapepath.Path);
Pen<Color32> pen = Assert.IsType<Pen<Color32>>(processor.Pen); Pen<Color> pen = Assert.IsType<Pen<Color>>(processor.Pen);
Assert.Equal(thickness, pen.Width); Assert.Equal(thickness, pen.Width);
SolidBrush<Color32> brush = Assert.IsType<SolidBrush<Color32>>(pen.Brush); SolidBrush<Color> brush = Assert.IsType<SolidBrush<Color>>(pen.Brush);
Assert.Equal(color, brush.Color); Assert.Equal(color, brush.Color);
} }
@ -121,7 +121,7 @@ namespace ImageSharp.Tests.Drawing.Paths
img.Draw(pen, path); img.Draw(pen, path);
Assert.NotEmpty(img.ProcessorApplications); Assert.NotEmpty(img.ProcessorApplications);
DrawPathProcessor<Color32> processor = Assert.IsType<DrawPathProcessor<Color32>>(img.ProcessorApplications[0].processor); DrawPathProcessor<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor);
Assert.Equal(GraphicsOptions.Default, processor.Options); Assert.Equal(GraphicsOptions.Default, processor.Options);
@ -137,7 +137,7 @@ namespace ImageSharp.Tests.Drawing.Paths
img.Draw(pen, path, noneDefault); img.Draw(pen, path, noneDefault);
Assert.NotEmpty(img.ProcessorApplications); Assert.NotEmpty(img.ProcessorApplications);
DrawPathProcessor<Color32> processor = Assert.IsType<DrawPathProcessor<Color32>>(img.ProcessorApplications[0].processor); DrawPathProcessor<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor);
Assert.Equal(noneDefault, processor.Options); 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; float thickness = 7.2f;
GraphicsOptions noneDefault = new GraphicsOptions(); GraphicsOptions noneDefault = new GraphicsOptions();
Color32 color = Color32.HotPink; Color color = Color.HotPink;
SolidBrush brush = Brushes.Solid(Color32.HotPink); SolidBrush brush = Brushes.Solid(Color.HotPink);
Pen pen = new Pen(Color32.Gray, 99.9f); Pen pen = new Pen(Color.Gray, 99.9f);
Vector2[] points = new Vector2[] { Vector2[] points = new Vector2[] {
new Vector2(10,10), new Vector2(10,10),
new Vector2(20,10), new Vector2(20,10),
@ -45,7 +45,7 @@ namespace ImageSharp.Tests.Drawing.Paths
img.DrawPolygon(brush, thickness, points); img.DrawPolygon(brush, thickness, points);
Assert.NotEmpty(img.ProcessorApplications); Assert.NotEmpty(img.ProcessorApplications);
DrawPathProcessor<Color32> processor = Assert.IsType<DrawPathProcessor<Color32>>(img.ProcessorApplications[0].processor); DrawPathProcessor<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor);
Assert.Equal(GraphicsOptions.Default, processor.Options); Assert.Equal(GraphicsOptions.Default, processor.Options);
@ -54,7 +54,7 @@ namespace ImageSharp.Tests.Drawing.Paths
Polygon vector = Assert.IsType<SixLabors.Shapes.Polygon>(path.Path); Polygon vector = Assert.IsType<SixLabors.Shapes.Polygon>(path.Path);
LinearLineSegment segment = Assert.IsType<LinearLineSegment>(vector.LineSegments[0]); LinearLineSegment segment = Assert.IsType<LinearLineSegment>(vector.LineSegments[0]);
Pen<Color32> pen = Assert.IsType<Pen<Color32>>(processor.Pen); Pen<Color> pen = Assert.IsType<Pen<Color>>(processor.Pen);
Assert.Equal(brush, pen.Brush); Assert.Equal(brush, pen.Brush);
Assert.Equal(thickness, pen.Width); Assert.Equal(thickness, pen.Width);
} }
@ -65,7 +65,7 @@ namespace ImageSharp.Tests.Drawing.Paths
img.DrawPolygon(brush, thickness, points, noneDefault); img.DrawPolygon(brush, thickness, points, noneDefault);
Assert.NotEmpty(img.ProcessorApplications); Assert.NotEmpty(img.ProcessorApplications);
DrawPathProcessor<Color32> processor = Assert.IsType<DrawPathProcessor<Color32>>(img.ProcessorApplications[0].processor); DrawPathProcessor<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor);
Assert.Equal(noneDefault, processor.Options); Assert.Equal(noneDefault, processor.Options);
@ -74,7 +74,7 @@ namespace ImageSharp.Tests.Drawing.Paths
Polygon vector = Assert.IsType<SixLabors.Shapes.Polygon>(path.Path); Polygon vector = Assert.IsType<SixLabors.Shapes.Polygon>(path.Path);
LinearLineSegment segment = Assert.IsType<LinearLineSegment>(vector.LineSegments[0]); LinearLineSegment segment = Assert.IsType<LinearLineSegment>(vector.LineSegments[0]);
Pen<Color32> pen = Assert.IsType<Pen<Color32>>(processor.Pen); Pen<Color> pen = Assert.IsType<Pen<Color>>(processor.Pen);
Assert.Equal(brush, pen.Brush); Assert.Equal(brush, pen.Brush);
Assert.Equal(thickness, pen.Width); Assert.Equal(thickness, pen.Width);
} }
@ -85,7 +85,7 @@ namespace ImageSharp.Tests.Drawing.Paths
img.DrawPolygon(color, thickness, points); img.DrawPolygon(color, thickness, points);
Assert.NotEmpty(img.ProcessorApplications); Assert.NotEmpty(img.ProcessorApplications);
DrawPathProcessor<Color32> processor = Assert.IsType<DrawPathProcessor<Color32>>(img.ProcessorApplications[0].processor); DrawPathProcessor<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor);
Assert.Equal(GraphicsOptions.Default, processor.Options); Assert.Equal(GraphicsOptions.Default, processor.Options);
@ -94,10 +94,10 @@ namespace ImageSharp.Tests.Drawing.Paths
Polygon vector = Assert.IsType<SixLabors.Shapes.Polygon>(path.Path); Polygon vector = Assert.IsType<SixLabors.Shapes.Polygon>(path.Path);
LinearLineSegment segment = Assert.IsType<LinearLineSegment>(vector.LineSegments[0]); LinearLineSegment segment = Assert.IsType<LinearLineSegment>(vector.LineSegments[0]);
Pen<Color32> pen = Assert.IsType<Pen<Color32>>(processor.Pen); Pen<Color> pen = Assert.IsType<Pen<Color>>(processor.Pen);
Assert.Equal(thickness, pen.Width); Assert.Equal(thickness, pen.Width);
SolidBrush<Color32> brush = Assert.IsType<SolidBrush<Color32>>(pen.Brush); SolidBrush<Color> brush = Assert.IsType<SolidBrush<Color>>(pen.Brush);
Assert.Equal(color, brush.Color); Assert.Equal(color, brush.Color);
} }
@ -107,7 +107,7 @@ namespace ImageSharp.Tests.Drawing.Paths
img.DrawPolygon(color, thickness, points, noneDefault); img.DrawPolygon(color, thickness, points, noneDefault);
Assert.NotEmpty(img.ProcessorApplications); Assert.NotEmpty(img.ProcessorApplications);
DrawPathProcessor<Color32> processor = Assert.IsType<DrawPathProcessor<Color32>>(img.ProcessorApplications[0].processor); DrawPathProcessor<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor);
Assert.Equal(noneDefault, processor.Options); Assert.Equal(noneDefault, processor.Options);
@ -116,10 +116,10 @@ namespace ImageSharp.Tests.Drawing.Paths
Polygon vector = Assert.IsType<SixLabors.Shapes.Polygon>(path.Path); Polygon vector = Assert.IsType<SixLabors.Shapes.Polygon>(path.Path);
LinearLineSegment segment = Assert.IsType<LinearLineSegment>(vector.LineSegments[0]); LinearLineSegment segment = Assert.IsType<LinearLineSegment>(vector.LineSegments[0]);
Pen<Color32> pen = Assert.IsType<Pen<Color32>>(processor.Pen); Pen<Color> pen = Assert.IsType<Pen<Color>>(processor.Pen);
Assert.Equal(thickness, pen.Width); Assert.Equal(thickness, pen.Width);
SolidBrush<Color32> brush = Assert.IsType<SolidBrush<Color32>>(pen.Brush); SolidBrush<Color> brush = Assert.IsType<SolidBrush<Color>>(pen.Brush);
Assert.Equal(color, brush.Color); Assert.Equal(color, brush.Color);
} }
@ -129,7 +129,7 @@ namespace ImageSharp.Tests.Drawing.Paths
img.DrawPolygon(pen, points); img.DrawPolygon(pen, points);
Assert.NotEmpty(img.ProcessorApplications); Assert.NotEmpty(img.ProcessorApplications);
DrawPathProcessor<Color32> processor = Assert.IsType<DrawPathProcessor<Color32>>(img.ProcessorApplications[0].processor); DrawPathProcessor<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor);
Assert.Equal(GraphicsOptions.Default, processor.Options); Assert.Equal(GraphicsOptions.Default, processor.Options);
@ -147,7 +147,7 @@ namespace ImageSharp.Tests.Drawing.Paths
img.DrawPolygon(pen, points, noneDefault); img.DrawPolygon(pen, points, noneDefault);
Assert.NotEmpty(img.ProcessorApplications); Assert.NotEmpty(img.ProcessorApplications);
DrawPathProcessor<Color32> processor = Assert.IsType<DrawPathProcessor<Color32>>(img.ProcessorApplications[0].processor); DrawPathProcessor<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor);
Assert.Equal(noneDefault, processor.Options); 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; float thickness = 7.2f;
GraphicsOptions noneDefault = new GraphicsOptions(); GraphicsOptions noneDefault = new GraphicsOptions();
Color32 color = Color32.HotPink; Color color = Color.HotPink;
SolidBrush brush = Brushes.Solid(Color32.HotPink); SolidBrush brush = Brushes.Solid(Color.HotPink);
Pen pen = new Pen(Color32.Gray, 99.9f); Pen pen = new Pen(Color.Gray, 99.9f);
ImageSharp.Rectangle rectangle = new ImageSharp.Rectangle(10, 10, 98, 324); ImageSharp.Rectangle rectangle = new ImageSharp.Rectangle(10, 10, 98, 324);
private ProcessorWatchingImage img; private ProcessorWatchingImage img;
@ -41,7 +41,7 @@ namespace ImageSharp.Tests.Drawing.Paths
img.Draw(brush, thickness, rectangle); img.Draw(brush, thickness, rectangle);
Assert.NotEmpty(img.ProcessorApplications); Assert.NotEmpty(img.ProcessorApplications);
DrawPathProcessor<Color32> processor = Assert.IsType<DrawPathProcessor<Color32>>(img.ProcessorApplications[0].processor); DrawPathProcessor<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor);
Assert.Equal(GraphicsOptions.Default, processor.Options); 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.Width, rectangle.Width);
Assert.Equal(rect.Size.Height, rectangle.Height); Assert.Equal(rect.Size.Height, rectangle.Height);
Pen<Color32> pen = Assert.IsType<Pen<Color32>>(processor.Pen); Pen<Color> pen = Assert.IsType<Pen<Color>>(processor.Pen);
Assert.Equal(brush, pen.Brush); Assert.Equal(brush, pen.Brush);
Assert.Equal(thickness, pen.Width); Assert.Equal(thickness, pen.Width);
} }
@ -64,7 +64,7 @@ namespace ImageSharp.Tests.Drawing.Paths
img.Draw(brush, thickness, rectangle, noneDefault); img.Draw(brush, thickness, rectangle, noneDefault);
Assert.NotEmpty(img.ProcessorApplications); Assert.NotEmpty(img.ProcessorApplications);
DrawPathProcessor<Color32> processor = Assert.IsType<DrawPathProcessor<Color32>>(img.ProcessorApplications[0].processor); DrawPathProcessor<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor);
Assert.Equal(noneDefault, processor.Options); 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.Width, rectangle.Width);
Assert.Equal(rect.Size.Height, rectangle.Height); Assert.Equal(rect.Size.Height, rectangle.Height);
Pen<Color32> pen = Assert.IsType<Pen<Color32>>(processor.Pen); Pen<Color> pen = Assert.IsType<Pen<Color>>(processor.Pen);
Assert.Equal(brush, pen.Brush); Assert.Equal(brush, pen.Brush);
Assert.Equal(thickness, pen.Width); Assert.Equal(thickness, pen.Width);
} }
@ -88,7 +88,7 @@ namespace ImageSharp.Tests.Drawing.Paths
img.Draw(color, thickness, rectangle); img.Draw(color, thickness, rectangle);
Assert.NotEmpty(img.ProcessorApplications); Assert.NotEmpty(img.ProcessorApplications);
DrawPathProcessor<Color32> processor = Assert.IsType<DrawPathProcessor<Color32>>(img.ProcessorApplications[0].processor); DrawPathProcessor<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor);
Assert.Equal(GraphicsOptions.Default, processor.Options); 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.Width, rectangle.Width);
Assert.Equal(rect.Size.Height, rectangle.Height); Assert.Equal(rect.Size.Height, rectangle.Height);
Pen<Color32> pen = Assert.IsType<Pen<Color32>>(processor.Pen); Pen<Color> pen = Assert.IsType<Pen<Color>>(processor.Pen);
Assert.Equal(thickness, pen.Width); Assert.Equal(thickness, pen.Width);
SolidBrush<Color32> brush = Assert.IsType<SolidBrush<Color32>>(pen.Brush); SolidBrush<Color> brush = Assert.IsType<SolidBrush<Color>>(pen.Brush);
Assert.Equal(color, brush.Color); Assert.Equal(color, brush.Color);
} }
@ -114,7 +114,7 @@ namespace ImageSharp.Tests.Drawing.Paths
img.Draw(color, thickness, rectangle, noneDefault); img.Draw(color, thickness, rectangle, noneDefault);
Assert.NotEmpty(img.ProcessorApplications); Assert.NotEmpty(img.ProcessorApplications);
DrawPathProcessor<Color32> processor = Assert.IsType<DrawPathProcessor<Color32>>(img.ProcessorApplications[0].processor); DrawPathProcessor<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor);
Assert.Equal(noneDefault, processor.Options); 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.Width, rectangle.Width);
Assert.Equal(rect.Size.Height, rectangle.Height); Assert.Equal(rect.Size.Height, rectangle.Height);
Pen<Color32> pen = Assert.IsType<Pen<Color32>>(processor.Pen); Pen<Color> pen = Assert.IsType<Pen<Color>>(processor.Pen);
Assert.Equal(thickness, pen.Width); Assert.Equal(thickness, pen.Width);
SolidBrush<Color32> brush = Assert.IsType<SolidBrush<Color32>>(pen.Brush); SolidBrush<Color> brush = Assert.IsType<SolidBrush<Color>>(pen.Brush);
Assert.Equal(color, brush.Color); Assert.Equal(color, brush.Color);
} }
@ -140,7 +140,7 @@ namespace ImageSharp.Tests.Drawing.Paths
img.Draw(pen, rectangle); img.Draw(pen, rectangle);
Assert.NotEmpty(img.ProcessorApplications); Assert.NotEmpty(img.ProcessorApplications);
DrawPathProcessor<Color32> processor = Assert.IsType<DrawPathProcessor<Color32>>(img.ProcessorApplications[0].processor); DrawPathProcessor<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor);
Assert.Equal(GraphicsOptions.Default, processor.Options); Assert.Equal(GraphicsOptions.Default, processor.Options);
@ -162,7 +162,7 @@ namespace ImageSharp.Tests.Drawing.Paths
img.Draw(pen, rectangle, noneDefault); img.Draw(pen, rectangle, noneDefault);
Assert.NotEmpty(img.ProcessorApplications); Assert.NotEmpty(img.ProcessorApplications);
DrawPathProcessor<Color32> processor = Assert.IsType<DrawPathProcessor<Color32>>(img.ProcessorApplications[0].processor); DrawPathProcessor<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor);
Assert.Equal(noneDefault, processor.Options); 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 public class FillPath : IDisposable
{ {
GraphicsOptions noneDefault = new GraphicsOptions(); GraphicsOptions noneDefault = new GraphicsOptions();
Color32 color = Color32.HotPink; Color color = Color.HotPink;
SolidBrush brush = Brushes.Solid(Color32.HotPink); SolidBrush brush = Brushes.Solid(Color.HotPink);
IPath path = new SixLabors.Shapes.Path(new LinearLineSegment(new Vector2[] { IPath path = new SixLabors.Shapes.Path(new LinearLineSegment(new Vector2[] {
new Vector2(10,10), new Vector2(10,10),
new Vector2(20,10), new Vector2(20,10),
@ -43,7 +43,7 @@ namespace ImageSharp.Tests.Drawing.Paths
img.Fill(brush, path); img.Fill(brush, path);
Assert.NotEmpty(img.ProcessorApplications); Assert.NotEmpty(img.ProcessorApplications);
FillRegionProcessor<Color32> processor = Assert.IsType<FillRegionProcessor<Color32>>(img.ProcessorApplications[0].processor); FillRegionProcessor<Color> processor = Assert.IsType<FillRegionProcessor<Color>>(img.ProcessorApplications[0].processor);
Assert.Equal(GraphicsOptions.Default, processor.Options); Assert.Equal(GraphicsOptions.Default, processor.Options);
@ -62,7 +62,7 @@ namespace ImageSharp.Tests.Drawing.Paths
img.Fill(brush, path, noneDefault); img.Fill(brush, path, noneDefault);
Assert.NotEmpty(img.ProcessorApplications); Assert.NotEmpty(img.ProcessorApplications);
FillRegionProcessor<Color32> processor = Assert.IsType<FillRegionProcessor<Color32>>(img.ProcessorApplications[0].processor); FillRegionProcessor<Color> processor = Assert.IsType<FillRegionProcessor<Color>>(img.ProcessorApplications[0].processor);
Assert.Equal(noneDefault, processor.Options); Assert.Equal(noneDefault, processor.Options);
@ -79,7 +79,7 @@ namespace ImageSharp.Tests.Drawing.Paths
img.Fill(color, path); img.Fill(color, path);
Assert.NotEmpty(img.ProcessorApplications); Assert.NotEmpty(img.ProcessorApplications);
FillRegionProcessor<Color32> processor = Assert.IsType<FillRegionProcessor<Color32>>(img.ProcessorApplications[0].processor); FillRegionProcessor<Color> processor = Assert.IsType<FillRegionProcessor<Color>>(img.ProcessorApplications[0].processor);
Assert.Equal(GraphicsOptions.Default, processor.Options); Assert.Equal(GraphicsOptions.Default, processor.Options);
@ -87,7 +87,7 @@ namespace ImageSharp.Tests.Drawing.Paths
Polygon polygon = Assert.IsType<Polygon>(region.Shape); Polygon polygon = Assert.IsType<Polygon>(region.Shape);
LinearLineSegment segments = Assert.IsType<LinearLineSegment>(polygon.LineSegments[0]); LinearLineSegment segments = Assert.IsType<LinearLineSegment>(polygon.LineSegments[0]);
SolidBrush<Color32> brush = Assert.IsType<SolidBrush<Color32>>(processor.Brush); SolidBrush<Color> brush = Assert.IsType<SolidBrush<Color>>(processor.Brush);
Assert.Equal(color, brush.Color); Assert.Equal(color, brush.Color);
} }
@ -97,7 +97,7 @@ namespace ImageSharp.Tests.Drawing.Paths
img.Fill(color, path, noneDefault); img.Fill(color, path, noneDefault);
Assert.NotEmpty(img.ProcessorApplications); Assert.NotEmpty(img.ProcessorApplications);
FillRegionProcessor<Color32> processor = Assert.IsType<FillRegionProcessor<Color32>>(img.ProcessorApplications[0].processor); FillRegionProcessor<Color> processor = Assert.IsType<FillRegionProcessor<Color>>(img.ProcessorApplications[0].processor);
Assert.Equal(noneDefault, processor.Options); Assert.Equal(noneDefault, processor.Options);
@ -105,7 +105,7 @@ namespace ImageSharp.Tests.Drawing.Paths
Polygon polygon = Assert.IsType<Polygon>(region.Shape); Polygon polygon = Assert.IsType<Polygon>(region.Shape);
LinearLineSegment segments = Assert.IsType<LinearLineSegment>(polygon.LineSegments[0]); LinearLineSegment segments = Assert.IsType<LinearLineSegment>(polygon.LineSegments[0]);
SolidBrush<Color32> brush = Assert.IsType<SolidBrush<Color32>>(processor.Brush); SolidBrush<Color> brush = Assert.IsType<SolidBrush<Color>>(processor.Brush);
Assert.Equal(color, brush.Color); 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 public class FillPolygon : IDisposable
{ {
GraphicsOptions noneDefault = new GraphicsOptions(); GraphicsOptions noneDefault = new GraphicsOptions();
Color32 color = Color32.HotPink; Color color = Color.HotPink;
SolidBrush brush = Brushes.Solid(Color32.HotPink); SolidBrush brush = Brushes.Solid(Color.HotPink);
Vector2[] path = new Vector2[] { Vector2[] path = new Vector2[] {
new Vector2(10,10), new Vector2(10,10),
new Vector2(20,10), new Vector2(20,10),
@ -43,7 +43,7 @@ namespace ImageSharp.Tests.Drawing.Paths
img.FillPolygon(brush, path); img.FillPolygon(brush, path);
Assert.NotEmpty(img.ProcessorApplications); Assert.NotEmpty(img.ProcessorApplications);
FillRegionProcessor<Color32> processor = Assert.IsType<FillRegionProcessor<Color32>>(img.ProcessorApplications[0].processor); FillRegionProcessor<Color> processor = Assert.IsType<FillRegionProcessor<Color>>(img.ProcessorApplications[0].processor);
Assert.Equal(GraphicsOptions.Default, processor.Options); Assert.Equal(GraphicsOptions.Default, processor.Options);
@ -60,7 +60,7 @@ namespace ImageSharp.Tests.Drawing.Paths
img.FillPolygon(brush, path, noneDefault); img.FillPolygon(brush, path, noneDefault);
Assert.NotEmpty(img.ProcessorApplications); Assert.NotEmpty(img.ProcessorApplications);
FillRegionProcessor<Color32> processor = Assert.IsType<FillRegionProcessor<Color32>>(img.ProcessorApplications[0].processor); FillRegionProcessor<Color> processor = Assert.IsType<FillRegionProcessor<Color>>(img.ProcessorApplications[0].processor);
Assert.Equal(noneDefault, processor.Options); Assert.Equal(noneDefault, processor.Options);
@ -77,7 +77,7 @@ namespace ImageSharp.Tests.Drawing.Paths
img.FillPolygon(color, path); img.FillPolygon(color, path);
Assert.NotEmpty(img.ProcessorApplications); Assert.NotEmpty(img.ProcessorApplications);
FillRegionProcessor<Color32> processor = Assert.IsType<FillRegionProcessor<Color32>>(img.ProcessorApplications[0].processor); FillRegionProcessor<Color> processor = Assert.IsType<FillRegionProcessor<Color>>(img.ProcessorApplications[0].processor);
Assert.Equal(GraphicsOptions.Default, processor.Options); Assert.Equal(GraphicsOptions.Default, processor.Options);
@ -85,7 +85,7 @@ namespace ImageSharp.Tests.Drawing.Paths
Polygon polygon = Assert.IsType<Polygon>(region.Shape); Polygon polygon = Assert.IsType<Polygon>(region.Shape);
LinearLineSegment segemnt = Assert.IsType<LinearLineSegment>(polygon.LineSegments[0]); LinearLineSegment segemnt = Assert.IsType<LinearLineSegment>(polygon.LineSegments[0]);
SolidBrush<Color32> brush = Assert.IsType<SolidBrush<Color32>>(processor.Brush); SolidBrush<Color> brush = Assert.IsType<SolidBrush<Color>>(processor.Brush);
Assert.Equal(color, brush.Color); Assert.Equal(color, brush.Color);
} }
@ -95,7 +95,7 @@ namespace ImageSharp.Tests.Drawing.Paths
img.FillPolygon(color, path, noneDefault); img.FillPolygon(color, path, noneDefault);
Assert.NotEmpty(img.ProcessorApplications); Assert.NotEmpty(img.ProcessorApplications);
FillRegionProcessor<Color32> processor = Assert.IsType<FillRegionProcessor<Color32>>(img.ProcessorApplications[0].processor); FillRegionProcessor<Color> processor = Assert.IsType<FillRegionProcessor<Color>>(img.ProcessorApplications[0].processor);
Assert.Equal(noneDefault, processor.Options); Assert.Equal(noneDefault, processor.Options);
@ -103,7 +103,7 @@ namespace ImageSharp.Tests.Drawing.Paths
Polygon polygon = Assert.IsType<Polygon>(region.Shape); Polygon polygon = Assert.IsType<Polygon>(region.Shape);
LinearLineSegment segemnt = Assert.IsType<LinearLineSegment>(polygon.LineSegments[0]); LinearLineSegment segemnt = Assert.IsType<LinearLineSegment>(polygon.LineSegments[0]);
SolidBrush<Color32> brush = Assert.IsType<SolidBrush<Color32>>(processor.Brush); SolidBrush<Color> brush = Assert.IsType<SolidBrush<Color>>(processor.Brush);
Assert.Equal(color, brush.Color); 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 public class FillRectangle : IDisposable
{ {
GraphicsOptions noneDefault = new GraphicsOptions(); GraphicsOptions noneDefault = new GraphicsOptions();
Color32 color = Color32.HotPink; Color color = Color.HotPink;
SolidBrush brush = Brushes.Solid(Color32.HotPink); SolidBrush brush = Brushes.Solid(Color.HotPink);
ImageSharp.Rectangle rectangle = new ImageSharp.Rectangle(10, 10, 77, 76); ImageSharp.Rectangle rectangle = new ImageSharp.Rectangle(10, 10, 77, 76);
private ProcessorWatchingImage img; private ProcessorWatchingImage img;
@ -39,7 +39,7 @@ namespace ImageSharp.Tests.Drawing.Paths
img.Fill(brush, rectangle); img.Fill(brush, rectangle);
Assert.NotEmpty(img.ProcessorApplications); Assert.NotEmpty(img.ProcessorApplications);
FillRegionProcessor<Color32> processor = Assert.IsType<FillRegionProcessor<Color32>>(img.ProcessorApplications[0].processor); FillRegionProcessor<Color> processor = Assert.IsType<FillRegionProcessor<Color>>(img.ProcessorApplications[0].processor);
Assert.Equal(GraphicsOptions.Default, processor.Options); Assert.Equal(GraphicsOptions.Default, processor.Options);
@ -59,7 +59,7 @@ namespace ImageSharp.Tests.Drawing.Paths
img.Fill(brush, rectangle, noneDefault); img.Fill(brush, rectangle, noneDefault);
Assert.NotEmpty(img.ProcessorApplications); Assert.NotEmpty(img.ProcessorApplications);
FillRegionProcessor<Color32> processor = Assert.IsType<FillRegionProcessor<Color32>>(img.ProcessorApplications[0].processor); FillRegionProcessor<Color> processor = Assert.IsType<FillRegionProcessor<Color>>(img.ProcessorApplications[0].processor);
Assert.Equal(noneDefault, processor.Options); Assert.Equal(noneDefault, processor.Options);
@ -79,7 +79,7 @@ namespace ImageSharp.Tests.Drawing.Paths
img.Fill(color, rectangle); img.Fill(color, rectangle);
Assert.NotEmpty(img.ProcessorApplications); Assert.NotEmpty(img.ProcessorApplications);
FillRegionProcessor<Color32> processor = Assert.IsType<FillRegionProcessor<Color32>>(img.ProcessorApplications[0].processor); FillRegionProcessor<Color> processor = Assert.IsType<FillRegionProcessor<Color>>(img.ProcessorApplications[0].processor);
Assert.Equal(GraphicsOptions.Default, processor.Options); 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.Width, rectangle.Width);
Assert.Equal(rect.Size.Height, rectangle.Height); Assert.Equal(rect.Size.Height, rectangle.Height);
SolidBrush<Color32> brush = Assert.IsType<SolidBrush<Color32>>(processor.Brush); SolidBrush<Color> brush = Assert.IsType<SolidBrush<Color>>(processor.Brush);
Assert.Equal(color, brush.Color); Assert.Equal(color, brush.Color);
} }
@ -100,7 +100,7 @@ namespace ImageSharp.Tests.Drawing.Paths
img.Fill(color, rectangle, noneDefault); img.Fill(color, rectangle, noneDefault);
Assert.NotEmpty(img.ProcessorApplications); Assert.NotEmpty(img.ProcessorApplications);
FillRegionProcessor<Color32> processor = Assert.IsType<FillRegionProcessor<Color32>>(img.ProcessorApplications[0].processor); FillRegionProcessor<Color> processor = Assert.IsType<FillRegionProcessor<Color>>(img.ProcessorApplications[0].processor);
Assert.Equal(noneDefault, processor.Options); 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.Width, rectangle.Width);
Assert.Equal(rect.Size.Height, rectangle.Height); Assert.Equal(rect.Size.Height, rectangle.Height);
SolidBrush<Color32> brush = Assert.IsType<SolidBrush<Color32>>(processor.Brush); SolidBrush<Color> brush = Assert.IsType<SolidBrush<Color>>(processor.Brush);
Assert.Equal(color, brush.Color); Assert.Equal(color, brush.Color);
} }
} }

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

@ -11,8 +11,8 @@ namespace ImageSharp.Tests.Drawing.Paths
/// <summary> /// <summary>
/// Watches but does not actually run the processors against the image. /// Watches but does not actually run the processors against the image.
/// </summary> /// </summary>
/// <seealso cref="ImageSharp.Image{ImageSharp.Color32}" /> /// <seealso cref="ImageSharp.Image{ImageSharp.Color}" />
public class ProcessorWatchingImage : Image<Color32> public class ProcessorWatchingImage : Image<Color>
{ {
public List<ProcessorDetails> ProcessorApplications { get; } = new List<ProcessorDetails>(); public List<ProcessorDetails> ProcessorApplications { get; } = new List<ProcessorDetails>();
@ -21,7 +21,7 @@ namespace ImageSharp.Tests.Drawing.Paths
{ {
} }
public override void ApplyProcessor(IImageProcessor<Color32> processor, Rectangle rectangle) public override void ApplyProcessor(IImageProcessor<Color> processor, Rectangle rectangle)
{ {
this.ProcessorApplications.Add(new ProcessorDetails this.ProcessorApplications.Add(new ProcessorDetails
{ {
@ -32,7 +32,7 @@ namespace ImageSharp.Tests.Drawing.Paths
public struct ProcessorDetails public struct ProcessorDetails
{ {
public IImageProcessor<Color32> processor; public IImageProcessor<Color> processor;
public Rectangle rectangle; 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")) using (FileStream output = File.OpenWrite($"{path}/Simple.png"))
{ {
image image
.BackgroundColor(Color32.Blue) .BackgroundColor(Color.Blue)
.DrawPolygon(Color32.HotPink, 5, .DrawPolygon(Color.HotPink, 5,
new[] { new[] {
new Vector2(10, 10), new Vector2(10, 10),
new Vector2(200, 150), new Vector2(200, 150),
@ -35,15 +35,15 @@ namespace ImageSharp.Tests.Drawing
.Save(output); .Save(output);
} }
using (PixelAccessor<Color32> sourcePixels = image.Lock()) using (PixelAccessor<Color> sourcePixels = image.Lock())
{ {
Assert.Equal(Color32.HotPink, sourcePixels[9, 9]); Assert.Equal(Color.HotPink, sourcePixels[9, 9]);
Assert.Equal(Color32.HotPink, sourcePixels[199, 149]); Assert.Equal(Color.HotPink, sourcePixels[199, 149]);
Assert.Equal(Color32.Blue, sourcePixels[50, 50]); Assert.Equal(Color.Blue, sourcePixels[50, 50]);
Assert.Equal(Color32.Blue, sourcePixels[2, 2]); Assert.Equal(Color.Blue, sourcePixels[2, 2]);
} }
} }
} }
@ -58,30 +58,30 @@ namespace ImageSharp.Tests.Drawing
new Vector2(50, 300) new Vector2(50, 300)
}; };
Color32 color = new Color32(Color32.HotPink.R, Color32.HotPink.G, Color32.HotPink.B, 150); Color color = new Color(Color.HotPink.R, Color.HotPink.G, Color.HotPink.B, 150);
using (Image image = new Image(500, 500)) using (Image image = new Image(500, 500))
{ {
using (FileStream output = File.OpenWrite($"{path}/Opacity.png")) using (FileStream output = File.OpenWrite($"{path}/Opacity.png"))
{ {
image image
.BackgroundColor(Color32.Blue) .BackgroundColor(Color.Blue)
.DrawPolygon(color, 10, simplePath) .DrawPolygon(color, 10, simplePath)
.Save(output); .Save(output);
} }
//shift background color towards forground color by the opacity amount //shift background color towards forground color by the opacity amount
Color32 mergedColor = new Color32(Vector4.Lerp(Color32.Blue.ToVector4(), Color32.HotPink.ToVector4(), 150f / 255f)); Color mergedColor = new Color(Vector4.Lerp(Color.Blue.ToVector4(), Color.HotPink.ToVector4(), 150f / 255f));
using (PixelAccessor<Color32> sourcePixels = image.Lock()) using (PixelAccessor<Color> sourcePixels = image.Lock())
{ {
Assert.Equal(mergedColor, sourcePixels[9, 9]); Assert.Equal(mergedColor, sourcePixels[9, 9]);
Assert.Equal(mergedColor, sourcePixels[199, 149]); Assert.Equal(mergedColor, sourcePixels[199, 149]);
Assert.Equal(Color32.Blue, sourcePixels[50, 50]); Assert.Equal(Color.Blue, sourcePixels[50, 50]);
Assert.Equal(Color32.Blue, sourcePixels[2, 2]); Assert.Equal(Color.Blue, sourcePixels[2, 2]);
} }
} }
} }
@ -96,22 +96,22 @@ namespace ImageSharp.Tests.Drawing
using (FileStream output = File.OpenWrite($"{path}/Rectangle.png")) using (FileStream output = File.OpenWrite($"{path}/Rectangle.png"))
{ {
image image
.BackgroundColor(Color32.Blue) .BackgroundColor(Color.Blue)
.Draw(Color32.HotPink, 10, new Rectangle(10, 10, 190, 140)) .Draw(Color.HotPink, 10, new Rectangle(10, 10, 190, 140))
.Save(output); .Save(output);
} }
using (PixelAccessor<Color32> sourcePixels = image.Lock()) using (PixelAccessor<Color> sourcePixels = image.Lock())
{ {
Assert.Equal(Color32.HotPink, sourcePixels[8, 8]); Assert.Equal(Color.HotPink, sourcePixels[8, 8]);
Assert.Equal(Color32.HotPink, sourcePixels[198, 10]); Assert.Equal(Color.HotPink, sourcePixels[198, 10]);
Assert.Equal(Color32.HotPink, sourcePixels[10, 50]); Assert.Equal(Color.HotPink, sourcePixels[10, 50]);
Assert.Equal(Color32.Blue, sourcePixels[50, 50]); Assert.Equal(Color.Blue, sourcePixels[50, 50]);
Assert.Equal(Color32.Blue, sourcePixels[2, 2]); Assert.Equal(Color.Blue, sourcePixels[2, 2]);
} }
} }
} }

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

@ -18,7 +18,7 @@ namespace ImageSharp.Tests
{ {
string path = this.CreateOutputDirectory("Drawing", "RecolorImage"); string path = this.CreateOutputDirectory("Drawing", "RecolorImage");
RecolorBrush brush = new RecolorBrush(Color32.Yellow, Color32.HotPink, 0.2f); RecolorBrush brush = new RecolorBrush(Color.Yellow, Color.HotPink, 0.2f);
foreach (TestFile file in Files) foreach (TestFile file in Files)
{ {
@ -38,7 +38,7 @@ namespace ImageSharp.Tests
{ {
string path = this.CreateOutputDirectory("Drawing", "RecolorImage"); string path = this.CreateOutputDirectory("Drawing", "RecolorImage");
RecolorBrush brush = new RecolorBrush(Color32.Yellow, Color32.HotPink, 0.2f); RecolorBrush brush = new RecolorBrush(Color.Yellow, Color.HotPink, 0.2f);
foreach (TestFile file in Files) 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")) using (FileStream output = File.OpenWrite($"{path}/Simple.png"))
{ {
image image
.BackgroundColor(Color32.Blue) .BackgroundColor(Color.Blue)
.Fill(Color32.HotPink, new Polygon(new BezierLineSegment(simplePath))) .Fill(Color.HotPink, new Polygon(new BezierLineSegment(simplePath)))
.Save(output); .Save(output);
} }
using (PixelAccessor<Color32> sourcePixels = image.Lock()) using (PixelAccessor<Color> sourcePixels = image.Lock())
{ {
Assert.Equal(Color32.HotPink, sourcePixels[150, 300]); Assert.Equal(Color.HotPink, sourcePixels[150, 300]);
//curve points should not be never be set //curve points should not be never be set
Assert.Equal(Color32.Blue, sourcePixels[240, 30]); Assert.Equal(Color.Blue, sourcePixels[240, 30]);
// inside shape should not be empty // inside shape should not be empty
Assert.Equal(Color32.HotPink, sourcePixels[200, 250]); Assert.Equal(Color.HotPink, sourcePixels[200, 250]);
} }
} }
} }
@ -57,28 +57,28 @@ namespace ImageSharp.Tests.Drawing
new Vector2(240, 30), new Vector2(240, 30),
new Vector2(300, 400) new Vector2(300, 400)
}; };
Color32 color = new Color32(Color32.HotPink.R, Color32.HotPink.G, Color32.HotPink.B, 150); Color color = new Color(Color.HotPink.R, Color.HotPink.G, Color.HotPink.B, 150);
using (Image image = new Image(500, 500)) using (Image image = new Image(500, 500))
{ {
using (FileStream output = File.OpenWrite($"{path}/Opacity.png")) using (FileStream output = File.OpenWrite($"{path}/Opacity.png"))
{ {
image image
.BackgroundColor(Color32.Blue) .BackgroundColor(Color.Blue)
.Fill(color, new Polygon(new BezierLineSegment(simplePath))) .Fill(color, new Polygon(new BezierLineSegment(simplePath)))
.Save(output); .Save(output);
} }
//shift background color towards forground color by the opacity amount //shift background color towards forground color by the opacity amount
Color32 mergedColor = new Color32(Vector4.Lerp(Color32.Blue.ToVector4(), Color32.HotPink.ToVector4(), 150f / 255f)); Color mergedColor = new Color(Vector4.Lerp(Color.Blue.ToVector4(), Color.HotPink.ToVector4(), 150f / 255f));
using (PixelAccessor<Color32> sourcePixels = image.Lock()) using (PixelAccessor<Color> sourcePixels = image.Lock())
{ {
//top of curve //top of curve
Assert.Equal(mergedColor, sourcePixels[138, 116]); Assert.Equal(mergedColor, sourcePixels[138, 116]);
//curve points should not be never be set //curve points should not be never be set
Assert.Equal(Color32.Blue, sourcePixels[240, 30]); Assert.Equal(Color.Blue, sourcePixels[240, 30]);
// inside shape should not be empty // inside shape should not be empty
Assert.Equal(mergedColor, sourcePixels[200, 250]); 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")) using (FileStream output = File.OpenWrite($"{path}/Simple.png"))
{ {
image image
.BackgroundColor(Color32.Blue) .BackgroundColor(Color.Blue)
.Fill(Color32.HotPink, clipped) .Fill(Color.HotPink, clipped)
.Save(output); .Save(output);
} }
using (PixelAccessor<Color32> sourcePixels = image.Lock()) using (PixelAccessor<Color> sourcePixels = image.Lock())
{ {
Assert.Equal(Color32.HotPink, sourcePixels[20, 35]); Assert.Equal(Color.HotPink, sourcePixels[20, 35]);
//inside hole //inside hole
Assert.Equal(Color32.Blue, sourcePixels[60, 100]); Assert.Equal(Color.Blue, sourcePixels[60, 100]);
} }
} }
} }
@ -70,17 +70,17 @@ namespace ImageSharp.Tests.Drawing
using (FileStream output = File.OpenWrite($"{path}/SimpleOverlapping.png")) using (FileStream output = File.OpenWrite($"{path}/SimpleOverlapping.png"))
{ {
image image
.BackgroundColor(Color32.Blue) .BackgroundColor(Color.Blue)
.Fill(Color32.HotPink, simplePath.Clip(hole1)) .Fill(Color.HotPink, simplePath.Clip(hole1))
.Save(output); .Save(output);
} }
using (PixelAccessor<Color32> sourcePixels = image.Lock()) using (PixelAccessor<Color> sourcePixels = image.Lock())
{ {
Assert.Equal(Color32.HotPink, sourcePixels[20, 35]); Assert.Equal(Color.HotPink, sourcePixels[20, 35]);
//inside hole //inside hole
Assert.Equal(Color32.Blue, sourcePixels[60, 100]); Assert.Equal(Color.Blue, sourcePixels[60, 100]);
} }
} }
} }
@ -98,27 +98,27 @@ namespace ImageSharp.Tests.Drawing
new Vector2(37, 85), new Vector2(37, 85),
new Vector2(93, 85), new Vector2(93, 85),
new Vector2(65, 137))); new Vector2(65, 137)));
Color32 color = new Color32(Color32.HotPink.R, Color32.HotPink.G, Color32.HotPink.B, 150); Color color = new Color(Color.HotPink.R, Color.HotPink.G, Color.HotPink.B, 150);
using (Image image = new Image(500, 500)) using (Image image = new Image(500, 500))
{ {
using (FileStream output = File.OpenWrite($"{path}/Opacity.png")) using (FileStream output = File.OpenWrite($"{path}/Opacity.png"))
{ {
image image
.BackgroundColor(Color32.Blue) .BackgroundColor(Color.Blue)
.Fill(color, simplePath.Clip(hole1)) .Fill(color, simplePath.Clip(hole1))
.Save(output); .Save(output);
} }
//shift background color towards forground color by the opacity amount //shift background color towards forground color by the opacity amount
Color32 mergedColor = new Color32(Vector4.Lerp(Color32.Blue.ToVector4(), Color32.HotPink.ToVector4(), 150f / 255f)); Color mergedColor = new Color(Vector4.Lerp(Color.Blue.ToVector4(), Color.HotPink.ToVector4(), 150f / 255f));
using (PixelAccessor<Color32> sourcePixels = image.Lock()) using (PixelAccessor<Color> sourcePixels = image.Lock())
{ {
Assert.Equal(mergedColor, sourcePixels[20, 35]); Assert.Equal(mergedColor, sourcePixels[20, 35]);
//inside hole //inside hole
Assert.Equal(Color32.Blue, sourcePixels[60, 100]); Assert.Equal(Color.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")) using (FileStream output = File.OpenWrite($"{path}/Simple.png"))
{ {
image image
.FillPolygon(Color32.HotPink, simplePath, new GraphicsOptions(true)) .FillPolygon(Color.HotPink, simplePath, new GraphicsOptions(true))
.Save(output); .Save(output);
} }
using (PixelAccessor<Color32> sourcePixels = image.Lock()) using (PixelAccessor<Color> sourcePixels = image.Lock())
{ {
Assert.Equal(Color32.HotPink, sourcePixels[81, 145]); Assert.Equal(Color.HotPink, sourcePixels[81, 145]);
} }
} }
} }
@ -58,13 +58,13 @@ namespace ImageSharp.Tests.Drawing
using (FileStream output = File.OpenWrite($"{path}/Pattern.png")) using (FileStream output = File.OpenWrite($"{path}/Pattern.png"))
{ {
image image
.FillPolygon(Brushes.Horizontal(Color32.HotPink), simplePath, new GraphicsOptions(true)) .FillPolygon(Brushes.Horizontal(Color.HotPink), simplePath, new GraphicsOptions(true))
.Save(output); .Save(output);
} }
using (PixelAccessor<Color32> sourcePixels = image.Lock()) using (PixelAccessor<Color> sourcePixels = image.Lock())
{ {
Assert.Equal(Color32.HotPink, sourcePixels[81, 145]); Assert.Equal(Color.HotPink, sourcePixels[81, 145]);
} }
} }
} }
@ -83,19 +83,19 @@ namespace ImageSharp.Tests.Drawing
using (FileStream output = File.OpenWrite($"{path}/Simple_NoAntialias.png")) using (FileStream output = File.OpenWrite($"{path}/Simple_NoAntialias.png"))
{ {
image image
.BackgroundColor(Color32.Blue) .BackgroundColor(Color.Blue)
.FillPolygon(Color32.HotPink, simplePath, new GraphicsOptions(false)) .FillPolygon(Color.HotPink, simplePath, new GraphicsOptions(false))
.Save(output); .Save(output);
using (PixelAccessor<Color32> sourcePixels = image.Lock()) using (PixelAccessor<Color> sourcePixels = image.Lock())
{ {
Assert.Equal(Color32.HotPink, sourcePixels[11, 11]); Assert.Equal(Color.HotPink, sourcePixels[11, 11]);
Assert.Equal(Color32.HotPink, sourcePixels[199, 150]); Assert.Equal(Color.HotPink, sourcePixels[199, 150]);
Assert.Equal(Color32.HotPink, sourcePixels[50, 50]); Assert.Equal(Color.HotPink, sourcePixels[50, 50]);
Assert.Equal(Color32.Blue, sourcePixels[2, 2]); Assert.Equal(Color.Blue, sourcePixels[2, 2]);
} }
} }
} }
@ -117,7 +117,7 @@ namespace ImageSharp.Tests.Drawing
ImageBrush brush = new ImageBrush(brushImage); ImageBrush brush = new ImageBrush(brushImage);
image image
.BackgroundColor(Color32.Blue) .BackgroundColor(Color.Blue)
.FillPolygon(brush, simplePath) .FillPolygon(brush, simplePath)
.Save(output); .Save(output);
} }
@ -132,24 +132,24 @@ namespace ImageSharp.Tests.Drawing
new Vector2(200, 150), new Vector2(200, 150),
new Vector2(50, 300) new Vector2(50, 300)
}; };
Color32 color = new Color32(Color32.HotPink.R, Color32.HotPink.G, Color32.HotPink.B, 150); Color color = new Color(Color.HotPink.R, Color.HotPink.G, Color.HotPink.B, 150);
using (Image image = new Image(500, 500)) using (Image image = new Image(500, 500))
{ {
using (FileStream output = File.OpenWrite($"{path}/Opacity.png")) using (FileStream output = File.OpenWrite($"{path}/Opacity.png"))
{ {
image image
.BackgroundColor(Color32.Blue) .BackgroundColor(Color.Blue)
.FillPolygon(color, simplePath) .FillPolygon(color, simplePath)
.Save(output); .Save(output);
} }
//shift background color towards forground color by the opacity amount //shift background color towards forground color by the opacity amount
Color32 mergedColor = new Color32(Vector4.Lerp(Color32.Blue.ToVector4(), Color32.HotPink.ToVector4(), 150f / 255f)); Color mergedColor = new Color(Vector4.Lerp(Color.Blue.ToVector4(), Color.HotPink.ToVector4(), 150f / 255f));
using (PixelAccessor<Color32> sourcePixels = image.Lock()) using (PixelAccessor<Color> sourcePixels = image.Lock())
{ {
Assert.Equal(Color32.Blue, sourcePixels[2, 2]); Assert.Equal(Color.Blue, sourcePixels[2, 2]);
} }
} }
} }
@ -164,22 +164,22 @@ namespace ImageSharp.Tests.Drawing
using (FileStream output = File.OpenWrite($"{path}/Rectangle.png")) using (FileStream output = File.OpenWrite($"{path}/Rectangle.png"))
{ {
image image
.BackgroundColor(Color32.Blue) .BackgroundColor(Color.Blue)
.Fill(Color32.HotPink, new SixLabors.Shapes.Rectangle(10, 10, 190, 140)) .Fill(Color.HotPink, new SixLabors.Shapes.Rectangle(10, 10, 190, 140))
.Save(output); .Save(output);
} }
using (PixelAccessor<Color32> sourcePixels = image.Lock()) using (PixelAccessor<Color> sourcePixels = image.Lock())
{ {
Assert.Equal(Color32.HotPink, sourcePixels[11, 11]); Assert.Equal(Color.HotPink, sourcePixels[11, 11]);
Assert.Equal(Color32.HotPink, sourcePixels[198, 10]); Assert.Equal(Color.HotPink, sourcePixels[198, 10]);
Assert.Equal(Color32.HotPink, sourcePixels[10, 50]); Assert.Equal(Color.HotPink, sourcePixels[10, 50]);
Assert.Equal(Color32.HotPink, sourcePixels[50, 50]); Assert.Equal(Color.HotPink, sourcePixels[50, 50]);
Assert.Equal(Color32.Blue, sourcePixels[2, 2]); Assert.Equal(Color.Blue, sourcePixels[2, 2]);
} }
} }
} }
@ -194,16 +194,16 @@ namespace ImageSharp.Tests.Drawing
using (FileStream output = File.OpenWrite($"{path}/Triangle.png")) using (FileStream output = File.OpenWrite($"{path}/Triangle.png"))
{ {
image image
.BackgroundColor(Color32.Blue) .BackgroundColor(Color.Blue)
.Fill(Color32.HotPink, new RegularPolygon(50, 50, 3, 30)) .Fill(Color.HotPink, new RegularPolygon(50, 50, 3, 30))
.Save(output); .Save(output);
} }
using (PixelAccessor<Color32> sourcePixels = image.Lock()) using (PixelAccessor<Color> sourcePixels = image.Lock())
{ {
Assert.Equal(Color32.Blue, sourcePixels[30, 65]); Assert.Equal(Color.Blue, sourcePixels[30, 65]);
Assert.Equal(Color32.HotPink, sourcePixels[50, 50]); Assert.Equal(Color.HotPink, sourcePixels[50, 50]);
} }
} }
} }
@ -220,8 +220,8 @@ namespace ImageSharp.Tests.Drawing
using (FileStream output = File.OpenWrite($"{path}/Septagon.png")) using (FileStream output = File.OpenWrite($"{path}/Septagon.png"))
{ {
image image
.BackgroundColor(Color32.Blue) .BackgroundColor(Color.Blue)
.Fill(Color32.HotPink, new RegularPolygon(50, 50, 7, 30, -(float)Math.PI)) .Fill(Color.HotPink, new RegularPolygon(50, 50, 7, 30, -(float)Math.PI))
.Save(output); .Save(output);
} }
} }
@ -239,8 +239,8 @@ namespace ImageSharp.Tests.Drawing
using (FileStream output = File.OpenWrite($"{path}/ellipse.png")) using (FileStream output = File.OpenWrite($"{path}/ellipse.png"))
{ {
image image
.BackgroundColor(Color32.Blue) .BackgroundColor(Color.Blue)
.Fill(Color32.HotPink, new Ellipse(50, 50, 30, 50) .Fill(Color.HotPink, new Ellipse(50, 50, 30, 50)
.Rotate((float)(Math.PI / 3))) .Rotate((float)(Math.PI / 3)))
.Save(output); .Save(output);
} }
@ -259,8 +259,8 @@ namespace ImageSharp.Tests.Drawing
using (FileStream output = File.OpenWrite($"{path}/clipped-corner.png")) using (FileStream output = File.OpenWrite($"{path}/clipped-corner.png"))
{ {
image image
.Fill(Color32.Blue) .Fill(Color.Blue)
.FillPolygon(Color32.HotPink, new[] .FillPolygon(Color.HotPink, new[]
{ {
new Vector2( 8, 8 ), new Vector2( 8, 8 ),
new Vector2( 64, 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 public class DrawText : IDisposable
{ {
Color32 color = Color32.HotPink; Color color = Color.HotPink;
SolidBrush brush = Brushes.Solid(Color32.HotPink); SolidBrush brush = Brushes.Solid(Color.HotPink);
IPath path = new SixLabors.Shapes.Path( IPath path = new SixLabors.Shapes.Path(
new LinearLineSegment( new LinearLineSegment(
@ -53,73 +53,73 @@ namespace ImageSharp.Tests.Drawing.Text
this.img.DrawText( this.img.DrawText(
"123", "123",
this.Font, this.Font,
Brushes.Solid(Color32.Red), Brushes.Solid(Color.Red),
null, null,
Vector2.Zero, Vector2.Zero,
new TextGraphicsOptions(true)); new TextGraphicsOptions(true));
Assert.NotEmpty(this.img.ProcessorApplications); Assert.NotEmpty(this.img.ProcessorApplications);
Assert.Equal(3, this.img.ProcessorApplications.Count); // 3 fills where applied Assert.Equal(3, this.img.ProcessorApplications.Count); // 3 fills where applied
Assert.IsType<FillRegionProcessor<Color32>>(this.img.ProcessorApplications[0].processor); Assert.IsType<FillRegionProcessor<Color>>(this.img.ProcessorApplications[0].processor);
} }
[Fact] [Fact]
public void FillsForEachACharachterWhenBrushSetAndNotPenDefaultOptions() public void FillsForEachACharachterWhenBrushSetAndNotPenDefaultOptions()
{ {
this.img.DrawText("123", this.Font, Brushes.Solid(Color32.Red), null, Vector2.Zero); this.img.DrawText("123", this.Font, Brushes.Solid(Color.Red), null, Vector2.Zero);
Assert.NotEmpty(this.img.ProcessorApplications); Assert.NotEmpty(this.img.ProcessorApplications);
Assert.Equal(3, this.img.ProcessorApplications.Count); // 3 fills where applied Assert.Equal(3, this.img.ProcessorApplications.Count); // 3 fills where applied
Assert.IsType<FillRegionProcessor<Color32>>(this.img.ProcessorApplications[0].processor); Assert.IsType<FillRegionProcessor<Color>>(this.img.ProcessorApplications[0].processor);
} }
[Fact] [Fact]
public void FillsForEachACharachterWhenBrushSet() public void FillsForEachACharachterWhenBrushSet()
{ {
this.img.DrawText("123", this.Font, Brushes.Solid(Color32.Red), Vector2.Zero, new TextGraphicsOptions(true)); this.img.DrawText("123", this.Font, Brushes.Solid(Color.Red), Vector2.Zero, new TextGraphicsOptions(true));
Assert.NotEmpty(this.img.ProcessorApplications); Assert.NotEmpty(this.img.ProcessorApplications);
Assert.Equal(3, this.img.ProcessorApplications.Count); // 3 fills where applied Assert.Equal(3, this.img.ProcessorApplications.Count); // 3 fills where applied
Assert.IsType<FillRegionProcessor<Color32>>(this.img.ProcessorApplications[0].processor); Assert.IsType<FillRegionProcessor<Color>>(this.img.ProcessorApplications[0].processor);
} }
[Fact] [Fact]
public void FillsForEachACharachterWhenBrushSetDefaultOptions() public void FillsForEachACharachterWhenBrushSetDefaultOptions()
{ {
this.img.DrawText("123", this.Font, Brushes.Solid(Color32.Red), Vector2.Zero); this.img.DrawText("123", this.Font, Brushes.Solid(Color.Red), Vector2.Zero);
Assert.NotEmpty(this.img.ProcessorApplications); Assert.NotEmpty(this.img.ProcessorApplications);
Assert.Equal(3, this.img.ProcessorApplications.Count); // 3 fills where applied Assert.Equal(3, this.img.ProcessorApplications.Count); // 3 fills where applied
Assert.IsType<FillRegionProcessor<Color32>>(this.img.ProcessorApplications[0].processor); Assert.IsType<FillRegionProcessor<Color>>(this.img.ProcessorApplications[0].processor);
} }
[Fact] [Fact]
public void FillsForEachACharachterWhenColorSet() public void FillsForEachACharachterWhenColorSet()
{ {
this.img.DrawText("123", this.Font, Color32.Red, Vector2.Zero, new TextGraphicsOptions(true)); this.img.DrawText("123", this.Font, Color.Red, Vector2.Zero, new TextGraphicsOptions(true));
Assert.NotEmpty(this.img.ProcessorApplications); Assert.NotEmpty(this.img.ProcessorApplications);
Assert.Equal(3, this.img.ProcessorApplications.Count); Assert.Equal(3, this.img.ProcessorApplications.Count);
FillRegionProcessor<Color32> processor = FillRegionProcessor<Color> processor =
Assert.IsType<FillRegionProcessor<Color32>>(this.img.ProcessorApplications[0].processor); Assert.IsType<FillRegionProcessor<Color>>(this.img.ProcessorApplications[0].processor);
SolidBrush<Color32> brush = Assert.IsType<SolidBrush<Color32>>(processor.Brush); SolidBrush<Color> brush = Assert.IsType<SolidBrush<Color>>(processor.Brush);
Assert.Equal(Color32.Red, brush.Color); Assert.Equal(Color.Red, brush.Color);
} }
[Fact] [Fact]
public void FillsForEachACharachterWhenColorSetDefaultOptions() public void FillsForEachACharachterWhenColorSetDefaultOptions()
{ {
this.img.DrawText("123", this.Font, Color32.Red, Vector2.Zero); this.img.DrawText("123", this.Font, Color.Red, Vector2.Zero);
Assert.NotEmpty(this.img.ProcessorApplications); Assert.NotEmpty(this.img.ProcessorApplications);
Assert.Equal(3, this.img.ProcessorApplications.Count); Assert.Equal(3, this.img.ProcessorApplications.Count);
Assert.IsType<FillRegionProcessor<Color32>>(this.img.ProcessorApplications[0].processor); Assert.IsType<FillRegionProcessor<Color>>(this.img.ProcessorApplications[0].processor);
FillRegionProcessor<Color32> processor = FillRegionProcessor<Color> processor =
Assert.IsType<FillRegionProcessor<Color32>>(this.img.ProcessorApplications[0].processor); Assert.IsType<FillRegionProcessor<Color>>(this.img.ProcessorApplications[0].processor);
SolidBrush<Color32> brush = Assert.IsType<SolidBrush<Color32>>(processor.Brush); SolidBrush<Color> brush = Assert.IsType<SolidBrush<Color>>(processor.Brush);
Assert.Equal(Color32.Red, brush.Color); Assert.Equal(Color.Red, brush.Color);
} }
[Fact] [Fact]
@ -129,43 +129,43 @@ namespace ImageSharp.Tests.Drawing.Text
"123", "123",
this.Font, this.Font,
null, null,
Pens.Dash(Color32.Red, 1), Pens.Dash(Color.Red, 1),
Vector2.Zero, Vector2.Zero,
new TextGraphicsOptions(true)); new TextGraphicsOptions(true));
Assert.NotEmpty(this.img.ProcessorApplications); Assert.NotEmpty(this.img.ProcessorApplications);
Assert.Equal(3, this.img.ProcessorApplications.Count); // 3 fills where applied Assert.Equal(3, this.img.ProcessorApplications.Count); // 3 fills where applied
Assert.IsType<DrawPathProcessor<Color32>>(this.img.ProcessorApplications[0].processor); Assert.IsType<DrawPathProcessor<Color>>(this.img.ProcessorApplications[0].processor);
} }
[Fact] [Fact]
public void DrawForEachACharachterWhenPenSetAndNotBrushDefaultOptions() public void DrawForEachACharachterWhenPenSetAndNotBrushDefaultOptions()
{ {
this.img.DrawText("123", this.Font, null, Pens.Dash(Color32.Red, 1), Vector2.Zero); this.img.DrawText("123", this.Font, null, Pens.Dash(Color.Red, 1), Vector2.Zero);
Assert.NotEmpty(this.img.ProcessorApplications); Assert.NotEmpty(this.img.ProcessorApplications);
Assert.Equal(3, this.img.ProcessorApplications.Count); // 3 fills where applied Assert.Equal(3, this.img.ProcessorApplications.Count); // 3 fills where applied
Assert.IsType<DrawPathProcessor<Color32>>(this.img.ProcessorApplications[0].processor); Assert.IsType<DrawPathProcessor<Color>>(this.img.ProcessorApplications[0].processor);
} }
[Fact] [Fact]
public void DrawForEachACharachterWhenPenSet() public void DrawForEachACharachterWhenPenSet()
{ {
this.img.DrawText("123", this.Font, Pens.Dash(Color32.Red, 1), Vector2.Zero, new TextGraphicsOptions(true)); this.img.DrawText("123", this.Font, Pens.Dash(Color.Red, 1), Vector2.Zero, new TextGraphicsOptions(true));
Assert.NotEmpty(this.img.ProcessorApplications); Assert.NotEmpty(this.img.ProcessorApplications);
Assert.Equal(3, this.img.ProcessorApplications.Count); // 3 fills where applied Assert.Equal(3, this.img.ProcessorApplications.Count); // 3 fills where applied
Assert.IsType<DrawPathProcessor<Color32>>(this.img.ProcessorApplications[0].processor); Assert.IsType<DrawPathProcessor<Color>>(this.img.ProcessorApplications[0].processor);
} }
[Fact] [Fact]
public void DrawForEachACharachterWhenPenSetDefaultOptions() public void DrawForEachACharachterWhenPenSetDefaultOptions()
{ {
this.img.DrawText("123", this.Font, Pens.Dash(Color32.Red, 1), Vector2.Zero); this.img.DrawText("123", this.Font, Pens.Dash(Color.Red, 1), Vector2.Zero);
Assert.NotEmpty(this.img.ProcessorApplications); Assert.NotEmpty(this.img.ProcessorApplications);
Assert.Equal(3, this.img.ProcessorApplications.Count); // 3 fills where applied Assert.Equal(3, this.img.ProcessorApplications.Count); // 3 fills where applied
Assert.IsType<DrawPathProcessor<Color32>>(this.img.ProcessorApplications[0].processor); Assert.IsType<DrawPathProcessor<Color>>(this.img.ProcessorApplications[0].processor);
} }
[Fact] [Fact]
@ -174,8 +174,8 @@ namespace ImageSharp.Tests.Drawing.Text
this.img.DrawText( this.img.DrawText(
"123", "123",
this.Font, this.Font,
Brushes.Solid(Color32.Red), Brushes.Solid(Color.Red),
Pens.Dash(Color32.Red, 1), Pens.Dash(Color.Red, 1),
Vector2.Zero, Vector2.Zero,
new TextGraphicsOptions(true)); new TextGraphicsOptions(true));
@ -186,7 +186,7 @@ namespace ImageSharp.Tests.Drawing.Text
[Fact] [Fact]
public void DrawForEachACharachterWhenPenSetAndFillFroEachWhenBrushSetDefaultOptions() public void DrawForEachACharachterWhenPenSetAndFillFroEachWhenBrushSetDefaultOptions()
{ {
this.img.DrawText("123", this.Font, Brushes.Solid(Color32.Red), Pens.Dash(Color32.Red, 1), Vector2.Zero); this.img.DrawText("123", this.Font, Brushes.Solid(Color.Red), Pens.Dash(Color.Red, 1), Vector2.Zero);
Assert.NotEmpty(this.img.ProcessorApplications); Assert.NotEmpty(this.img.ProcessorApplications);
Assert.Equal(6, this.img.ProcessorApplications.Count); Assert.Equal(6, this.img.ProcessorApplications.Count);
@ -198,26 +198,26 @@ namespace ImageSharp.Tests.Drawing.Text
this.img.DrawText( this.img.DrawText(
"1", "1",
this.Font, this.Font,
Brushes.Solid(Color32.Red), Brushes.Solid(Color.Red),
Pens.Dash(Color32.Red, 1), Pens.Dash(Color.Red, 1),
Vector2.Zero, Vector2.Zero,
new TextGraphicsOptions(true)); new TextGraphicsOptions(true));
Assert.NotEmpty(this.img.ProcessorApplications); Assert.NotEmpty(this.img.ProcessorApplications);
Assert.Equal(2, this.img.ProcessorApplications.Count); Assert.Equal(2, this.img.ProcessorApplications.Count);
Assert.IsType<FillRegionProcessor<Color32>>(this.img.ProcessorApplications[0].processor); Assert.IsType<FillRegionProcessor<Color>>(this.img.ProcessorApplications[0].processor);
Assert.IsType<DrawPathProcessor<Color32>>(this.img.ProcessorApplications[1].processor); Assert.IsType<DrawPathProcessor<Color>>(this.img.ProcessorApplications[1].processor);
} }
[Fact] [Fact]
public void BrushAppliesBeforPenDefaultOptions() public void BrushAppliesBeforPenDefaultOptions()
{ {
this.img.DrawText("1", this.Font, Brushes.Solid(Color32.Red), Pens.Dash(Color32.Red, 1), Vector2.Zero); this.img.DrawText("1", this.Font, Brushes.Solid(Color.Red), Pens.Dash(Color.Red, 1), Vector2.Zero);
Assert.NotEmpty(this.img.ProcessorApplications); Assert.NotEmpty(this.img.ProcessorApplications);
Assert.Equal(2, this.img.ProcessorApplications.Count); Assert.Equal(2, this.img.ProcessorApplications.Count);
Assert.IsType<FillRegionProcessor<Color32>>(this.img.ProcessorApplications[0].processor); Assert.IsType<FillRegionProcessor<Color>>(this.img.ProcessorApplications[0].processor);
Assert.IsType<DrawPathProcessor<Color32>>(this.img.ProcessorApplications[1].processor); Assert.IsType<DrawPathProcessor<Color>>(this.img.ProcessorApplications[1].processor);
} }
[Fact] [Fact]
@ -225,19 +225,19 @@ namespace ImageSharp.Tests.Drawing.Text
{ {
this.img.MetaData.VerticalResolution = 1; this.img.MetaData.VerticalResolution = 1;
this.img.MetaData.HorizontalResolution = 1; this.img.MetaData.HorizontalResolution = 1;
this.img.DrawText("1", this.Font, Brushes.Solid(Color32.Red), Vector2.Zero, new TextGraphicsOptions(true) { this.img.DrawText("1", this.Font, Brushes.Solid(Color.Red), Vector2.Zero, new TextGraphicsOptions(true) {
UseImageResolution = false UseImageResolution = false
}); });
this.img.DrawText("1", this.Font, Brushes.Solid(Color32.Red), Vector2.Zero, new TextGraphicsOptions(true) this.img.DrawText("1", this.Font, Brushes.Solid(Color.Red), Vector2.Zero, new TextGraphicsOptions(true)
{ {
UseImageResolution = true UseImageResolution = true
}); });
Assert.NotEmpty(this.img.ProcessorApplications); Assert.NotEmpty(this.img.ProcessorApplications);
Assert.Equal(2, this.img.ProcessorApplications.Count); Assert.Equal(2, this.img.ProcessorApplications.Count);
FillRegionProcessor<Color32> ownResolution = Assert.IsType<FillRegionProcessor<Color32>>(this.img.ProcessorApplications[0].processor); FillRegionProcessor<Color> ownResolution = Assert.IsType<FillRegionProcessor<Color>>(this.img.ProcessorApplications[0].processor);
FillRegionProcessor<Color32> imgResolution = Assert.IsType<FillRegionProcessor<Color32>>(this.img.ProcessorApplications[1].processor); FillRegionProcessor<Color> imgResolution = Assert.IsType<FillRegionProcessor<Color>>(this.img.ProcessorApplications[1].processor);
ShapeRegion ownRegion = Assert.IsType<ShapeRegion>(ownResolution.Region); ShapeRegion ownRegion = Assert.IsType<ShapeRegion>(ownResolution.Region);
ShapeRegion imgRegion = Assert.IsType<ShapeRegion>(imgResolution.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 //draws 2 overlapping triangle glyphs twice 1 set on each line
using (Image img = new Image(100, 200)) using (Image img = new Image(100, 200))
{ {
img.Fill(Color32.DarkBlue) img.Fill(Color.DarkBlue)
.DrawText("AB\nAB", new Font(this.Font, 50), Color32.Red, new Vector2(0, 0)); .DrawText("AB\nAB", new Font(this.Font, 50), Color.Red, new Vector2(0, 0));
img.Save($"{this.CreateOutputDirectory("Drawing", "Text")}/AB.png"); 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 }) .Concat(new[] { TestImages.Jpeg.Baseline.Calliphora, TestImages.Jpeg.Baseline.Cmyk })
.ToArray(); .ToArray();
Image<Color32>[] testImages = Image<Color>[] testImages =
testFiles.Select( testFiles.Select(
tf => TestImageProvider<Color32>.File(tf, pixelTypeOverride: PixelTypes.StandardImageClass).GetImage()) tf => TestImageProvider<Color>.File(tf, pixelTypeOverride: PixelTypes.StandardImageClass).GetImage())
.ToArray(); .ToArray();
using (MemoryStream ms = new MemoryStream()) using (MemoryStream ms = new MemoryStream())
@ -79,7 +79,7 @@ namespace ImageSharp.Tests
this.Measure(executionCount, this.Measure(executionCount,
() => () =>
{ {
foreach (Image<Color32> img in testImages) foreach (Image<Color> img in testImages)
{ {
JpegEncoder encoder = new JpegEncoder(); JpegEncoder encoder = new JpegEncoder();
JpegEncoderOptions options = new JpegEncoderOptions { Quality = quality, Subsample = subsample }; 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 Mock<IFileSystem> fileSystem;
private readonly IDecoderOptions decoderOptions; private readonly IDecoderOptions decoderOptions;
private Image<Color32> returnImage; private Image<Color> returnImage;
private Mock<IImageDecoder> localDecoder; private Mock<IImageDecoder> localDecoder;
private Mock<IImageFormat> localFormat; private Mock<IImageFormat> localFormat;
private readonly string FilePath; 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.IsSupportedFileFormat(It.IsAny<byte[]>())).Returns(true);
this.localFormat.Setup(x => x.SupportedExtensions).Returns(new string[] { "png", "jpg" }); this.localFormat.Setup(x => x.SupportedExtensions).Returns(new string[] { "png", "jpg" });
this.localDecoder.Setup(x => x.Decode<Color32>(It.IsAny<Configuration>(), It.IsAny<Stream>(), It.IsAny<IDecoderOptions>())) this.localDecoder.Setup(x => x.Decode<Color>(It.IsAny<Configuration>(), It.IsAny<Stream>(), It.IsAny<IDecoderOptions>()))
.Callback<Configuration, Stream, IDecoderOptions>((c, s, o) => { .Callback<Configuration, Stream, IDecoderOptions>((c, s, o) => {
using (var ms = new MemoryStream()) using (var ms = new MemoryStream())
@ -103,10 +103,10 @@ namespace ImageSharp.Tests
[Fact] [Fact]
public void LoadFromStreamWithType() public void LoadFromStreamWithType()
{ {
Image<Color32> img = Image.Load<Color32>(this.DataStream); Image<Color> img = Image.Load<Color>(this.DataStream);
Assert.NotNull(img); Assert.NotNull(img);
Assert.Equal(TestFormat.GlobalTestFormat.Sample<Color32>(), img); Assert.Equal(TestFormat.GlobalTestFormat.Sample<Color>(), img);
Assert.Equal(TestFormat.GlobalTestFormat, img.CurrentImageFormat); Assert.Equal(TestFormat.GlobalTestFormat, img.CurrentImageFormat);
TestFormat.GlobalTestFormat.VerifyDecodeCall(this.Marker, null, Configuration.Default); TestFormat.GlobalTestFormat.VerifyDecodeCall(this.Marker, null, Configuration.Default);
@ -128,10 +128,10 @@ namespace ImageSharp.Tests
[Fact] [Fact]
public void LoadFromStreamWithTypeAndOptions() public void LoadFromStreamWithTypeAndOptions()
{ {
Image<Color32> img = Image.Load<Color32>(this.DataStream, this.decoderOptions); Image<Color> img = Image.Load<Color>(this.DataStream, this.decoderOptions);
Assert.NotNull(img); Assert.NotNull(img);
Assert.Equal(TestFormat.GlobalTestFormat.Sample<Color32>(), img); Assert.Equal(TestFormat.GlobalTestFormat.Sample<Color>(), img);
Assert.Equal(TestFormat.GlobalTestFormat, img.CurrentImageFormat); Assert.Equal(TestFormat.GlobalTestFormat, img.CurrentImageFormat);
TestFormat.GlobalTestFormat.VerifyDecodeCall(this.Marker, this.decoderOptions, Configuration.Default); TestFormat.GlobalTestFormat.VerifyDecodeCall(this.Marker, this.decoderOptions, Configuration.Default);
@ -147,7 +147,7 @@ namespace ImageSharp.Tests
Assert.NotNull(img); Assert.NotNull(img);
Assert.Equal(this.localFormat.Object, img.CurrentImageFormat); Assert.Equal(this.localFormat.Object, img.CurrentImageFormat);
this.localDecoder.Verify(x => x.Decode<Color32>(this.LocalConfiguration, stream, null)); this.localDecoder.Verify(x => x.Decode<Color>(this.LocalConfiguration, stream, null));
} }
@ -155,13 +155,13 @@ namespace ImageSharp.Tests
public void LoadFromStreamWithTypeAndConfig() public void LoadFromStreamWithTypeAndConfig()
{ {
Stream stream = new MemoryStream(); Stream stream = new MemoryStream();
Image<Color32> img = Image.Load<Color32>(this.LocalConfiguration, stream); Image<Color> img = Image.Load<Color>(this.LocalConfiguration, stream);
Assert.NotNull(img); Assert.NotNull(img);
Assert.Equal(this.returnImage, img); Assert.Equal(this.returnImage, img);
Assert.Equal(this.localFormat.Object, img.CurrentImageFormat); Assert.Equal(this.localFormat.Object, img.CurrentImageFormat);
this.localDecoder.Verify(x => x.Decode<Color32>(this.LocalConfiguration, stream, null)); this.localDecoder.Verify(x => x.Decode<Color>(this.LocalConfiguration, stream, null));
} }
@ -174,7 +174,7 @@ namespace ImageSharp.Tests
Assert.NotNull(img); Assert.NotNull(img);
Assert.Equal(this.localFormat.Object, img.CurrentImageFormat); Assert.Equal(this.localFormat.Object, img.CurrentImageFormat);
this.localDecoder.Verify(x => x.Decode<Color32>(this.LocalConfiguration, stream, this.decoderOptions)); this.localDecoder.Verify(x => x.Decode<Color>(this.LocalConfiguration, stream, this.decoderOptions));
} }
@ -182,13 +182,13 @@ namespace ImageSharp.Tests
public void LoadFromStreamWithTypeAndConfigAndOptions() public void LoadFromStreamWithTypeAndConfigAndOptions()
{ {
Stream stream = new MemoryStream(); Stream stream = new MemoryStream();
Image<Color32> img = Image.Load<Color32>(this.LocalConfiguration, stream, this.decoderOptions); Image<Color> img = Image.Load<Color>(this.LocalConfiguration, stream, this.decoderOptions);
Assert.NotNull(img); Assert.NotNull(img);
Assert.Equal(this.returnImage, img); Assert.Equal(this.returnImage, img);
Assert.Equal(this.localFormat.Object, img.CurrentImageFormat); Assert.Equal(this.localFormat.Object, img.CurrentImageFormat);
this.localDecoder.Verify(x => x.Decode<Color32>(this.LocalConfiguration, stream, this.decoderOptions)); this.localDecoder.Verify(x => x.Decode<Color>(this.LocalConfiguration, stream, this.decoderOptions));
} }
@ -201,18 +201,18 @@ namespace ImageSharp.Tests
Image img = Image.Load(stream, this.localDecoder.Object); Image img = Image.Load(stream, this.localDecoder.Object);
Assert.NotNull(img); Assert.NotNull(img);
this.localDecoder.Verify(x => x.Decode<Color32>(Configuration.Default, stream, null)); this.localDecoder.Verify(x => x.Decode<Color>(Configuration.Default, stream, null));
} }
[Fact] [Fact]
public void LoadFromStreamWithTypeAndDecoder() public void LoadFromStreamWithTypeAndDecoder()
{ {
Stream stream = new MemoryStream(); Stream stream = new MemoryStream();
Image<Color32> img = Image.Load<Color32>(stream, this.localDecoder.Object); Image<Color> img = Image.Load<Color>(stream, this.localDecoder.Object);
Assert.NotNull(img); Assert.NotNull(img);
Assert.Equal(this.returnImage, img); Assert.Equal(this.returnImage, img);
this.localDecoder.Verify(x => x.Decode<Color32>(Configuration.Default, stream, null)); this.localDecoder.Verify(x => x.Decode<Color>(Configuration.Default, stream, null));
} }
[Fact] [Fact]
@ -222,18 +222,18 @@ namespace ImageSharp.Tests
Image img = Image.Load(stream, this.localDecoder.Object, this.decoderOptions); Image img = Image.Load(stream, this.localDecoder.Object, this.decoderOptions);
Assert.NotNull(img); Assert.NotNull(img);
this.localDecoder.Verify(x => x.Decode<Color32>(Configuration.Default, stream, this.decoderOptions)); this.localDecoder.Verify(x => x.Decode<Color>(Configuration.Default, stream, this.decoderOptions));
} }
[Fact] [Fact]
public void LoadFromStreamWithTypeAndDecoderAndOptions() public void LoadFromStreamWithTypeAndDecoderAndOptions()
{ {
Stream stream = new MemoryStream(); Stream stream = new MemoryStream();
Image<Color32> img = Image.Load<Color32>(stream, this.localDecoder.Object, this.decoderOptions); Image<Color> img = Image.Load<Color>(stream, this.localDecoder.Object, this.decoderOptions);
Assert.NotNull(img); Assert.NotNull(img);
Assert.Equal(this.returnImage, img); Assert.Equal(this.returnImage, img);
this.localDecoder.Verify(x => x.Decode<Color32>(Configuration.Default, stream, this.decoderOptions)); this.localDecoder.Verify(x => x.Decode<Color>(Configuration.Default, stream, this.decoderOptions));
} }
[Fact] [Fact]
@ -252,10 +252,10 @@ namespace ImageSharp.Tests
[Fact] [Fact]
public void LoadFromBytesWithType() public void LoadFromBytesWithType()
{ {
Image<Color32> img = Image.Load<Color32>(this.DataStream.ToArray()); Image<Color> img = Image.Load<Color>(this.DataStream.ToArray());
Assert.NotNull(img); Assert.NotNull(img);
Assert.Equal(TestFormat.GlobalTestFormat.Sample<Color32>(), img); Assert.Equal(TestFormat.GlobalTestFormat.Sample<Color>(), img);
Assert.Equal(TestFormat.GlobalTestFormat, img.CurrentImageFormat); Assert.Equal(TestFormat.GlobalTestFormat, img.CurrentImageFormat);
TestFormat.GlobalTestFormat.VerifyDecodeCall(this.Marker, null, Configuration.Default); TestFormat.GlobalTestFormat.VerifyDecodeCall(this.Marker, null, Configuration.Default);
@ -277,10 +277,10 @@ namespace ImageSharp.Tests
[Fact] [Fact]
public void LoadFromBytesWithTypeAndOptions() public void LoadFromBytesWithTypeAndOptions()
{ {
Image<Color32> img = Image.Load<Color32>(this.DataStream.ToArray(), this.decoderOptions); Image<Color> img = Image.Load<Color>(this.DataStream.ToArray(), this.decoderOptions);
Assert.NotNull(img); Assert.NotNull(img);
Assert.Equal(TestFormat.GlobalTestFormat.Sample<Color32>(), img); Assert.Equal(TestFormat.GlobalTestFormat.Sample<Color>(), img);
Assert.Equal(TestFormat.GlobalTestFormat, img.CurrentImageFormat); Assert.Equal(TestFormat.GlobalTestFormat, img.CurrentImageFormat);
TestFormat.GlobalTestFormat.VerifyDecodeCall(this.Marker, this.decoderOptions, Configuration.Default); TestFormat.GlobalTestFormat.VerifyDecodeCall(this.Marker, this.decoderOptions, Configuration.Default);
@ -295,7 +295,7 @@ namespace ImageSharp.Tests
Assert.NotNull(img); Assert.NotNull(img);
Assert.Equal(this.localFormat.Object, img.CurrentImageFormat); Assert.Equal(this.localFormat.Object, img.CurrentImageFormat);
this.localDecoder.Verify(x => x.Decode<Color32>(this.LocalConfiguration, It.IsAny<Stream>(), null)); this.localDecoder.Verify(x => x.Decode<Color>(this.LocalConfiguration, It.IsAny<Stream>(), null));
Assert.Equal(this.DataStream.ToArray(), this.DecodedData); Assert.Equal(this.DataStream.ToArray(), this.DecodedData);
} }
@ -303,14 +303,14 @@ namespace ImageSharp.Tests
[Fact] [Fact]
public void LoadFromBytesWithTypeAndConfig() public void LoadFromBytesWithTypeAndConfig()
{ {
Image<Color32> img = Image.Load<Color32>(this.LocalConfiguration, this.DataStream.ToArray()); Image<Color> img = Image.Load<Color>(this.LocalConfiguration, this.DataStream.ToArray());
Assert.NotNull(img); Assert.NotNull(img);
Assert.Equal(this.returnImage, img); Assert.Equal(this.returnImage, img);
Assert.Equal(this.localFormat.Object, img.CurrentImageFormat); Assert.Equal(this.localFormat.Object, img.CurrentImageFormat);
this.localDecoder.Verify(x => x.Decode<Color32>(this.LocalConfiguration, It.IsAny<Stream>(), null)); this.localDecoder.Verify(x => x.Decode<Color>(this.LocalConfiguration, It.IsAny<Stream>(), null));
Assert.Equal(this.DataStream.ToArray(), this.DecodedData); Assert.Equal(this.DataStream.ToArray(), this.DecodedData);
} }
@ -323,7 +323,7 @@ namespace ImageSharp.Tests
Assert.NotNull(img); Assert.NotNull(img);
Assert.Equal(this.localFormat.Object, img.CurrentImageFormat); Assert.Equal(this.localFormat.Object, img.CurrentImageFormat);
this.localDecoder.Verify(x => x.Decode<Color32>(this.LocalConfiguration, It.IsAny<Stream>(), this.decoderOptions)); this.localDecoder.Verify(x => x.Decode<Color>(this.LocalConfiguration, It.IsAny<Stream>(), this.decoderOptions));
Assert.Equal(this.DataStream.ToArray(), this.DecodedData); Assert.Equal(this.DataStream.ToArray(), this.DecodedData);
} }
@ -331,13 +331,13 @@ namespace ImageSharp.Tests
[Fact] [Fact]
public void LoadFromBytesWithTypeAndConfigAndOptions() public void LoadFromBytesWithTypeAndConfigAndOptions()
{ {
Image<Color32> img = Image.Load<Color32>(this.LocalConfiguration, this.DataStream.ToArray(), this.decoderOptions); Image<Color> img = Image.Load<Color>(this.LocalConfiguration, this.DataStream.ToArray(), this.decoderOptions);
Assert.NotNull(img); Assert.NotNull(img);
Assert.Equal(this.returnImage, img); Assert.Equal(this.returnImage, img);
Assert.Equal(this.localFormat.Object, img.CurrentImageFormat); Assert.Equal(this.localFormat.Object, img.CurrentImageFormat);
this.localDecoder.Verify(x => x.Decode<Color32>(this.LocalConfiguration, It.IsAny<Stream>(), this.decoderOptions)); this.localDecoder.Verify(x => x.Decode<Color>(this.LocalConfiguration, It.IsAny<Stream>(), this.decoderOptions));
Assert.Equal(this.DataStream.ToArray(), this.DecodedData); Assert.Equal(this.DataStream.ToArray(), this.DecodedData);
} }
@ -349,18 +349,18 @@ namespace ImageSharp.Tests
Image img = Image.Load(this.DataStream.ToArray(), this.localDecoder.Object); Image img = Image.Load(this.DataStream.ToArray(), this.localDecoder.Object);
Assert.NotNull(img); Assert.NotNull(img);
this.localDecoder.Verify(x => x.Decode<Color32>(Configuration.Default, It.IsAny<Stream>(), null)); this.localDecoder.Verify(x => x.Decode<Color>(Configuration.Default, It.IsAny<Stream>(), null));
Assert.Equal(this.DataStream.ToArray(), this.DecodedData); Assert.Equal(this.DataStream.ToArray(), this.DecodedData);
} }
[Fact] [Fact]
public void LoadFromBytesWithTypeAndDecoder() public void LoadFromBytesWithTypeAndDecoder()
{ {
Image<Color32> img = Image.Load<Color32>(this.DataStream.ToArray(), this.localDecoder.Object); Image<Color> img = Image.Load<Color>(this.DataStream.ToArray(), this.localDecoder.Object);
Assert.NotNull(img); Assert.NotNull(img);
Assert.Equal(this.returnImage, img); Assert.Equal(this.returnImage, img);
this.localDecoder.Verify(x => x.Decode<Color32>(Configuration.Default, It.IsAny<Stream>(), null)); this.localDecoder.Verify(x => x.Decode<Color>(Configuration.Default, It.IsAny<Stream>(), null));
Assert.Equal(this.DataStream.ToArray(), this.DecodedData); 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); Image img = Image.Load(this.DataStream.ToArray(), this.localDecoder.Object, this.decoderOptions);
Assert.NotNull(img); Assert.NotNull(img);
this.localDecoder.Verify(x => x.Decode<Color32>(Configuration.Default, It.IsAny<Stream>(), this.decoderOptions)); this.localDecoder.Verify(x => x.Decode<Color>(Configuration.Default, It.IsAny<Stream>(), this.decoderOptions));
Assert.Equal(this.DataStream.ToArray(), this.DecodedData); Assert.Equal(this.DataStream.ToArray(), this.DecodedData);
} }
[Fact] [Fact]
public void LoadFromBytesWithTypeAndDecoderAndOptions() public void LoadFromBytesWithTypeAndDecoderAndOptions()
{ {
Image<Color32> img = Image.Load<Color32>(this.DataStream.ToArray(), this.localDecoder.Object, this.decoderOptions); Image<Color> img = Image.Load<Color>(this.DataStream.ToArray(), this.localDecoder.Object, this.decoderOptions);
Assert.NotNull(img); Assert.NotNull(img);
Assert.Equal(this.returnImage, img); Assert.Equal(this.returnImage, img);
this.localDecoder.Verify(x => x.Decode<Color32>(Configuration.Default, It.IsAny<Stream>(), this.decoderOptions)); this.localDecoder.Verify(x => x.Decode<Color>(Configuration.Default, It.IsAny<Stream>(), this.decoderOptions));
Assert.Equal(this.DataStream.ToArray(), this.DecodedData); Assert.Equal(this.DataStream.ToArray(), this.DecodedData);
} }
@ -401,10 +401,10 @@ namespace ImageSharp.Tests
[Fact] [Fact]
public void LoadFromFileWithType() public void LoadFromFileWithType()
{ {
Image<Color32> img = Image.Load<Color32>(this.DataStream); Image<Color> img = Image.Load<Color>(this.DataStream);
Assert.NotNull(img); Assert.NotNull(img);
Assert.Equal(TestFormat.GlobalTestFormat.Sample<Color32>(), img); Assert.Equal(TestFormat.GlobalTestFormat.Sample<Color>(), img);
Assert.Equal(TestFormat.GlobalTestFormat, img.CurrentImageFormat); Assert.Equal(TestFormat.GlobalTestFormat, img.CurrentImageFormat);
TestFormat.GlobalTestFormat.VerifyDecodeCall(this.Marker, null, Configuration.Default); TestFormat.GlobalTestFormat.VerifyDecodeCall(this.Marker, null, Configuration.Default);
@ -426,10 +426,10 @@ namespace ImageSharp.Tests
[Fact] [Fact]
public void LoadFromFileWithTypeAndOptions() public void LoadFromFileWithTypeAndOptions()
{ {
Image<Color32> img = Image.Load<Color32>(this.DataStream, this.decoderOptions); Image<Color> img = Image.Load<Color>(this.DataStream, this.decoderOptions);
Assert.NotNull(img); Assert.NotNull(img);
Assert.Equal(TestFormat.GlobalTestFormat.Sample<Color32>(), img); Assert.Equal(TestFormat.GlobalTestFormat.Sample<Color>(), img);
Assert.Equal(TestFormat.GlobalTestFormat, img.CurrentImageFormat); Assert.Equal(TestFormat.GlobalTestFormat, img.CurrentImageFormat);
TestFormat.GlobalTestFormat.VerifyDecodeCall(this.Marker, this.decoderOptions, Configuration.Default); TestFormat.GlobalTestFormat.VerifyDecodeCall(this.Marker, this.decoderOptions, Configuration.Default);
@ -444,20 +444,20 @@ namespace ImageSharp.Tests
Assert.NotNull(img); Assert.NotNull(img);
Assert.Equal(this.localFormat.Object, img.CurrentImageFormat); Assert.Equal(this.localFormat.Object, img.CurrentImageFormat);
this.localDecoder.Verify(x => x.Decode<Color32>(this.LocalConfiguration, this.DataStream, null)); this.localDecoder.Verify(x => x.Decode<Color>(this.LocalConfiguration, this.DataStream, null));
} }
[Fact] [Fact]
public void LoadFromFileWithTypeAndConfig() public void LoadFromFileWithTypeAndConfig()
{ {
Image<Color32> img = Image.Load<Color32>(this.LocalConfiguration, this.FilePath); Image<Color> img = Image.Load<Color>(this.LocalConfiguration, this.FilePath);
Assert.NotNull(img); Assert.NotNull(img);
Assert.Equal(this.returnImage, img); Assert.Equal(this.returnImage, img);
Assert.Equal(this.localFormat.Object, img.CurrentImageFormat); Assert.Equal(this.localFormat.Object, img.CurrentImageFormat);
this.localDecoder.Verify(x => x.Decode<Color32>(this.LocalConfiguration, this.DataStream, null)); this.localDecoder.Verify(x => x.Decode<Color>(this.LocalConfiguration, this.DataStream, null));
} }
@ -469,20 +469,20 @@ namespace ImageSharp.Tests
Assert.NotNull(img); Assert.NotNull(img);
Assert.Equal(this.localFormat.Object, img.CurrentImageFormat); Assert.Equal(this.localFormat.Object, img.CurrentImageFormat);
this.localDecoder.Verify(x => x.Decode<Color32>(this.LocalConfiguration, this.DataStream, this.decoderOptions)); this.localDecoder.Verify(x => x.Decode<Color>(this.LocalConfiguration, this.DataStream, this.decoderOptions));
} }
[Fact] [Fact]
public void LoadFromFileWithTypeAndConfigAndOptions() public void LoadFromFileWithTypeAndConfigAndOptions()
{ {
Image<Color32> img = Image.Load<Color32>(this.LocalConfiguration, this.FilePath, this.decoderOptions); Image<Color> img = Image.Load<Color>(this.LocalConfiguration, this.FilePath, this.decoderOptions);
Assert.NotNull(img); Assert.NotNull(img);
Assert.Equal(this.returnImage, img); Assert.Equal(this.returnImage, img);
Assert.Equal(this.localFormat.Object, img.CurrentImageFormat); Assert.Equal(this.localFormat.Object, img.CurrentImageFormat);
this.localDecoder.Verify(x => x.Decode<Color32>(this.LocalConfiguration, this.DataStream, this.decoderOptions)); this.localDecoder.Verify(x => x.Decode<Color>(this.LocalConfiguration, this.DataStream, this.decoderOptions));
} }
@ -493,17 +493,17 @@ namespace ImageSharp.Tests
Image img = Image.Load(this.FilePath, this.localDecoder.Object); Image img = Image.Load(this.FilePath, this.localDecoder.Object);
Assert.NotNull(img); Assert.NotNull(img);
this.localDecoder.Verify(x => x.Decode<Color32>(Configuration.Default, this.DataStream, null)); this.localDecoder.Verify(x => x.Decode<Color>(Configuration.Default, this.DataStream, null));
} }
[Fact] [Fact]
public void LoadFromFileWithTypeAndDecoder() public void LoadFromFileWithTypeAndDecoder()
{ {
Image<Color32> img = Image.Load<Color32>(this.FilePath, this.localDecoder.Object); Image<Color> img = Image.Load<Color>(this.FilePath, this.localDecoder.Object);
Assert.NotNull(img); Assert.NotNull(img);
Assert.Equal(this.returnImage, img); Assert.Equal(this.returnImage, img);
this.localDecoder.Verify(x => x.Decode<Color32>(Configuration.Default, this.DataStream, null)); this.localDecoder.Verify(x => x.Decode<Color>(Configuration.Default, this.DataStream, null));
} }
[Fact] [Fact]
@ -512,17 +512,17 @@ namespace ImageSharp.Tests
Image img = Image.Load(this.FilePath, this.localDecoder.Object, this.decoderOptions); Image img = Image.Load(this.FilePath, this.localDecoder.Object, this.decoderOptions);
Assert.NotNull(img); Assert.NotNull(img);
this.localDecoder.Verify(x => x.Decode<Color32>(Configuration.Default, this.DataStream, this.decoderOptions)); this.localDecoder.Verify(x => x.Decode<Color>(Configuration.Default, this.DataStream, this.decoderOptions));
} }
[Fact] [Fact]
public void LoadFromFileWithTypeAndDecoderAndOptions() public void LoadFromFileWithTypeAndDecoderAndOptions()
{ {
Image<Color32> img = Image.Load<Color32>(this.FilePath, this.localDecoder.Object, this.decoderOptions); Image<Color> img = Image.Load<Color>(this.FilePath, this.localDecoder.Object, this.decoderOptions);
Assert.NotNull(img); Assert.NotNull(img);
Assert.Equal(this.returnImage, img); Assert.Equal(this.returnImage, img);
this.localDecoder.Verify(x => x.Decode<Color32>(Configuration.Default, this.DataStream, this.decoderOptions)); this.localDecoder.Verify(x => x.Decode<Color>(Configuration.Default, this.DataStream, this.decoderOptions));
} }
public void Dispose() 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.fileSystem.Setup(x => x.Create("path.png")).Returns(stream);
this.Image.Save("path.png"); this.Image.Save("path.png");
this.encoder.Verify(x => x.Encode<Color32>(this.Image, stream, null)); this.encoder.Verify(x => x.Encode<Color>(this.Image, stream, null));
} }
[Fact] [Fact]
@ -70,7 +70,7 @@ namespace ImageSharp.Tests
this.Image.Save("path.jpg", this.encoderOptions); this.Image.Save("path.jpg", this.encoderOptions);
this.encoder.Verify(x => x.Encode<Color32>(this.Image, stream, this.encoderOptions)); this.encoder.Verify(x => x.Encode<Color>(this.Image, stream, this.encoderOptions));
} }
[Fact] [Fact]
@ -81,7 +81,7 @@ namespace ImageSharp.Tests
this.Image.Save("path.jpg", this.encoderNotInFormat.Object); this.Image.Save("path.jpg", this.encoderNotInFormat.Object);
this.encoderNotInFormat.Verify(x => x.Encode<Color32>(this.Image, stream, null)); this.encoderNotInFormat.Verify(x => x.Encode<Color>(this.Image, stream, null));
} }
[Fact] [Fact]
@ -92,7 +92,7 @@ namespace ImageSharp.Tests
this.Image.Save("path.jpg", this.encoderNotInFormat.Object, this.encoderOptions); this.Image.Save("path.jpg", this.encoderNotInFormat.Object, this.encoderOptions);
this.encoderNotInFormat.Verify(x => x.Encode<Color32>(this.Image, stream, this.encoderOptions)); this.encoderNotInFormat.Verify(x => x.Encode<Color>(this.Image, stream, this.encoderOptions));
} }
@ -105,7 +105,7 @@ namespace ImageSharp.Tests
this.Image.Save("path.jpg", this.encoderNotInFormat.Object); this.Image.Save("path.jpg", this.encoderNotInFormat.Object);
this.encoderNotInFormat.Verify(x => x.Encode<Color32>(this.Image, stream, null)); this.encoderNotInFormat.Verify(x => x.Encode<Color>(this.Image, stream, null));
} }
[Fact] [Fact]
@ -116,7 +116,7 @@ namespace ImageSharp.Tests
this.Image.Save("path.jpg", this.encoderNotInFormat.Object, this.encoderOptions); this.Image.Save("path.jpg", this.encoderNotInFormat.Object, this.encoderOptions);
this.encoderNotInFormat.Verify(x => x.Encode<Color32>(this.Image, stream, this.encoderOptions)); this.encoderNotInFormat.Verify(x => x.Encode<Color>(this.Image, stream, this.encoderOptions));
} }
[Fact] [Fact]
@ -125,7 +125,7 @@ namespace ImageSharp.Tests
Stream stream = new MemoryStream(); Stream stream = new MemoryStream();
this.Image.Save(stream); this.Image.Save(stream);
this.encoder.Verify(x => x.Encode<Color32>(this.Image, stream, null)); this.encoder.Verify(x => x.Encode<Color>(this.Image, stream, null));
} }
[Fact] [Fact]
@ -135,7 +135,7 @@ namespace ImageSharp.Tests
this.Image.Save(stream, this.encoderOptions); this.Image.Save(stream, this.encoderOptions);
this.encoder.Verify(x => x.Encode<Color32>(this.Image, stream, this.encoderOptions)); this.encoder.Verify(x => x.Encode<Color>(this.Image, stream, this.encoderOptions));
} }
[Fact] [Fact]
@ -145,7 +145,7 @@ namespace ImageSharp.Tests
this.Image.Save(stream, this.encoderNotInFormat.Object); this.Image.Save(stream, this.encoderNotInFormat.Object);
this.encoderNotInFormat.Verify(x => x.Encode<Color32>(this.Image, stream, null)); this.encoderNotInFormat.Verify(x => x.Encode<Color>(this.Image, stream, null));
} }
[Fact] [Fact]
@ -155,7 +155,7 @@ namespace ImageSharp.Tests
this.Image.Save(stream, this.encoderNotInFormat.Object, this.encoderOptions); this.Image.Save(stream, this.encoderNotInFormat.Object, this.encoderOptions);
this.encoderNotInFormat.Verify(x => x.Encode<Color32>(this.Image, stream, this.encoderOptions)); this.encoderNotInFormat.Verify(x => x.Encode<Color>(this.Image, stream, this.encoderOptions));
} }
[Fact] [Fact]
@ -165,7 +165,7 @@ namespace ImageSharp.Tests
this.Image.Save(stream, this.formatNotRegistered.Object); this.Image.Save(stream, this.formatNotRegistered.Object);
this.encoderNotInFormat.Verify(x => x.Encode<Color32>(this.Image, stream, null)); this.encoderNotInFormat.Verify(x => x.Encode<Color>(this.Image, stream, null));
} }
[Fact] [Fact]
@ -175,7 +175,7 @@ namespace ImageSharp.Tests
this.Image.Save(stream, this.formatNotRegistered.Object, this.encoderOptions); this.Image.Save(stream, this.formatNotRegistered.Object, this.encoderOptions);
this.encoderNotInFormat.Verify(x => x.Encode<Color32>(this.Image, stream, this.encoderOptions)); this.encoderNotInFormat.Verify(x => x.Encode<Color>(this.Image, stream, this.encoderOptions));
} }
public void Dispose() public void Dispose()

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

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

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

@ -243,7 +243,7 @@ namespace ImageSharp.Tests
TestProfile(profile); TestProfile(profile);
Image<Color32> thumbnail = profile.CreateThumbnail<Color32>(); Image<Color> thumbnail = profile.CreateThumbnail<Color>();
Assert.NotNull(thumbnail); Assert.NotNull(thumbnail);
Assert.Equal(256, thumbnail.Width); Assert.Equal(256, thumbnail.Width);
Assert.Equal(170, thumbnail.Height); 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 (Image image = file.CreateImage())
using (FileStream output = File.OpenWrite($"{path}/{file.FileName}")) using (FileStream output = File.OpenWrite($"{path}/{file.FileName}"))
{ {
image.BackgroundColor(Color32.HotPink).Save(output); image.BackgroundColor(Color.HotPink).Save(output);
} }
} }
} }

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

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

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

@ -36,13 +36,13 @@ namespace ImageSharp.Tests
// [Fact] // [Fact]
public void PrintWeightsData() public void PrintWeightsData()
{ {
ResizeProcessor<Color32> proc = new ResizeProcessor<Color32>(new BicubicResampler(), 200, 200); ResizeProcessor<Color> proc = new ResizeProcessor<Color>(new BicubicResampler(), 200, 200);
ResamplingWeightedProcessor<Color32>.WeightsBuffer weights = proc.PrecomputeWeights(200, 500); ResamplingWeightedProcessor<Color>.WeightsBuffer weights = proc.PrecomputeWeights(200, 500);
StringBuilder bld = new StringBuilder(); StringBuilder bld = new StringBuilder();
foreach (ResamplingWeightedProcessor<Color32>.WeightsWindow window in weights.Weights) foreach (ResamplingWeightedProcessor<Color>.WeightsWindow window in weights.Weights)
{ {
for (int i = 0; i < window.Length; i++) 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 (Image image = file.CreateImage())
using (FileStream output = File.OpenWrite($"{path}/{filename}")) using (FileStream output = File.OpenWrite($"{path}/{filename}"))
{ {
image.Vignette(Color32.HotPink).Save(output); image.Vignette(Color.HotPink).Save(output);
} }
} }
} }

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

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

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

@ -147,9 +147,9 @@ namespace ImageSharp.Tests
int bottom = pixels.Height; int bottom = pixels.Height;
int height = (int)Math.Ceiling(pixels.Height / 6f); int height = (int)Math.Ceiling(pixels.Height / 6f);
Vector4 red = Color32.Red.ToVector4(); // use real color so we can see har it translates in the test pattern Vector4 red = Color.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 green = Color.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 Vector4 blue = Color.Blue.ToVector4(); // use real color so we can see har it translates in the test pattern
TColor c = default(TColor); 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 Dictionary<Type, PixelTypes> ClrTypes2PixelTypes = new Dictionary<Type, PixelTypes>();
private static readonly Assembly ImageSharpAssembly = typeof(Color32).GetTypeInfo().Assembly; private static readonly Assembly ImageSharpAssembly = typeof(Color).GetTypeInfo().Assembly;
private static readonly Dictionary<PixelTypes, Type> PixelTypes2ClrTypes = new Dictionary<PixelTypes, Type>(); private static readonly Dictionary<PixelTypes, Type> PixelTypes2ClrTypes = new Dictionary<PixelTypes, Type>();
@ -28,8 +28,8 @@ namespace ImageSharp.Tests
static TestUtilityExtensions() static TestUtilityExtensions()
{ {
string nameSpace = typeof(Color32).FullName; string nameSpace = typeof(Color).FullName;
nameSpace = nameSpace.Substring(0, nameSpace.Length - typeof(Color32).Name.Length - 1); nameSpace = nameSpace.Substring(0, nameSpace.Length - typeof(Color).Name.Length - 1);
foreach (PixelTypes pt in AllConcretePixelTypes.Where(pt => pt != PixelTypes.StandardImageClass)) foreach (PixelTypes pt in AllConcretePixelTypes.Where(pt => pt != PixelTypes.StandardImageClass))
{ {
string typeName = $"{nameSpace}.{pt.ToString()}"; string typeName = $"{nameSpace}.{pt.ToString()}";
@ -42,7 +42,7 @@ namespace ImageSharp.Tests
PixelTypes2ClrTypes[pt] = t; PixelTypes2ClrTypes[pt] = t;
ClrTypes2PixelTypes[t] = pt; ClrTypes2PixelTypes[t] = pt;
} }
PixelTypes2ClrTypes[PixelTypes.StandardImageClass] = typeof(Color32); PixelTypes2ClrTypes[PixelTypes.StandardImageClass] = typeof(Color);
} }
public static bool HasFlag(this PixelTypes pixelTypes, PixelTypes flag) => (pixelTypes & flag) == flag; 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>() public static readonly TheoryData<object> BasicData = new TheoryData<object>()
{ {
TestImageProvider<Color32>.Blank(10, 20), TestImageProvider<Color>.Blank(10, 20),
TestImageProvider<HalfVector4>.Blank( TestImageProvider<HalfVector4>.Blank(
10, 10,
20), 20),
@ -169,7 +169,7 @@ namespace ImageSharp.Tests
public static readonly TheoryData<object> FileData = new TheoryData<object>() public static readonly TheoryData<object> FileData = new TheoryData<object>()
{ {
TestImageProvider<Color32>.File( TestImageProvider<Color>.File(
TestImages.Bmp.Car), TestImages.Bmp.Car),
TestImageProvider<HalfVector4>.File( TestImageProvider<HalfVector4>.File(
TestImages.Bmp.F) TestImages.Bmp.F)

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

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