Browse Source

Rename Color and ColorVector

Color -> Rgba32
ColorVector -> RgbaVector
af/merge-core
James Jackson-South 9 years ago
parent
commit
fa152146dd
  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. 728
      src/ImageSharp/Colors/Color.Definitions.cs
  9. 292
      src/ImageSharp/Colors/ColorConstants.cs
  10. 728
      src/ImageSharp/Colors/ColorVector.Definitions.cs
  11. 60
      src/ImageSharp/Colors/ColorspaceTransforms.cs
  12. 8
      src/ImageSharp/Colors/ComponentOrder.cs
  13. 2
      src/ImageSharp/Colors/NamedColors{TColor}.cs
  14. 8
      src/ImageSharp/Colors/PackedPixel/IPixel.cs
  15. 2
      src/ImageSharp/Colors/PackedPixel/PackedPixelConverterHelper.cs
  16. 72
      src/ImageSharp/Colors/Rgba32.BulkOperations.cs
  17. 728
      src/ImageSharp/Colors/Rgba32.Definitions.cs
  18. 64
      src/ImageSharp/Colors/Rgba32.Transforms.cs
  19. 60
      src/ImageSharp/Colors/Rgba32.cs
  20. 15
      src/ImageSharp/Colors/RgbaVector.BulkOperations.cs
  21. 728
      src/ImageSharp/Colors/RgbaVector.Definitions.cs
  22. 94
      src/ImageSharp/Colors/RgbaVector.Transforms.cs
  23. 50
      src/ImageSharp/Colors/RgbaVector.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. 14
      src/ImageSharp/Image.Create.cs
  33. 2
      src/ImageSharp/Image.FromFile.cs
  34. 4
      src/ImageSharp/Image.FromStream.cs
  35. 10
      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. 4
      tests/ImageSharp.Tests/Colors/ColorEqualityTests.cs
  60. 38
      tests/ImageSharp.Tests/Colors/ColorTests.cs
  61. 58
      tests/ImageSharp.Tests/Colors/ColorTransformTests.cs
  62. 38
      tests/ImageSharp.Tests/Colors/ColorVectorTests.cs
  63. 58
      tests/ImageSharp.Tests/Colors/ColorVectorTransformTests.cs
  64. 22
      tests/ImageSharp.Tests/Colors/PackedPixelTests.cs
  65. 44
      tests/ImageSharp.Tests/Colors/UnPackedPixelTests.cs
  66. 6
      tests/ImageSharp.Tests/Common/BufferSpanTests.cs
  67. 8
      tests/ImageSharp.Tests/Common/PixelDataPoolTests.cs
  68. 32
      tests/ImageSharp.Tests/Drawing/BeziersTests.cs
  69. 22
      tests/ImageSharp.Tests/Drawing/DrawPathTests.cs
  70. 176
      tests/ImageSharp.Tests/Drawing/FillPatternTests.cs
  71. 4
      tests/ImageSharp.Tests/Drawing/FillRegionProcessorTests.cs
  72. 26
      tests/ImageSharp.Tests/Drawing/FillSolidBrushTests.cs
  73. 80
      tests/ImageSharp.Tests/Drawing/LineComplexPolygonTests.cs
  74. 64
      tests/ImageSharp.Tests/Drawing/LineTests.cs
  75. 30
      tests/ImageSharp.Tests/Drawing/Paths/DrawBeziersTests.cs
  76. 30
      tests/ImageSharp.Tests/Drawing/Paths/DrawLinesTests.cs
  77. 30
      tests/ImageSharp.Tests/Drawing/Paths/DrawPath.cs
  78. 30
      tests/ImageSharp.Tests/Drawing/Paths/DrawPolygon.cs
  79. 30
      tests/ImageSharp.Tests/Drawing/Paths/DrawRectangle.cs
  80. 16
      tests/ImageSharp.Tests/Drawing/Paths/FillPath.cs
  81. 16
      tests/ImageSharp.Tests/Drawing/Paths/FillPolygon.cs
  82. 16
      tests/ImageSharp.Tests/Drawing/Paths/FillRectangle.cs
  83. 8
      tests/ImageSharp.Tests/Drawing/Paths/ProcessorWatchingImage.cs
  84. 42
      tests/ImageSharp.Tests/Drawing/PolygonTests.cs
  85. 4
      tests/ImageSharp.Tests/Drawing/RecolorImageTest.cs
  86. 22
      tests/ImageSharp.Tests/Drawing/SolidBezierTests.cs
  87. 30
      tests/ImageSharp.Tests/Drawing/SolidComplexPolygonTests.cs
  88. 76
      tests/ImageSharp.Tests/Drawing/SolidPolygonTests.cs
  89. 86
      tests/ImageSharp.Tests/Drawing/Text/DrawText.cs
  90. 4
      tests/ImageSharp.Tests/Drawing/Text/OutputText.cs
  91. 4
      tests/ImageSharp.Tests/Formats/Jpg/BadEofJpegTests.cs
  92. 4
      tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs
  93. 4
      tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.cs
  94. 6
      tests/ImageSharp.Tests/Formats/Jpg/JpegProfilingBenchmarks.cs
  95. 4
      tests/ImageSharp.Tests/Formats/Jpg/JpegUtilsTests.cs
  96. 100
      tests/ImageSharp.Tests/Image/ImageLoadTests.cs
  97. 24
      tests/ImageSharp.Tests/Image/ImageSaveTests.cs
  98. 16
      tests/ImageSharp.Tests/Image/PixelAccessorTests.cs
  99. 2
      tests/ImageSharp.Tests/MetaData/Profiles/Exif/ExifProfileTests.cs
  100. 2
      tests/ImageSharp.Tests/Processors/Filters/BackgroundColorTest.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="Color"/> for painting. /// A collection of methods for creating brushes. Brushes use <see cref="Rgba32"/> 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(Color color) public static SolidBrush Solid(Rgba32 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(Color foreColor) public static PatternBrush Percent10(Rgba32 foreColor)
=> new PatternBrush(Brushes<Color>.Percent10(foreColor, Color.Transparent)); => new PatternBrush(Brushes<Rgba32>.Percent10(foreColor, Rgba32.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(Color foreColor, Color backColor) public static PatternBrush Percent10(Rgba32 foreColor, Rgba32 backColor)
=> new PatternBrush(Brushes<Color>.Percent10(foreColor, backColor)); => new PatternBrush(Brushes<Rgba32>.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(Color foreColor) public static PatternBrush Percent20(Rgba32 foreColor)
=> new PatternBrush(Brushes<Color>.Percent20(foreColor, Color.Transparent)); => new PatternBrush(Brushes<Rgba32>.Percent20(foreColor, Rgba32.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(Color foreColor, Color backColor) public static PatternBrush Percent20(Rgba32 foreColor, Rgba32 backColor)
=> new PatternBrush(Brushes<Color>.Percent20(foreColor, backColor)); => new PatternBrush(Brushes<Rgba32>.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(Color foreColor) public static PatternBrush Horizontal(Rgba32 foreColor)
=> new PatternBrush(Brushes<Color>.Horizontal(foreColor, Color.Transparent)); => new PatternBrush(Brushes<Rgba32>.Horizontal(foreColor, Rgba32.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(Color foreColor, Color backColor) public static PatternBrush Horizontal(Rgba32 foreColor, Rgba32 backColor)
=> new PatternBrush(Brushes<Color>.Horizontal(foreColor, backColor)); => new PatternBrush(Brushes<Rgba32>.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(Color foreColor) public static PatternBrush Min(Rgba32 foreColor)
=> new PatternBrush(Brushes<Color>.Min(foreColor, Color.Transparent)); => new PatternBrush(Brushes<Rgba32>.Min(foreColor, Rgba32.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(Color foreColor, Color backColor) public static PatternBrush Min(Rgba32 foreColor, Rgba32 backColor)
=> new PatternBrush(Brushes<Color>.Min(foreColor, backColor)); => new PatternBrush(Brushes<Rgba32>.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(Color foreColor) public static PatternBrush Vertical(Rgba32 foreColor)
=> new PatternBrush(Brushes<Color>.Vertical(foreColor, Color.Transparent)); => new PatternBrush(Brushes<Rgba32>.Vertical(foreColor, Rgba32.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(Color foreColor, Color backColor) public static PatternBrush Vertical(Rgba32 foreColor, Rgba32 backColor)
=> new PatternBrush(Brushes<Color>.Vertical(foreColor, backColor)); => new PatternBrush(Brushes<Rgba32>.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(Color foreColor) public static PatternBrush ForwardDiagonal(Rgba32 foreColor)
=> new PatternBrush(Brushes<Color>.ForwardDiagonal(foreColor, Color.Transparent)); => new PatternBrush(Brushes<Rgba32>.ForwardDiagonal(foreColor, Rgba32.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(Color foreColor, Color backColor) public static PatternBrush ForwardDiagonal(Rgba32 foreColor, Rgba32 backColor)
=> new PatternBrush(Brushes<Color>.ForwardDiagonal(foreColor, backColor)); => new PatternBrush(Brushes<Rgba32>.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(Color foreColor) public static PatternBrush BackwardDiagonal(Rgba32 foreColor)
=> new PatternBrush(Brushes<Color>.BackwardDiagonal(foreColor, Color.Transparent)); => new PatternBrush(Brushes<Rgba32>.BackwardDiagonal(foreColor, Rgba32.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(Color foreColor, Color backColor) public static PatternBrush BackwardDiagonal(Rgba32 foreColor, Rgba32 backColor)
=> new PatternBrush(Brushes<Color>.BackwardDiagonal(foreColor, backColor)); => new PatternBrush(Brushes<Rgba32>.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="Color"/> for painting. /// Provides an implementation of a solid brush for painting with repeating images. The brush uses <see cref="Rgba32"/> for painting.
/// </summary> /// </summary>
public class ImageBrush : ImageBrush<Color> public class ImageBrush : ImageBrush<Rgba32>
{ {
/// <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<Color> image) public ImageBrush(IImageBase<Rgba32> 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="Color"/> for painting. /// Provides an implementation of a pattern brush for painting patterns. The brush use <see cref="Rgba32"/> for painting.
/// </summary> /// </summary>
public class PatternBrush : PatternBrush<Color> public class PatternBrush : PatternBrush<Rgba32>
{ {
/// <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(Color foreColor, Color backColor, bool[,] pattern) public PatternBrush(Rgba32 foreColor, Rgba32 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<Color> brush) internal PatternBrush(PatternBrush<Rgba32> 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<Color> public class RecolorBrush : RecolorBrush<Rgba32>
{ {
/// <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(Color sourceColor, Color targetColor, float threshold) public RecolorBrush(Rgba32 sourceColor, Rgba32 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="Color"/> for painting. /// Provides an implementation of a solid brush for painting solid color areas. The brush uses <see cref="Rgba32"/> for painting.
/// </summary> /// </summary>
public class SolidBrush : SolidBrush<Color> public class SolidBrush : SolidBrush<Rgba32>
{ {
/// <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(Color color) public SolidBrush(Rgba32 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="Color"/> color space. /// Represents a <see cref="Pen{TColor}"/> in the <see cref="Rgba32"/> color space.
/// </summary> /// </summary>
public class Pen : Pen<Color> public class Pen : Pen<Rgba32>
{ {
/// <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(Color color, float width) public Pen(Rgba32 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<Color> brush, float width) public Pen(IBrush<Rgba32> 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<Color> brush, float width, float[] pattern) public Pen(IBrush<Rgba32> 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<Color> pen) internal Pen(Pen<Rgba32> 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(Color color, float width) => new Pen(color, width); public static Pen Solid(Rgba32 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<Color> brush, float width) => new Pen(brush, width); public static Pen Solid(IBrush<Rgba32> 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(Color color, float width) => new Pen(Pens<Color>.Dash(color, width)); public static Pen Dash(Rgba32 color, float width) => new Pen(Pens<Rgba32>.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<Color> brush, float width) => new Pen(Pens<Color>.Dash(brush, width)); public static Pen Dash(IBrush<Rgba32> brush, float width) => new Pen(Pens<Rgba32>.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(Color color, float width) => new Pen(Pens<Color>.Dot(color, width)); public static Pen Dot(Rgba32 color, float width) => new Pen(Pens<Rgba32>.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<Color> brush, float width) => new Pen(Pens<Color>.Dot(brush, width)); public static Pen Dot(IBrush<Rgba32> brush, float width) => new Pen(Pens<Rgba32>.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(Color color, float width) => new Pen(Pens<Color>.DashDot(color, width)); public static Pen DashDot(Rgba32 color, float width) => new Pen(Pens<Rgba32>.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<Color> brush, float width) => new Pen(Pens<Color>.DashDot(brush, width)); public static Pen DashDot(IBrush<Rgba32> brush, float width) => new Pen(Pens<Rgba32>.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(Color color, float width) => new Pen(Pens<Color>.DashDotDot(color, width)); public static Pen DashDotDot(Rgba32 color, float width) => new Pen(Pens<Rgba32>.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<Color> brush, float width) => new Pen(Pens<Color>.DashDotDot(brush, width)); public static Pen DashDotDot(IBrush<Rgba32> brush, float width) => new Pen(Pens<Rgba32>.DashDotDot(brush, width));
} }
} }

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

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

292
src/ImageSharp/Colors/ColorConstants.cs

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

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

@ -1,728 +0,0 @@
// <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 16-bit floating-point 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>
/// 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;
}
}

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 Color public partial struct Rgba32
{ {
/// <summary> /// <summary>
/// Allows the implicit conversion of an instance of <see cref="Color"/> to a /// Allows the implicit conversion of an instance of <see cref="Rgba32"/> to a
/// <see cref="Bgra32"/>. /// <see cref="Bgra32"/>.
/// </summary> /// </summary>
/// <param name="color">The instance of <see cref="Color"/> to convert.</param> /// <param name="color">The instance of <see cref="Rgba32"/> to convert.</param>
/// <returns> /// <returns>
/// An instance of <see cref="Bgra32"/>. /// An instance of <see cref="Bgra32"/>.
/// </returns> /// </returns>
public static implicit operator Color(Bgra32 color) public static implicit operator Rgba32(Bgra32 color)
{ {
return new Color(color.R, color.G, color.B, color.A); return new Rgba32(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="Color"/>. /// <see cref="Rgba32"/>.
/// </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="Color"/>. /// An instance of <see cref="Rgba32"/>.
/// </returns> /// </returns>
public static implicit operator Color(Cmyk cmykColor) public static implicit operator Rgba32(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 Color(r, g, b, 1); return new Rgba32(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="Color"/>. /// <see cref="Rgba32"/>.
/// </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="Color"/>. /// An instance of <see cref="Rgba32"/>.
/// </returns> /// </returns>
public static implicit operator Color(YCbCr color) public static implicit operator Rgba32(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 Color(r, g, b); return new Rgba32(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="Color"/>. /// <see cref="Rgba32"/>.
/// </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="Color"/>. /// An instance of <see cref="Rgba32"/>.
/// </returns> /// </returns>
public static implicit operator Color(CieXyz color) public static implicit operator Rgba32(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 Color(vector); return new Rgba32(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="Color"/>. /// <see cref="Rgba32"/>.
/// </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="Color"/>. /// An instance of <see cref="Rgba32"/>.
/// </returns> /// </returns>
public static implicit operator Color(Hsv color) public static implicit operator Rgba32(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 Color(v, v, v, 1); return new Rgba32(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 Color(r, g, b, 1); return new Rgba32(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="Color"/>. /// <see cref="Rgba32"/>.
/// </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="Color"/>. /// An instance of <see cref="Rgba32"/>.
/// </returns> /// </returns>
public static implicit operator Color(Hsl color) public static implicit operator Rgba32(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 Color(r, g, b, 1); return new Rgba32(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="Color"/>. /// <see cref="Rgba32"/>.
/// </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="Color"/>. /// An instance of <see cref="Rgba32"/>.
/// </returns> /// </returns>
public static implicit operator Color(CieLab cieLabColor) public static implicit operator Rgba32(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 Color(new Vector4(r, g, b, 1F).Compress()); return new Rgba32(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="Color"/> /// Z-> Y-> X order. Equivalent to B-> G-> R in <see cref="Rgba32"/>
/// </summary> /// </summary>
Zyx, Zyx,
/// <summary> /// <summary>
/// Z-> Y-> X-> W order. Equivalent to B-> G-> R-> A in <see cref="Color"/> /// Z-> Y-> X-> W order. Equivalent to B-> G-> R-> A in <see cref="Rgba32"/>
/// </summary> /// </summary>
Zyxw, Zyxw,
/// <summary> /// <summary>
/// X-> Y-> Z order. Equivalent to R-> G-> B in <see cref="Color"/> /// X-> Y-> Z order. Equivalent to R-> G-> B in <see cref="Rgba32"/>
/// </summary> /// </summary>
Xyz, Xyz,
/// <summary> /// <summary>
/// X-> Y-> Z-> W order. Equivalent to R-> G-> B-> A in <see cref="Color"/> /// X-> Y-> Z-> W order. Equivalent to R-> G-> B-> A in <see cref="Rgba32"/>
/// </summary> /// </summary>
Xyzw, Xyzw,
} }

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

@ -5,8 +5,6 @@
namespace ImageSharp namespace ImageSharp
{ {
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>

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="Color"/> /// Output is expanded to X-> Y-> Z order. Equivalent to R-> G-> B in <see cref="Rgba32"/>
/// </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="Color"/> /// Output is expanded to X-> Y-> Z-> W order. Equivalent to R-> G-> B-> A in <see cref="Rgba32"/>
/// </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="Color"/> /// Output is expanded to Z-> Y-> X order. Equivalent to B-> G-> R in <see cref="Rgba32"/>
/// </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="Color"/> /// Output is expanded to Z-> Y-> X-> W order. Equivalent to B-> G-> R-> A in <see cref="Rgba32"/>
/// </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(Color) return type == typeof(Rgba32)
|| type == typeof(Argb32) || type == typeof(Argb32)
|| type == typeof(Alpha8) || type == typeof(Alpha8)
|| type == typeof(Bgr565) || type == typeof(Bgr565)

72
src/ImageSharp/Colors/Color.BulkOperations.cs → src/ImageSharp/Colors/Rgba32.BulkOperations.cs

@ -1,4 +1,4 @@
// <copyright file="Color.BulkOperations.cs" company="James Jackson-South"> // <copyright file="Rgba32.BulkOperations.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>
@ -18,12 +18,12 @@ 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 Color public partial struct Rgba32
{ {
/// <summary> /// <summary>
/// <see cref="BulkPixelOperations{TColor}"/> implementation optimized for <see cref="Color"/>. /// <see cref="BulkPixelOperations{TColor}"/> implementation optimized for <see cref="Rgba32"/>.
/// </summary> /// </summary>
internal class BulkOperations : BulkPixelOperations<Color> internal class BulkOperations : BulkPixelOperations<Rgba32>
{ {
/// <summary> /// <summary>
/// SIMD optimized bulk implementation of <see cref="IPixel.PackFromVector4(Vector4)"/> /// SIMD optimized bulk implementation of <see cref="IPixel.PackFromVector4(Vector4)"/>
@ -42,12 +42,12 @@ namespace ImageSharp
/// <cref>https://github.com/dotnet/corefx/issues/15957</cref> /// <cref>https://github.com/dotnet/corefx/issues/15957</cref>
/// </see> /// </see>
/// </remarks> /// </remarks>
internal static unsafe void ToVector4SimdAligned(BufferSpan<Color> sourceColors, BufferSpan<Vector4> destVectors, int count) internal static unsafe void ToVector4SimdAligned(BufferSpan<Rgba32> sourceColors, BufferSpan<Vector4> destVectors, int count)
{ {
if (!Vector.IsHardwareAccelerated) if (!Vector.IsHardwareAccelerated)
{ {
throw new InvalidOperationException( throw new InvalidOperationException(
"Color32.BulkOperations.ToVector4SimdAligned() should not be called when Vector.IsHardwareAccelerated == false!"); "Rgba32.BulkOperations.ToVector4SimdAligned() should not be called when Vector.IsHardwareAccelerated == false!");
} }
int vecSize = Vector<uint>.Count; int vecSize = Vector<uint>.Count;
@ -64,7 +64,7 @@ namespace ImageSharp
int unpackedRawCount = count * 4; int unpackedRawCount = count * 4;
ref uint src = ref Unsafe.As<Color, uint>(ref sourceColors.DangerousGetPinnableReference()); ref uint src = ref Unsafe.As<Rgba32, uint>(ref sourceColors.DangerousGetPinnableReference());
using (Buffer<uint> tempBuf = new Buffer<uint>( using (Buffer<uint> tempBuf = new Buffer<uint>(
unpackedRawCount + Vector<uint>.Count)) unpackedRawCount + Vector<uint>.Count))
@ -100,7 +100,7 @@ namespace ImageSharp
} }
/// <inheritdoc /> /// <inheritdoc />
internal override void ToVector4(BufferSpan<Color> sourceColors, BufferSpan<Vector4> destVectors, int count) internal override void ToVector4(BufferSpan<Rgba32> sourceColors, BufferSpan<Vector4> destVectors, int count)
{ {
if (count < 256 || !Vector.IsHardwareAccelerated) if (count < 256 || !Vector.IsHardwareAccelerated)
{ {
@ -127,103 +127,103 @@ namespace ImageSharp
} }
/// <inheritdoc /> /// <inheritdoc />
internal override void PackFromXyzBytes(BufferSpan<byte> sourceBytes, BufferSpan<Color> destColors, int count) internal override void PackFromXyzBytes(BufferSpan<byte> sourceBytes, BufferSpan<Rgba32> destColors, int count)
{ {
ref RGB24 sourceRef = ref Unsafe.As<byte, RGB24>(ref sourceBytes.DangerousGetPinnableReference()); ref RGB24 sourceRef = ref Unsafe.As<byte, RGB24>(ref sourceBytes.DangerousGetPinnableReference());
ref Color destRef = ref destColors.DangerousGetPinnableReference(); ref Rgba32 destRef = ref destColors.DangerousGetPinnableReference();
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
ref RGB24 sp = ref Unsafe.Add(ref sourceRef, i); ref RGB24 sp = ref Unsafe.Add(ref sourceRef, i);
ref Color dp = ref Unsafe.Add(ref destRef, i); ref Rgba32 dp = ref Unsafe.Add(ref destRef, i);
Unsafe.As<Color, RGB24>(ref dp) = sp; Unsafe.As<Rgba32, RGB24>(ref dp) = sp;
dp.A = 255; dp.A = 255;
} }
} }
/// <inheritdoc /> /// <inheritdoc />
internal override void ToXyzBytes(BufferSpan<Color> sourceColors, BufferSpan<byte> destBytes, int count) internal override void ToXyzBytes(BufferSpan<Rgba32> sourceColors, BufferSpan<byte> destBytes, int count)
{ {
ref Color sourceRef = ref sourceColors.DangerousGetPinnableReference(); ref Rgba32 sourceRef = ref sourceColors.DangerousGetPinnableReference();
ref RGB24 destRef = ref Unsafe.As<byte, RGB24>(ref destBytes.DangerousGetPinnableReference()); ref RGB24 destRef = ref Unsafe.As<byte, RGB24>(ref destBytes.DangerousGetPinnableReference());
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
ref Color sp = ref Unsafe.Add(ref sourceRef, i); ref Rgba32 sp = ref Unsafe.Add(ref sourceRef, i);
ref RGB24 dp = ref Unsafe.Add(ref destRef, i); ref RGB24 dp = ref Unsafe.Add(ref destRef, i);
dp = Unsafe.As<Color, RGB24>(ref sp); dp = Unsafe.As<Rgba32, RGB24>(ref sp);
} }
} }
/// <inheritdoc /> /// <inheritdoc />
internal override unsafe void PackFromXyzwBytes(BufferSpan<byte> sourceBytes, BufferSpan<Color> destColors, int count) internal override unsafe void PackFromXyzwBytes(BufferSpan<byte> sourceBytes, BufferSpan<Rgba32> destColors, int count)
{ {
BufferSpan.Copy(sourceBytes, destColors.AsBytes(), count * sizeof(Color)); BufferSpan.Copy(sourceBytes, destColors.AsBytes(), count * sizeof(Rgba32));
} }
/// <inheritdoc /> /// <inheritdoc />
internal override unsafe void ToXyzwBytes(BufferSpan<Color> sourceColors, BufferSpan<byte> destBytes, int count) internal override unsafe void ToXyzwBytes(BufferSpan<Rgba32> sourceColors, BufferSpan<byte> destBytes, int count)
{ {
BufferSpan.Copy(sourceColors.AsBytes(), destBytes, count * sizeof(Color)); BufferSpan.Copy(sourceColors.AsBytes(), destBytes, count * sizeof(Rgba32));
} }
/// <inheritdoc /> /// <inheritdoc />
internal override void PackFromZyxBytes(BufferSpan<byte> sourceBytes, BufferSpan<Color> destColors, int count) internal override void PackFromZyxBytes(BufferSpan<byte> sourceBytes, BufferSpan<Rgba32> destColors, int count)
{ {
ref RGB24 sourceRef = ref Unsafe.As<byte, RGB24>(ref sourceBytes.DangerousGetPinnableReference()); ref RGB24 sourceRef = ref Unsafe.As<byte, RGB24>(ref sourceBytes.DangerousGetPinnableReference());
ref Color destRef = ref destColors.DangerousGetPinnableReference(); ref Rgba32 destRef = ref destColors.DangerousGetPinnableReference();
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
ref RGB24 sp = ref Unsafe.Add(ref sourceRef, i); ref RGB24 sp = ref Unsafe.Add(ref sourceRef, i);
ref Color dp = ref Unsafe.Add(ref destRef, i); ref Rgba32 dp = ref Unsafe.Add(ref destRef, i);
Unsafe.As<Color, RGB24>(ref dp) = sp.ToZyx(); Unsafe.As<Rgba32, RGB24>(ref dp) = sp.ToZyx();
dp.A = 255; dp.A = 255;
} }
} }
/// <inheritdoc /> /// <inheritdoc />
internal override void ToZyxBytes(BufferSpan<Color> sourceColors, BufferSpan<byte> destBytes, int count) internal override void ToZyxBytes(BufferSpan<Rgba32> sourceColors, BufferSpan<byte> destBytes, int count)
{ {
ref Color sourceRef = ref sourceColors.DangerousGetPinnableReference(); ref Rgba32 sourceRef = ref sourceColors.DangerousGetPinnableReference();
ref RGB24 destRef = ref Unsafe.As<byte, RGB24>(ref destBytes.DangerousGetPinnableReference()); ref RGB24 destRef = ref Unsafe.As<byte, RGB24>(ref destBytes.DangerousGetPinnableReference());
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
ref Color sp = ref Unsafe.Add(ref sourceRef, i); ref Rgba32 sp = ref Unsafe.Add(ref sourceRef, i);
ref RGB24 dp = ref Unsafe.Add(ref destRef, i); ref RGB24 dp = ref Unsafe.Add(ref destRef, i);
dp = Unsafe.As<Color, RGB24>(ref sp).ToZyx(); dp = Unsafe.As<Rgba32, RGB24>(ref sp).ToZyx();
} }
} }
/// <inheritdoc /> /// <inheritdoc />
internal override void PackFromZyxwBytes(BufferSpan<byte> sourceBytes, BufferSpan<Color> destColors, int count) internal override void PackFromZyxwBytes(BufferSpan<byte> sourceBytes, BufferSpan<Rgba32> destColors, int count)
{ {
ref RGBA32 sourceRef = ref Unsafe.As<byte, RGBA32>(ref sourceBytes.DangerousGetPinnableReference()); ref RGBA32 sourceRef = ref Unsafe.As<byte, RGBA32>(ref sourceBytes.DangerousGetPinnableReference());
ref Color destRef = ref destColors.DangerousGetPinnableReference(); ref Rgba32 destRef = ref destColors.DangerousGetPinnableReference();
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
ref RGBA32 sp = ref Unsafe.Add(ref sourceRef, i); ref RGBA32 sp = ref Unsafe.Add(ref sourceRef, i);
ref Color dp = ref Unsafe.Add(ref destRef, i); ref Rgba32 dp = ref Unsafe.Add(ref destRef, i);
RGBA32 zyxw = sp.ToZyxw(); RGBA32 zyxw = sp.ToZyxw();
dp = Unsafe.As<RGBA32, Color>(ref zyxw); dp = Unsafe.As<RGBA32, Rgba32>(ref zyxw);
} }
} }
/// <inheritdoc /> /// <inheritdoc />
internal override void ToZyxwBytes(BufferSpan<Color> sourceColors, BufferSpan<byte> destBytes, int count) internal override void ToZyxwBytes(BufferSpan<Rgba32> sourceColors, BufferSpan<byte> destBytes, int count)
{ {
ref Color sourceRef = ref sourceColors.DangerousGetPinnableReference(); ref Rgba32 sourceRef = ref sourceColors.DangerousGetPinnableReference();
ref RGBA32 destRef = ref Unsafe.As<byte, RGBA32>(ref destBytes.DangerousGetPinnableReference()); ref RGBA32 destRef = ref Unsafe.As<byte, RGBA32>(ref destBytes.DangerousGetPinnableReference());
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
ref RGBA32 sp = ref Unsafe.As<Color, RGBA32>(ref Unsafe.Add(ref sourceRef, i)); ref RGBA32 sp = ref Unsafe.As<Rgba32, RGBA32>(ref Unsafe.Add(ref sourceRef, i));
ref RGBA32 dp = ref Unsafe.Add(ref destRef, i); ref RGBA32 dp = ref Unsafe.Add(ref destRef, i);
dp = sp.ToZyxw(); dp = sp.ToZyxw();
} }
@ -264,7 +264,7 @@ namespace ImageSharp
} }
/// <summary> /// <summary>
/// Value type to store <see cref="Color"/>-s unpacked into multiple <see cref="uint"/>-s. /// Value type to store <see cref="Rgba32"/>-s unpacked into multiple <see cref="uint"/>-s.
/// </summary> /// </summary>
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
private struct UnpackedRGBA private struct UnpackedRGBA

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

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

64
src/ImageSharp/Colors/Color.Transforms.cs → src/ImageSharp/Colors/Rgba32.Transforms.cs

@ -1,4 +1,4 @@
// <copyright file="Color.Transforms.cs" company="James Jackson-South"> // <copyright file="Rgba32.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>
@ -16,7 +16,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 Color public partial struct Rgba32
{ {
/// <summary> /// <summary>
/// Adds the second color to the first. /// Adds the second color to the first.
@ -24,10 +24,10 @@ 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="Color"/>. /// The <see cref="Rgba32"/>.
/// </returns> /// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Color operator +(Color left, Color right) public static Rgba32 operator +(Rgba32 left, Rgba32 right)
{ {
Vector4 add = left.ToVector4() + right.ToVector4(); Vector4 add = left.ToVector4() + right.ToVector4();
return PackNew(ref add); return PackNew(ref add);
@ -39,10 +39,10 @@ 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="Color"/>. /// The <see cref="Rgba32"/>.
/// </returns> /// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Color operator -(Color left, Color right) public static Rgba32 operator -(Rgba32 left, Rgba32 right)
{ {
Vector4 sub = left.ToVector4() - right.ToVector4(); Vector4 sub = left.ToVector4() - right.ToVector4();
return PackNew(ref sub); return PackNew(ref sub);
@ -54,9 +54,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="Color"/>. /// The <see cref="Rgba32"/>.
/// </returns> /// </returns>
public static Color Normal(Color backdrop, Color source) public static Rgba32 Normal(Rgba32 backdrop, Rgba32 source)
{ {
Vector4 normal = Vector4BlendTransforms.Normal(backdrop.ToVector4(), source.ToVector4()); Vector4 normal = Vector4BlendTransforms.Normal(backdrop.ToVector4(), source.ToVector4());
return PackNew(ref normal); return PackNew(ref normal);
@ -74,9 +74,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="Color"/>. /// The <see cref="Rgba32"/>.
/// </returns> /// </returns>
public static Color Multiply(Color backdrop, Color source) public static Rgba32 Multiply(Rgba32 backdrop, Rgba32 source)
{ {
Vector4 multiply = Vector4BlendTransforms.Multiply(backdrop.ToVector4(), source.ToVector4()); Vector4 multiply = Vector4BlendTransforms.Multiply(backdrop.ToVector4(), source.ToVector4());
return PackNew(ref multiply); return PackNew(ref multiply);
@ -93,9 +93,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="Color"/>. /// The <see cref="Rgba32"/>.
/// </returns> /// </returns>
public static Color Screen(Color backdrop, Color source) public static Rgba32 Screen(Rgba32 backdrop, Rgba32 source)
{ {
Vector4 subtract = Vector4BlendTransforms.Screen(backdrop.ToVector4(), source.ToVector4()); Vector4 subtract = Vector4BlendTransforms.Screen(backdrop.ToVector4(), source.ToVector4());
return PackNew(ref subtract); return PackNew(ref subtract);
@ -108,9 +108,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="Color"/>. /// The <see cref="Rgba32"/>.
/// </returns> /// </returns>
public static Color HardLight(Color backdrop, Color source) public static Rgba32 HardLight(Rgba32 backdrop, Rgba32 source)
{ {
Vector4 hardlight = Vector4BlendTransforms.HardLight(backdrop.ToVector4(), source.ToVector4()); Vector4 hardlight = Vector4BlendTransforms.HardLight(backdrop.ToVector4(), source.ToVector4());
return PackNew(ref hardlight); return PackNew(ref hardlight);
@ -127,9 +127,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="Color"/>. /// The <see cref="Rgba32"/>.
/// </returns> /// </returns>
public static Color Overlay(Color backdrop, Color source) public static Rgba32 Overlay(Rgba32 backdrop, Rgba32 source)
{ {
Vector4 overlay = Vector4BlendTransforms.Overlay(backdrop.ToVector4(), source.ToVector4()); Vector4 overlay = Vector4BlendTransforms.Overlay(backdrop.ToVector4(), source.ToVector4());
return PackNew(ref overlay); return PackNew(ref overlay);
@ -142,9 +142,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="Color"/>. /// The <see cref="Rgba32"/>.
/// </returns> /// </returns>
public static Color Darken(Color backdrop, Color source) public static Rgba32 Darken(Rgba32 backdrop, Rgba32 source)
{ {
Vector4 darken = Vector4BlendTransforms.Darken(backdrop.ToVector4(), source.ToVector4()); Vector4 darken = Vector4BlendTransforms.Darken(backdrop.ToVector4(), source.ToVector4());
return PackNew(ref darken); return PackNew(ref darken);
@ -157,9 +157,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="Color"/>. /// The <see cref="Rgba32"/>.
/// </returns> /// </returns>
public static Color Lighten(Color backdrop, Color source) public static Rgba32 Lighten(Rgba32 backdrop, Rgba32 source)
{ {
Vector4 lighten = Vector4BlendTransforms.Lighten(backdrop.ToVector4(), source.ToVector4()); Vector4 lighten = Vector4BlendTransforms.Lighten(backdrop.ToVector4(), source.ToVector4());
return PackNew(ref lighten); return PackNew(ref lighten);
@ -172,9 +172,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="Color"/>. /// The <see cref="Rgba32"/>.
/// </returns> /// </returns>
public static Color SoftLight(Color backdrop, Color source) public static Rgba32 SoftLight(Rgba32 backdrop, Rgba32 source)
{ {
Vector4 softlight = Vector4BlendTransforms.SoftLight(backdrop.ToVector4(), source.ToVector4()); Vector4 softlight = Vector4BlendTransforms.SoftLight(backdrop.ToVector4(), source.ToVector4());
return PackNew(ref softlight); return PackNew(ref softlight);
@ -186,9 +186,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="Color"/>. /// The <see cref="Rgba32"/>.
/// </returns> /// </returns>
public static Color ColorDodge(Color backdrop, Color source) public static Rgba32 ColorDodge(Rgba32 backdrop, Rgba32 source)
{ {
Vector4 dodge = Vector4BlendTransforms.Dodge(backdrop.ToVector4(), source.ToVector4()); Vector4 dodge = Vector4BlendTransforms.Dodge(backdrop.ToVector4(), source.ToVector4());
return PackNew(ref dodge); return PackNew(ref dodge);
@ -200,9 +200,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="Color"/>. /// The <see cref="Rgba32"/>.
/// </returns> /// </returns>
public static Color ColorBurn(Color backdrop, Color source) public static Rgba32 ColorBurn(Rgba32 backdrop, Rgba32 source)
{ {
Vector4 burn = Vector4BlendTransforms.Burn(backdrop.ToVector4(), source.ToVector4()); Vector4 burn = Vector4BlendTransforms.Burn(backdrop.ToVector4(), source.ToVector4());
return PackNew(ref burn); return PackNew(ref burn);
@ -215,9 +215,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="Color"/>. /// The <see cref="Rgba32"/>.
/// </returns> /// </returns>
public static Color Difference(Color backdrop, Color source) public static Rgba32 Difference(Rgba32 backdrop, Rgba32 source)
{ {
Vector4 difference = Vector4BlendTransforms.Difference(backdrop.ToVector4(), source.ToVector4()); Vector4 difference = Vector4BlendTransforms.Difference(backdrop.ToVector4(), source.ToVector4());
return PackNew(ref difference); return PackNew(ref difference);
@ -230,9 +230,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="Color"/>. /// The <see cref="Rgba32"/>.
/// </returns> /// </returns>
public static Color Exclusion(Color backdrop, Color source) public static Rgba32 Exclusion(Rgba32 backdrop, Rgba32 source)
{ {
Vector4 exclusion = Vector4BlendTransforms.Exclusion(backdrop.ToVector4(), source.ToVector4()); Vector4 exclusion = Vector4BlendTransforms.Exclusion(backdrop.ToVector4(), source.ToVector4());
return PackNew(ref exclusion); return PackNew(ref exclusion);
@ -248,9 +248,9 @@ 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="Color"/> /// The <see cref="Rgba32"/>
/// </returns> /// </returns>
public static Color Lerp(Color from, Color to, float amount) public static Rgba32 Lerp(Rgba32 from, Rgba32 to, float amount)
{ {
Vector4 lerp = Vector4.Lerp(from.ToVector4(), to.ToVector4(), amount); Vector4 lerp = Vector4.Lerp(from.ToVector4(), to.ToVector4(), amount);
return PackNew(ref lerp); return PackNew(ref lerp);

60
src/ImageSharp/Colors/Color.cs → src/ImageSharp/Colors/Rgba32.cs

@ -1,4 +1,4 @@
// <copyright file="Color.cs" company="James Jackson-South"> // <copyright file="Rgba32.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>
@ -18,7 +18,7 @@ namespace ImageSharp
/// 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)] [StructLayout(LayoutKind.Explicit)]
public partial struct Color : IPixel<Color>, IPackedVector<uint> public partial struct Rgba32 : IPixel<Rgba32>, IPackedVector<uint>
{ {
/// <summary> /// <summary>
/// Gets or sets the red component. /// Gets or sets the red component.
@ -81,14 +81,14 @@ 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="Color"/> struct. /// Initializes a new instance of the <see cref="Rgba32"/> 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>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public Color(byte r, byte g, byte b, byte a = 255) public Rgba32(byte r, byte g, byte b, byte a = 255)
: this() : this()
{ {
this.R = r; this.R = r;
@ -98,53 +98,53 @@ namespace ImageSharp
} }
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Color"/> struct. /// Initializes a new instance of the <see cref="Rgba32"/> 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>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public Color(float r, float g, float b, float a = 1) public Rgba32(float r, float g, float b, float a = 1)
: this() : this()
{ {
this.Pack(r, g, b, a); this.Pack(r, g, b, a);
} }
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Color"/> struct. /// Initializes a new instance of the <see cref="Rgba32"/> 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>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public Color(Vector3 vector) public Rgba32(Vector3 vector)
: this() : this()
{ {
this.Pack(ref vector); this.Pack(ref vector);
} }
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Color"/> struct. /// Initializes a new instance of the <see cref="Rgba32"/> 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>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public Color(Vector4 vector) public Rgba32(Vector4 vector)
: this() : this()
{ {
this = PackNew(ref vector); this = PackNew(ref vector);
} }
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Color"/> struct. /// Initializes a new instance of the <see cref="Rgba32"/> struct.
/// </summary> /// </summary>
/// <param name="packed"> /// <param name="packed">
/// The packed value. /// The packed value.
/// </param> /// </param>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public Color(uint packed) public Rgba32(uint packed)
: this() : this()
{ {
this.Rgba = packed; this.Rgba = packed;
@ -154,54 +154,54 @@ namespace ImageSharp
public uint PackedValue { get => this.Rgba; set => this.Rgba = value; } public uint PackedValue { get => this.Rgba; set => this.Rgba = value; }
/// <summary> /// <summary>
/// Compares two <see cref="Color"/> objects for equality. /// Compares two <see cref="Rgba32"/> objects for equality.
/// </summary> /// </summary>
/// <param name="left"> /// <param name="left">
/// The <see cref="Color"/> on the left side of the operand. /// The <see cref="Rgba32"/> on the left side of the operand.
/// </param> /// </param>
/// <param name="right"> /// <param name="right">
/// The <see cref="Color"/> on the right side of the operand. /// The <see cref="Rgba32"/> 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 ==(Color left, Color right) public static bool operator ==(Rgba32 left, Rgba32 right)
{ {
return left.Rgba == right.Rgba; return left.Rgba == right.Rgba;
} }
/// <summary> /// <summary>
/// Compares two <see cref="Color"/> objects for equality. /// Compares two <see cref="Rgba32"/> objects for equality.
/// </summary> /// </summary>
/// <param name="left">The <see cref="Color"/> on the left side of the operand.</param> /// <param name="left">The <see cref="Rgba32"/> on the left side of the operand.</param>
/// <param name="right">The <see cref="Color"/> on the right side of the operand.</param> /// <param name="right">The <see cref="Rgba32"/> 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 !=(Color left, Color right) public static bool operator !=(Rgba32 left, Rgba32 right)
{ {
return left.Rgba != right.Rgba; return left.Rgba != right.Rgba;
} }
/// <summary> /// <summary>
/// Creates a new instance of the <see cref="Color"/> struct. /// Creates a new instance of the <see cref="Rgba32"/> 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="Color"/>. /// The <see cref="Rgba32"/>.
/// </returns> /// </returns>
public static Color FromHex(string hex) public static Rgba32 FromHex(string hex)
{ {
return ColorBuilder<Color>.FromHex(hex); return ColorBuilder<Rgba32>.FromHex(hex);
} }
/// <inheritdoc /> /// <inheritdoc />
public BulkPixelOperations<Color> CreateBulkOperations() => new BulkOperations(); public BulkPixelOperations<Rgba32> CreateBulkOperations() => new BulkOperations();
/// <inheritdoc/> /// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
@ -278,12 +278,12 @@ namespace ImageSharp
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
return (obj is Color) && this.Equals((Color)obj); return (obj is Rgba32) && this.Equals((Rgba32)obj);
} }
/// <inheritdoc/> /// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool Equals(Color other) public bool Equals(Rgba32 other)
{ {
return this.Rgba == other.Rgba; return this.Rgba == other.Rgba;
} }
@ -328,15 +328,15 @@ namespace ImageSharp
/// Packs a <see cref="Vector4"/> into a color returning a new instance as a result. /// Packs a <see cref="Vector4"/> into a color returning a new instance as a result.
/// </summary> /// </summary>
/// <param name="vector">The vector containing the values to pack.</param> /// <param name="vector">The vector containing the values to pack.</param>
/// <returns>The <see cref="Color"/></returns> /// <returns>The <see cref="Rgba32"/></returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
private static Color PackNew(ref Vector4 vector) private static Rgba32 PackNew(ref Vector4 vector)
{ {
vector *= MaxBytes; vector *= MaxBytes;
vector += Half; vector += Half;
vector = Vector4.Clamp(vector, Vector4.Zero, MaxBytes); vector = Vector4.Clamp(vector, Vector4.Zero, MaxBytes);
return new Color((byte)vector.X, (byte)vector.Y, (byte)vector.Z, (byte)vector.W); return new Rgba32((byte)vector.X, (byte)vector.Y, (byte)vector.Z, (byte)vector.W);
} }
/// <summary> /// <summary>

15
src/ImageSharp/Colors/ColorVector.BulkOperations.cs → src/ImageSharp/Colors/RgbaVector.BulkOperations.cs

@ -1,4 +1,9 @@
namespace ImageSharp // <copyright file="RgbaVector.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.Numerics; using System.Numerics;
@ -10,15 +15,15 @@
/// 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 ColorVector public partial struct RgbaVector
{ {
/// <summary> /// <summary>
/// <see cref="BulkPixelOperations{TColor}"/> implementation optimized for <see cref="ColorVector"/>. /// <see cref="BulkPixelOperations{TColor}"/> implementation optimized for <see cref="RgbaVector"/>.
/// </summary> /// </summary>
internal class BulkOperations : BulkPixelOperations<ColorVector> internal class BulkOperations : BulkPixelOperations<RgbaVector>
{ {
/// <inheritdoc /> /// <inheritdoc />
internal override unsafe void ToVector4(BufferSpan<ColorVector> sourceColors, BufferSpan<Vector4> destVectors, int count) internal override unsafe void ToVector4(BufferSpan<RgbaVector> sourceColors, BufferSpan<Vector4> destVectors, int count)
{ {
BufferSpan.Copy(sourceColors.AsBytes(), destVectors.AsBytes(), count * sizeof(Vector4)); BufferSpan.Copy(sourceColors.AsBytes(), destVectors.AsBytes(), count * sizeof(Vector4));
} }

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

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

94
src/ImageSharp/Colors/ColorVector.Transforms.cs → src/ImageSharp/Colors/RgbaVector.Transforms.cs

@ -1,4 +1,4 @@
// <copyright file="ColorVector.Transforms.cs" company="James Jackson-South"> // <copyright file="RgbaVector.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>
@ -16,7 +16,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 ColorVector public partial struct RgbaVector
{ {
/// <summary> /// <summary>
/// Adds the second color to the first. /// Adds the second color to the first.
@ -24,12 +24,12 @@ 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="ColorVector"/>. /// The <see cref="RgbaVector"/>.
/// </returns> /// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ColorVector operator +(ColorVector left, ColorVector right) public static RgbaVector operator +(RgbaVector left, RgbaVector right)
{ {
return new ColorVector(left.backingVector + right.backingVector); return new RgbaVector(left.backingVector + right.backingVector);
} }
/// <summary> /// <summary>
@ -38,12 +38,12 @@ 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="ColorVector"/>. /// The <see cref="RgbaVector"/>.
/// </returns> /// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ColorVector operator -(ColorVector left, ColorVector right) public static RgbaVector operator -(RgbaVector left, RgbaVector right)
{ {
return new ColorVector(left.backingVector - right.backingVector); return new RgbaVector(left.backingVector - right.backingVector);
} }
/// <summary> /// <summary>
@ -52,12 +52,12 @@ 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="ColorVector"/>. /// The <see cref="RgbaVector"/>.
/// </returns> /// </returns>
public static ColorVector Normal(ColorVector backdrop, ColorVector source) public static RgbaVector Normal(RgbaVector backdrop, RgbaVector source)
{ {
Vector4 normal = Vector4BlendTransforms.Normal(backdrop.backingVector, source.backingVector); Vector4 normal = Vector4BlendTransforms.Normal(backdrop.backingVector, source.backingVector);
return new ColorVector(normal); return new RgbaVector(normal);
} }
/// <summary> /// <summary>
@ -72,12 +72,12 @@ 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="ColorVector"/>. /// The <see cref="RgbaVector"/>.
/// </returns> /// </returns>
public static ColorVector Multiply(ColorVector backdrop, ColorVector source) public static RgbaVector Multiply(RgbaVector backdrop, RgbaVector source)
{ {
Vector4 multiply = Vector4BlendTransforms.Multiply(backdrop.backingVector, source.backingVector); Vector4 multiply = Vector4BlendTransforms.Multiply(backdrop.backingVector, source.backingVector);
return new ColorVector(multiply); return new RgbaVector(multiply);
} }
/// <summary> /// <summary>
@ -91,12 +91,12 @@ 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="ColorVector"/>. /// The <see cref="RgbaVector"/>.
/// </returns> /// </returns>
public static ColorVector Screen(ColorVector backdrop, ColorVector source) public static RgbaVector Screen(RgbaVector backdrop, RgbaVector source)
{ {
Vector4 subtract = Vector4BlendTransforms.Screen(backdrop.backingVector, source.backingVector); Vector4 subtract = Vector4BlendTransforms.Screen(backdrop.backingVector, source.backingVector);
return new ColorVector(subtract); return new RgbaVector(subtract);
} }
/// <summary> /// <summary>
@ -106,12 +106,12 @@ 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="ColorVector"/>. /// The <see cref="RgbaVector"/>.
/// </returns> /// </returns>
public static ColorVector HardLight(ColorVector backdrop, ColorVector source) public static RgbaVector HardLight(RgbaVector backdrop, RgbaVector source)
{ {
Vector4 hardlight = Vector4BlendTransforms.HardLight(backdrop.backingVector, source.backingVector); Vector4 hardlight = Vector4BlendTransforms.HardLight(backdrop.backingVector, source.backingVector);
return new ColorVector(hardlight); return new RgbaVector(hardlight);
} }
/// <summary> /// <summary>
@ -125,12 +125,12 @@ 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="ColorVector"/>. /// The <see cref="RgbaVector"/>.
/// </returns> /// </returns>
public static ColorVector Overlay(ColorVector backdrop, ColorVector source) public static RgbaVector Overlay(RgbaVector backdrop, RgbaVector source)
{ {
Vector4 overlay = Vector4BlendTransforms.Overlay(backdrop.backingVector, source.backingVector); Vector4 overlay = Vector4BlendTransforms.Overlay(backdrop.backingVector, source.backingVector);
return new ColorVector(overlay); return new RgbaVector(overlay);
} }
/// <summary> /// <summary>
@ -140,12 +140,12 @@ 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="ColorVector"/>. /// The <see cref="RgbaVector"/>.
/// </returns> /// </returns>
public static ColorVector Darken(ColorVector backdrop, ColorVector source) public static RgbaVector Darken(RgbaVector backdrop, RgbaVector source)
{ {
Vector4 darken = Vector4BlendTransforms.Darken(backdrop.backingVector, source.backingVector); Vector4 darken = Vector4BlendTransforms.Darken(backdrop.backingVector, source.backingVector);
return new ColorVector(darken); return new RgbaVector(darken);
} }
/// <summary> /// <summary>
@ -155,12 +155,12 @@ 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="ColorVector"/>. /// The <see cref="RgbaVector"/>.
/// </returns> /// </returns>
public static ColorVector Lighten(ColorVector backdrop, ColorVector source) public static RgbaVector Lighten(RgbaVector backdrop, RgbaVector source)
{ {
Vector4 lighten = Vector4BlendTransforms.Lighten(backdrop.backingVector, source.backingVector); Vector4 lighten = Vector4BlendTransforms.Lighten(backdrop.backingVector, source.backingVector);
return new ColorVector(lighten); return new RgbaVector(lighten);
} }
/// <summary> /// <summary>
@ -170,12 +170,12 @@ 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="ColorVector"/>. /// The <see cref="RgbaVector"/>.
/// </returns> /// </returns>
public static ColorVector SoftLight(ColorVector backdrop, ColorVector source) public static RgbaVector SoftLight(RgbaVector backdrop, RgbaVector source)
{ {
Vector4 softlight = Vector4BlendTransforms.SoftLight(backdrop.backingVector, source.backingVector); Vector4 softlight = Vector4BlendTransforms.SoftLight(backdrop.backingVector, source.backingVector);
return new ColorVector(softlight); return new RgbaVector(softlight);
} }
/// <summary> /// <summary>
@ -184,12 +184,12 @@ 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="ColorVector"/>. /// The <see cref="RgbaVector"/>.
/// </returns> /// </returns>
public static ColorVector ColorDodge(ColorVector backdrop, ColorVector source) public static RgbaVector ColorDodge(RgbaVector backdrop, RgbaVector source)
{ {
Vector4 dodge = Vector4BlendTransforms.Dodge(backdrop.backingVector, source.backingVector); Vector4 dodge = Vector4BlendTransforms.Dodge(backdrop.backingVector, source.backingVector);
return new ColorVector(dodge); return new RgbaVector(dodge);
} }
/// <summary> /// <summary>
@ -198,12 +198,12 @@ 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="ColorVector"/>. /// The <see cref="RgbaVector"/>.
/// </returns> /// </returns>
public static ColorVector ColorBurn(ColorVector backdrop, ColorVector source) public static RgbaVector ColorBurn(RgbaVector backdrop, RgbaVector source)
{ {
Vector4 burn = Vector4BlendTransforms.Burn(backdrop.backingVector, source.backingVector); Vector4 burn = Vector4BlendTransforms.Burn(backdrop.backingVector, source.backingVector);
return new ColorVector(burn); return new RgbaVector(burn);
} }
/// <summary> /// <summary>
@ -213,12 +213,12 @@ 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="ColorVector"/>. /// The <see cref="RgbaVector"/>.
/// </returns> /// </returns>
public static ColorVector Difference(ColorVector backdrop, ColorVector source) public static RgbaVector Difference(RgbaVector backdrop, RgbaVector source)
{ {
Vector4 difference = Vector4BlendTransforms.Difference(backdrop.backingVector, source.backingVector); Vector4 difference = Vector4BlendTransforms.Difference(backdrop.backingVector, source.backingVector);
return new ColorVector(difference); return new RgbaVector(difference);
} }
/// <summary> /// <summary>
@ -228,12 +228,12 @@ 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="ColorVector"/>. /// The <see cref="RgbaVector"/>.
/// </returns> /// </returns>
public static ColorVector Exclusion(ColorVector backdrop, ColorVector source) public static RgbaVector Exclusion(RgbaVector backdrop, RgbaVector source)
{ {
Vector4 exclusion = Vector4BlendTransforms.Exclusion(backdrop.backingVector, source.backingVector); Vector4 exclusion = Vector4BlendTransforms.Exclusion(backdrop.backingVector, source.backingVector);
return new ColorVector(exclusion); return new RgbaVector(exclusion);
} }
/// <summary> /// <summary>
@ -246,11 +246,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="ColorVector"/> /// The <see cref="RgbaVector"/>
/// </returns> /// </returns>
public static ColorVector Lerp(ColorVector from, ColorVector to, float amount) public static RgbaVector Lerp(RgbaVector from, RgbaVector to, float amount)
{ {
return new ColorVector(Vector4.Lerp(from.backingVector, to.backingVector, amount)); return new RgbaVector(Vector4.Lerp(from.backingVector, to.backingVector, amount));
} }
} }
} }

50
src/ImageSharp/Colors/ColorVector.cs → src/ImageSharp/Colors/RgbaVector.cs

@ -1,4 +1,4 @@
// <copyright file="ColorVector.cs" company="James Jackson-South"> // <copyright file="RgbaVector.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>
@ -16,7 +16,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 ColorVector : IPixel<ColorVector> public partial struct RgbaVector : IPixel<RgbaVector>
{ {
/// <summary> /// <summary>
/// The maximum byte value. /// The maximum byte value.
@ -34,54 +34,54 @@ namespace ImageSharp
private Vector4 backingVector; private Vector4 backingVector;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="ColorVector"/> struct. /// Initializes a new instance of the <see cref="RgbaVector"/> 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>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public ColorVector(byte r, byte g, byte b, byte a = 255) public RgbaVector(byte r, byte g, byte b, byte a = 255)
: this() : this()
{ {
this.backingVector = new Vector4(r, g, b, a) / MaxBytes; this.backingVector = new Vector4(r, g, b, a) / MaxBytes;
} }
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="ColorVector"/> struct. /// Initializes a new instance of the <see cref="RgbaVector"/> 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>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public ColorVector(float r, float g, float b, float a = 1) public RgbaVector(float r, float g, float b, float a = 1)
: this() : this()
{ {
this.backingVector = new Vector4(r, g, b, a); this.backingVector = new Vector4(r, g, b, a);
} }
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="ColorVector"/> struct. /// Initializes a new instance of the <see cref="RgbaVector"/> 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>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public ColorVector(Vector3 vector) public RgbaVector(Vector3 vector)
: this() : this()
{ {
this.backingVector = new Vector4(vector, 1); this.backingVector = new Vector4(vector, 1);
} }
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="ColorVector"/> struct. /// Initializes a new instance of the <see cref="RgbaVector"/> 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>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public ColorVector(Vector4 vector) public RgbaVector(Vector4 vector)
: this() : this()
{ {
this.backingVector = vector; this.backingVector = vector;
@ -160,54 +160,54 @@ namespace ImageSharp
} }
/// <summary> /// <summary>
/// Compares two <see cref="ColorVector"/> objects for equality. /// Compares two <see cref="RgbaVector"/> objects for equality.
/// </summary> /// </summary>
/// <param name="left"> /// <param name="left">
/// The <see cref="ColorVector"/> on the left side of the operand. /// The <see cref="RgbaVector"/> on the left side of the operand.
/// </param> /// </param>
/// <param name="right"> /// <param name="right">
/// The <see cref="ColorVector"/> on the right side of the operand. /// The <see cref="RgbaVector"/> 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 ==(ColorVector left, ColorVector right) public static bool operator ==(RgbaVector left, RgbaVector right)
{ {
return left.backingVector == right.backingVector; return left.backingVector == right.backingVector;
} }
/// <summary> /// <summary>
/// Compares two <see cref="ColorVector"/> objects for equality. /// Compares two <see cref="RgbaVector"/> objects for equality.
/// </summary> /// </summary>
/// <param name="left">The <see cref="ColorVector"/> on the left side of the operand.</param> /// <param name="left">The <see cref="RgbaVector"/> on the left side of the operand.</param>
/// <param name="right">The <see cref="ColorVector"/> on the right side of the operand.</param> /// <param name="right">The <see cref="RgbaVector"/> 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 !=(ColorVector left, ColorVector right) public static bool operator !=(RgbaVector left, RgbaVector right)
{ {
return left.backingVector != right.backingVector; return left.backingVector != right.backingVector;
} }
/// <summary> /// <summary>
/// Creates a new instance of the <see cref="ColorVector"/> struct. /// Creates a new instance of the <see cref="RgbaVector"/> 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="ColorVector"/>. /// The <see cref="RgbaVector"/>.
/// </returns> /// </returns>
public static ColorVector FromHex(string hex) public static RgbaVector FromHex(string hex)
{ {
return ColorBuilder<ColorVector>.FromHex(hex); return ColorBuilder<RgbaVector>.FromHex(hex);
} }
/// <inheritdoc /> /// <inheritdoc />
public BulkPixelOperations<ColorVector> CreateBulkOperations() => new ColorVector.BulkOperations(); public BulkPixelOperations<RgbaVector> CreateBulkOperations() => new RgbaVector.BulkOperations();
/// <inheritdoc/> /// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
@ -292,12 +292,12 @@ namespace ImageSharp
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
return (obj is ColorVector) && this.Equals((ColorVector)obj); return (obj is RgbaVector) && this.Equals((RgbaVector)obj);
} }
/// <inheritdoc/> /// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool Equals(ColorVector other) public bool Equals(RgbaVector other)
{ {
return this.backingVector == other.backingVector; return this.backingVector == other.backingVector;
} }

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="Color"/> to a /// Allows the implicit conversion of an instance of <see cref="Rgba32"/> to a
/// <see cref="Bgra32"/>. /// <see cref="Bgra32"/>.
/// </summary> /// </summary>
/// <param name="color"> /// <param name="color">
/// The instance of <see cref="Color"/> to convert. /// The instance of <see cref="Rgba32"/> 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(Color color) public static implicit operator Bgra32(Rgba32 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="Color"/> to a /// Allows the implicit conversion of an instance of <see cref="Rgba32"/> to a
/// <see cref="CieLab"/>. /// <see cref="CieLab"/>.
/// </summary> /// </summary>
/// <param name="color"> /// <param name="color">
/// The instance of <see cref="Color"/> to convert. /// The instance of <see cref="Rgba32"/> 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(Color color) public static implicit operator CieLab(Rgba32 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="Color"/> to a /// Allows the implicit conversion of an instance of <see cref="Rgba32"/> to a
/// <see cref="CieXyz"/>. /// <see cref="CieXyz"/>.
/// </summary> /// </summary>
/// <param name="color"> /// <param name="color">
/// The instance of <see cref="Color"/> to convert. /// The instance of <see cref="Rgba32"/> 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(Color color) public static implicit operator CieXyz(Rgba32 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="Color"/> to a /// Allows the implicit conversion of an instance of <see cref="Rgba32"/> 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(Color color) public static implicit operator Cmyk(Rgba32 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="Color"/> to a /// Allows the implicit conversion of an instance of <see cref="Rgba32"/> to a
/// <see cref="Hsl"/>. /// <see cref="Hsl"/>.
/// </summary> /// </summary>
/// <param name="color">The instance of <see cref="Color"/> to convert.</param> /// <param name="color">The instance of <see cref="Rgba32"/> to convert.</param>
/// <returns> /// <returns>
/// An instance of <see cref="Hsl"/>. /// An instance of <see cref="Hsl"/>.
/// </returns> /// </returns>
public static implicit operator Hsl(Color color) public static implicit operator Hsl(Rgba32 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="Color"/> to a /// Allows the implicit conversion of an instance of <see cref="Rgba32"/> to a
/// <see cref="Hsv"/>. /// <see cref="Hsv"/>.
/// </summary> /// </summary>
/// <param name="color">The instance of <see cref="Color"/> to convert.</param> /// <param name="color">The instance of <see cref="Rgba32"/> to convert.</param>
/// <returns> /// <returns>
/// An instance of <see cref="Hsv"/>. /// An instance of <see cref="Hsv"/>.
/// </returns> /// </returns>
public static implicit operator Hsv(Color color) public static implicit operator Hsv(Rgba32 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="Color"/> to a /// Allows the implicit conversion of an instance of <see cref="Rgba32"/> to a
/// <see cref="YCbCr"/>. /// <see cref="YCbCr"/>.
/// </summary> /// </summary>
/// <param name="color"> /// <param name="color">
/// The instance of <see cref="Color"/> to convert. /// The instance of <see cref="Rgba32"/> 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(Color color) public static implicit operator YCbCr(Rgba32 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="Color"/> whose signal to expand.</param> /// <param name="gamma">The <see cref="Rgba32"/> 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)
{ {

14
src/ImageSharp/Image.Create.cs

@ -5,12 +5,6 @@
namespace ImageSharp namespace ImageSharp
{ {
using System;
using System.Diagnostics;
using System.IO;
using Formats;
/// <summary> /// <summary>
/// Represents an image. Each pixel is a made up four 8-bit components red, green, blue, and alpha /// Represents an image. Each pixel is a made up four 8-bit components red, green, blue, and alpha
/// packed into a single unsigned integer value. /// packed into a single unsigned integer value.
@ -29,12 +23,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="Color"/> in which case it returns <see cref="Image" /> /// A new <see cref="Image{TColor}"/> unless <typeparamref name="TColor"/> is <see cref="Rgba32"/> 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(Color)) if (typeof(TColor) == typeof(Rgba32))
{ {
return new Image(width, height, metadata, configuration) as Image<TColor>; return new Image(width, height, metadata, configuration) as Image<TColor>;
} }
@ -55,7 +49,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="Color"/> in which case it returns <see cref="Image" /> /// A new <see cref="Image{TColor}"/> unless <typeparamref name="TColor"/> is <see cref="Rgba32"/> 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>
@ -63,4 +57,4 @@ namespace ImageSharp
return Image.Create<TColor>(width, height, null, configuration); return Image.Create<TColor>(width, height, null, configuration);
} }
} }
} }

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<Color>(path, decoder, options)); return new Image(Load<Rgba32>(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<Color> image = Load<Color>(config, stream, options); Image<Rgba32> image = Load<Rgba32>(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<Color> image = new Image(Load<Color>(stream, decoder, options)); Image<Rgba32> image = new Image(Load<Rgba32>(stream, decoder, options));
return image as Image ?? new Image(image); return image as Image ?? new Image(image);
} }

10
src/ImageSharp/Image.cs

@ -5,18 +5,14 @@
namespace ImageSharp namespace ImageSharp
{ {
using System;
using System.Diagnostics; using System.Diagnostics;
using System.IO;
using Formats;
/// <summary> /// <summary>
/// Represents an image. Each pixel is a made up four 8-bit components red, green, blue, and alpha /// Represents an image. Each pixel is a made up four 8-bit components red, green, blue, and alpha
/// 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<Color> public sealed partial class Image : Image<Rgba32>
{ {
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Image"/> class /// Initializes a new instance of the <see cref="Image"/> class
@ -49,7 +45,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<Color> other) public Image(Image<Rgba32> other)
: base(other) : base(other)
{ {
} }
@ -69,4 +65,4 @@ namespace ImageSharp
{ {
} }
} }
} }

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="Color"/>. /// The <see cref="Rgba32"/>.
/// </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)
{ {
Color[] constants = ColorConstants.WebSafeColors; Rgba32[] 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.Color> destination; private Buffer<ImageSharp.Rgba32> 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.Color>(this.Count); this.destination = new Buffer<ImageSharp.Rgba32>(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.Color); int size = sizeof(ImageSharp.Rgba32);
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.Color c = default(ImageSharp.Color); ImageSharp.Rgba32 c = default(ImageSharp.Rgba32);
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.Color dp = ref this.destination.Array[0]; ref ImageSharp.Rgba32 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 Color = ImageSharp.Color; using Rgba32 = ImageSharp.Rgba32;
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<Color> public class PackFromXyzw_Color : PackFromXyzw<Rgba32>
{ {
} }
} }

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

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

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

@ -3,7 +3,7 @@ namespace ImageSharp.Benchmarks.Color.Bulk
{ {
using BenchmarkDotNet.Attributes; using BenchmarkDotNet.Attributes;
using Color = ImageSharp.Color; using Rgba32 = ImageSharp.Rgba32;
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<Color> public class ToXyz_Color : ToXyz<Rgba32>
{ {
} }
} }

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

@ -8,7 +8,7 @@ namespace ImageSharp.Benchmarks.Color.Bulk
{ {
using BenchmarkDotNet.Attributes; using BenchmarkDotNet.Attributes;
using Color = ImageSharp.Color; using Rgba32 = ImageSharp.Rgba32;
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<Color> public class ToXyzw_Color : ToXyzw<Rgba32>
{ {
} }

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

@ -7,7 +7,7 @@ namespace ImageSharp.Benchmarks
{ {
using BenchmarkDotNet.Attributes; using BenchmarkDotNet.Attributes;
using CoreColor = ImageSharp.Color; using CoreColor = ImageSharp.Rgba32;
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.Color; using CoreColor = ImageSharp.Rgba32;
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.Color; using CoreColor = ImageSharp.Rgba32;
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.Color; using CoreColor = ImageSharp.Rgba32;
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.Color; using CoreColor = ImageSharp.Rgba32;
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.Color; using CoreColor = ImageSharp.Rgba32;
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.Color; using CoreColor = ImageSharp.Rgba32;
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 Color = ImageSharp.Color; using Rgba32 = ImageSharp.Rgba32;
public unsafe class ClearBuffer public unsafe class ClearBuffer
{ {
private Buffer<Color> buffer; private Buffer<Rgba32> 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.Color>(this.Count); this.buffer = new Buffer<ImageSharp.Rgba32>(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.Color; using CoreColor = ImageSharp.Rgba32;
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<Color>(), Quality = 256 }; PngEncoderOptions options = new PngEncoderOptions() { Quantizer = new OctreeQuantizer<Rgba32>(), 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<Color> { Dither = false }, Quality = 256 }; PngEncoderOptions options = new PngEncoderOptions { Quantizer = new OctreeQuantizer<Rgba32> { 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<Color>(), Quality = 256 }; PngEncoderOptions options = new PngEncoderOptions { Quantizer = new PaletteQuantizer<Rgba32>(), 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<Color> { Dither = false }, Quality = 256 }; PngEncoderOptions options = new PngEncoderOptions { Quantizer = new PaletteQuantizer<Rgba32> { 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<Color>(), Quality = 256 }; PngEncoderOptions options = new PngEncoderOptions() { Quantizer = new WuQuantizer<Rgba32>(), 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.Color> quantizer = this.UseOctreeQuantizer Quantizer<ImageSharp.Rgba32> quantizer = this.UseOctreeQuantizer
? (Quantizer<ImageSharp.Color>) ? (Quantizer<ImageSharp.Rgba32>)
new OctreeQuantizer<ImageSharp.Color>() new OctreeQuantizer<ImageSharp.Rgba32>()
: new PaletteQuantizer<ImageSharp.Color>(); : new PaletteQuantizer<ImageSharp.Rgba32>();
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.Color; using CoreColor = ImageSharp.Rgba32;
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.ColorVector>; using CoreVectorImage = ImageSharp.Image<ImageSharp.RgbaVector>;
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.Color> public class Color32 : BulkPixelOperationsTests<ImageSharp.Rgba32>
{ {
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.Color.BulkOperations>(BulkPixelOperations<ImageSharp.Color>.Instance); Assert.IsType<ImageSharp.Rgba32.BulkOperations>(BulkPixelOperations<ImageSharp.Rgba32>.Instance);
} }
[Fact] [Fact]
public void ToVector4SimdAligned() public void ToVector4SimdAligned()
{ {
ImageSharp.Color[] source = CreatePixelTestData(64); ImageSharp.Rgba32[] source = CreatePixelTestData(64);
Vector4[] expected = CreateExpectedVector4Data(source); Vector4[] expected = CreateExpectedVector4Data(source);
TestOperation( TestOperation(
source, source,
expected, expected,
(s, d) => ImageSharp.Color.BulkOperations.ToVector4SimdAligned(s, d, 64) (s, d) => ImageSharp.Rgba32.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.Color> source = new Buffer<ImageSharp.Color>(count)) using (Buffer<ImageSharp.Rgba32> source = new Buffer<ImageSharp.Rgba32>(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.Color>.Instance.ToVector4(source, dest, count); BulkPixelOperations<ImageSharp.Rgba32>.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="Color"/> to <see cref="YCbCr"/>. /// Tests the implicit conversion from <see cref="Rgba32"/> 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
Color color = Color.White; Rgba32 color = Rgba32.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
Color color2 = Color.Black; Rgba32 color2 = Rgba32.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
Color color3 = Color.Gray; Rgba32 color3 = Rgba32.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="Color"/>. /// Tests the implicit conversion from <see cref="YCbCr"/> to <see cref="Rgba32"/>.
/// </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);
Color color = yCbCr; Rgba32 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);
Color color2 = yCbCr2; Rgba32 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);
Color color3 = yCbCr3; Rgba32 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="Color"/> to <see cref="CieXyz"/>. /// Tests the implicit conversion from <see cref="Rgba32"/> 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
Color color = Color.White; Rgba32 color = Rgba32.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
Color color2 = Color.Black; Rgba32 color2 = Rgba32.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
Color color3 = Color.Gray; Rgba32 color3 = Rgba32.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
Color color4 = Color.Cyan; Rgba32 color4 = Rgba32.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="Color"/>. /// Tests the implicit conversion from <see cref="CieXyz"/> to <see cref="Rgba32"/>.
/// 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);
Color color = ciexyz; Rgba32 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);
Color color2 = ciexyz2; Rgba32 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);
Color color3 = ciexyz3; Rgba32 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="Color"/> to <see cref="Hsv"/>. /// Tests the implicit conversion from <see cref="Rgba32"/> 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
Color b = Color.Black; Rgba32 b = Rgba32.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
Color color = Color.White; Rgba32 color = Rgba32.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.
Color color2 = new Color(128, 64, 106); Rgba32 color2 = new Rgba32(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.
Color color3 = new Color(204, 119, 34); Rgba32 color3 = new Rgba32(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="Color"/>. /// Tests the implicit conversion from <see cref="Hsv"/> to <see cref="Rgba32"/>.
/// </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);
Color color = hsv; Rgba32 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);
Color color2 = hsv2; Rgba32 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);
Color color3 = hsv3; Rgba32 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="Color"/> to <see cref="Hsl"/>. /// Tests the implicit conversion from <see cref="Rgba32"/> 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
Color b = Color.Black; Rgba32 b = Rgba32.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
Color color = Color.White; Rgba32 color = Rgba32.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.
Color color2 = new Color(128, 64, 106); Rgba32 color2 = new Rgba32(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.
Color color3 = new Color(204, 119, 34); Rgba32 color3 = new Rgba32(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="Color"/>. /// Tests the implicit conversion from <see cref="Hsl"/> to <see cref="Rgba32"/>.
/// </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);
Color color = hsl; Rgba32 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);
Color color2 = hsl2; Rgba32 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);
Color color3 = hsl3; Rgba32 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="Color"/> to <see cref="Cmyk"/>. /// Tests the implicit conversion from <see cref="Rgba32"/> 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
Color color = Color.White; Rgba32 color = Rgba32.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
Color color2 = Color.Black; Rgba32 color2 = Rgba32.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
Color color3 = Color.Gray; Rgba32 color3 = Rgba32.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
Color color4 = Color.Cyan; Rgba32 color4 = Rgba32.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="Color"/>. /// Tests the implicit conversion from <see cref="Cmyk"/> to <see cref="Rgba32"/>.
/// </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);
Color color = cmyk; Rgba32 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);
Color color2 = cmyk2; Rgba32 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);
Color color3 = cmyk3; Rgba32 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="Color"/> to <see cref="CieLab"/>. /// Tests the implicit conversion from <see cref="Rgba32"/> 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
Color color = Color.White; Rgba32 color = Rgba32.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
Color color2 = Color.Black; Rgba32 color2 = Rgba32.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
Color color3 = Color.Gray; Rgba32 color3 = Rgba32.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
Color color4 = Color.Cyan; Rgba32 color4 = Rgba32.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="Color"/>. /// Tests the implicit conversion from <see cref="CieLab"/> to <see cref="Rgba32"/>.
/// </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);
Color color = cielab; Rgba32 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);
Color color2 = cielab2; Rgba32 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);
Color color3 = cielab3; Rgba32 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<Color>).GetTypeInfo().GetFields().Select(x => new[] { x.Name }); public static IEnumerable<string[]> ColorNames => typeof(NamedColors<Rgba32>).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<Color>).GetTypeInfo().GetField(name); FieldInfo generic = typeof(NamedColors<Rgba32>).GetTypeInfo().GetField(name);
FieldInfo specific = typeof(Color).GetTypeInfo().GetField(name); FieldInfo specific = typeof(Rgba32).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");
Color expected = (Color)generic.GetValue(null); Rgba32 expected = (Rgba32)generic.GetValue(null);
Color actual = (Color)specific.GetValue(null); Rgba32 actual = (Rgba32)specific.GetValue(null);
Assert.Equal(expected, actual); Assert.Equal(expected, actual);
} }
} }

4
tests/ImageSharp.Tests/Colors/ColorEqualityTests.cs

@ -33,7 +33,7 @@ namespace ImageSharp.Tests.Colors
{ new NormalizedShort4(Vector4.One), new NormalizedShort4(Vector4.One), typeof(NormalizedShort4) }, { new NormalizedShort4(Vector4.One), new NormalizedShort4(Vector4.One), typeof(NormalizedShort4) },
{ new Rg32(Vector2.One), new Rg32(Vector2.One), typeof(Rg32) }, { new Rg32(Vector2.One), new Rg32(Vector2.One), typeof(Rg32) },
{ new Rgba1010102(Vector4.One), new Rgba1010102(Vector4.One), typeof(Rgba1010102) }, { new Rgba1010102(Vector4.One), new Rgba1010102(Vector4.One), typeof(Rgba1010102) },
{ new Color(Vector4.One), new Color(Vector4.One), typeof(Color) }, { new Rgba32(Vector4.One), new Rgba32(Vector4.One), typeof(Rgba32) },
{ new Rgba64(Vector4.One), new Rgba64(Vector4.One), typeof(Rgba64) }, { new Rgba64(Vector4.One), new Rgba64(Vector4.One), typeof(Rgba64) },
{ new Short2(Vector2.One * 0x7FFF), new Short2(Vector2.One * 0x7FFF), typeof(Short2) }, { new Short2(Vector2.One * 0x7FFF), new Short2(Vector2.One * 0x7FFF), typeof(Short2) },
{ new Short4(Vector4.One * 0x7FFF), new Short4(Vector4.One * 0x7FFF), typeof(Short4) }, { new Short4(Vector4.One * 0x7FFF), new Short4(Vector4.One * 0x7FFF), typeof(Short4) },
@ -145,7 +145,7 @@ namespace ImageSharp.Tests.Colors
{ new NormalizedShort4(Vector4.One), new NormalizedShort4(Vector4.Zero), typeof(NormalizedShort4) }, { new NormalizedShort4(Vector4.One), new NormalizedShort4(Vector4.Zero), typeof(NormalizedShort4) },
{ new Rg32(Vector2.One), new Rg32(Vector2.Zero), typeof(Rg32) }, { new Rg32(Vector2.One), new Rg32(Vector2.Zero), typeof(Rg32) },
{ new Rgba1010102(Vector4.One), new Rgba1010102(Vector4.Zero), typeof(Rgba1010102) }, { new Rgba1010102(Vector4.One), new Rgba1010102(Vector4.Zero), typeof(Rgba1010102) },
{ new Color(Vector4.One), new Color(Vector4.Zero), typeof(Color) }, { new Rgba32(Vector4.One), new Rgba32(Vector4.Zero), typeof(Rgba32) },
{ new Rgba64(Vector4.One), new Rgba64(Vector4.Zero), typeof(Rgba64) }, { new Rgba64(Vector4.One), new Rgba64(Vector4.Zero), typeof(Rgba64) },
{ new Short2(Vector2.One * 0x7FFF), new Short2(Vector2.Zero), typeof(Short2) }, { new Short2(Vector2.One * 0x7FFF), new Short2(Vector2.Zero), typeof(Short2) },
{ new Short4(Vector4.One * 0x7FFF), new Short4(Vector4.Zero), typeof(Short4) }, { new Short4(Vector4.One * 0x7FFF), new Short4(Vector4.Zero), typeof(Short4) },

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

@ -11,7 +11,7 @@ namespace ImageSharp.Tests
using Xunit; using Xunit;
/// <summary> /// <summary>
/// Tests the <see cref="Color"/> struct. /// Tests the <see cref="Rgba32"/> struct.
/// </summary> /// </summary>
public class ColorTests public class ColorTests
{ {
@ -21,12 +21,12 @@ namespace ImageSharp.Tests
[Fact] [Fact]
public void AreEqual() public void AreEqual()
{ {
Color color1 = new Color(0, 0, 0); Rgba32 color1 = new Rgba32(0, 0, 0);
Color color2 = new Color(0, 0, 0, 1F); Rgba32 color2 = new Rgba32(0, 0, 0, 1F);
Color color3 = Color.FromHex("#000"); Rgba32 color3 = Rgba32.FromHex("#000");
Color color4 = Color.FromHex("#000F"); Rgba32 color4 = Rgba32.FromHex("#000F");
Color color5 = Color.FromHex("#000000"); Rgba32 color5 = Rgba32.FromHex("#000000");
Color color6 = Color.FromHex("#000000FF"); Rgba32 color6 = Rgba32.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()
{ {
Color color1 = new Color(255, 0, 0, 255); Rgba32 color1 = new Rgba32(255, 0, 0, 255);
Color color2 = new Color(0, 0, 0, 255); Rgba32 color2 = new Rgba32(0, 0, 0, 255);
Color color3 = Color.FromHex("#000"); Rgba32 color3 = Rgba32.FromHex("#000");
Color color4 = Color.FromHex("#000000"); Rgba32 color4 = Rgba32.FromHex("#000000");
Color color5 = Color.FromHex("#FF000000"); Rgba32 color5 = Rgba32.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()
{ {
Color color1 = new Color(1, .1f, .133f, .864f); Rgba32 color1 = new Rgba32(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);
Color color2 = new Color(1, .1f, .133f); Rgba32 color2 = new Rgba32(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);
Color color4 = new Color(new Vector3(1, .1f, .133f)); Rgba32 color4 = new Rgba32(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);
Color color5 = new Color(new Vector4(1, .1f, .133f, .5f)); Rgba32 color5 = new Rgba32(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()
{ {
Color color = Color.FromHex("#AABBCCDD"); Rgba32 color = Rgba32.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,14 +118,14 @@ namespace ImageSharp.Tests
[Fact] [Fact]
public unsafe void ByteLayout() public unsafe void ByteLayout()
{ {
Color color = new Color(1, 2, 3, 4); Rgba32 color = new Rgba32(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]);
Assert.Equal(3, colorBase[2]); Assert.Equal(3, colorBase[2]);
Assert.Equal(4, colorBase[3]); Assert.Equal(4, colorBase[3]);
Assert.Equal(4, sizeof(Color)); Assert.Equal(4, sizeof(Rgba32));
} }
} }
} }

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 Color Backdrop = new Color(204, 102, 0); private static readonly Rgba32 Backdrop = new Rgba32(204, 102, 0);
/// <summary> /// <summary>
/// Blue source /// Blue source
/// </summary> /// </summary>
private static readonly Color Source = new Color(0, 102, 153); private static readonly Rgba32 Source = new Rgba32(0, 102, 153);
[Fact] [Fact]
public void Normal() public void Normal()
{ {
Color normal = Color.Normal(Backdrop, Source); Rgba32 normal = Rgba32.Normal(Backdrop, Source);
Assert.True(normal == Source); Assert.True(normal == Source);
} }
[Fact] [Fact]
public void Multiply() public void Multiply()
{ {
Assert.True(Color.Multiply(Backdrop, Color.Black) == Color.Black); Assert.True(Rgba32.Multiply(Backdrop, Rgba32.Black) == Rgba32.Black);
Assert.True(Color.Multiply(Backdrop, Color.White) == Backdrop); Assert.True(Rgba32.Multiply(Backdrop, Rgba32.White) == Backdrop);
Color multiply = Color.Multiply(Backdrop, Source); Rgba32 multiply = Rgba32.Multiply(Backdrop, Source);
Assert.True(multiply == new Color(0, 41, 0)); Assert.True(multiply == new Rgba32(0, 41, 0));
} }
[Fact] [Fact]
public void Screen() public void Screen()
{ {
Assert.True(Color.Screen(Backdrop, Color.Black) == Backdrop); Assert.True(Rgba32.Screen(Backdrop, Rgba32.Black) == Backdrop);
Assert.True(Color.Screen(Backdrop, Color.White) == Color.White); Assert.True(Rgba32.Screen(Backdrop, Rgba32.White) == Rgba32.White);
Color screen = Color.Screen(Backdrop, Source); Rgba32 screen = Rgba32.Screen(Backdrop, Source);
Assert.True(screen == new Color(204, 163, 153)); Assert.True(screen == new Rgba32(204, 163, 153));
} }
[Fact] [Fact]
public void HardLight() public void HardLight()
{ {
Color hardLight = Color.HardLight(Backdrop, Source); Rgba32 hardLight = Rgba32.HardLight(Backdrop, Source);
Assert.True(hardLight == new Color(0, 82, 51)); Assert.True(hardLight == new Rgba32(0, 82, 51));
} }
[Fact] [Fact]
public void Overlay() public void Overlay()
{ {
Color overlay = Color.Overlay(Backdrop, Source); Rgba32 overlay = Rgba32.Overlay(Backdrop, Source);
Assert.True(overlay == new Color(153, 82, 0)); Assert.True(overlay == new Rgba32(153, 82, 0));
} }
[Fact] [Fact]
public void Darken() public void Darken()
{ {
Color darken = Color.Darken(Backdrop, Source); Rgba32 darken = Rgba32.Darken(Backdrop, Source);
Assert.True(darken == new Color(0, 102, 0)); Assert.True(darken == new Rgba32(0, 102, 0));
} }
[Fact] [Fact]
public void Lighten() public void Lighten()
{ {
Color lighten = Color.Lighten(Backdrop, Source); Rgba32 lighten = Rgba32.Lighten(Backdrop, Source);
Assert.True(lighten == new Color(204, 102, 153)); Assert.True(lighten == new Rgba32(204, 102, 153));
} }
[Fact] [Fact]
public void SoftLight() public void SoftLight()
{ {
Color softLight = Color.SoftLight(Backdrop, Source); Rgba32 softLight = Rgba32.SoftLight(Backdrop, Source);
Assert.True(softLight == new Color(163, 90, 0)); Assert.True(softLight == new Rgba32(163, 90, 0));
} }
[Fact] [Fact]
public void ColorDodge() public void ColorDodge()
{ {
Color colorDodge = Color.ColorDodge(Backdrop, Source); Rgba32 colorDodge = Rgba32.ColorDodge(Backdrop, Source);
Assert.True(colorDodge == new Color(204, 170, 0)); Assert.True(colorDodge == new Rgba32(204, 170, 0));
} }
[Fact] [Fact]
public void ColorBurn() public void ColorBurn()
{ {
Color colorBurn = Color.ColorBurn(Backdrop, Source); Rgba32 colorBurn = Rgba32.ColorBurn(Backdrop, Source);
Assert.True(colorBurn == new Color(0, 0, 0)); Assert.True(colorBurn == new Rgba32(0, 0, 0));
} }
[Fact] [Fact]
public void Difference() public void Difference()
{ {
Color difference = Color.Difference(Backdrop, Source); Rgba32 difference = Rgba32.Difference(Backdrop, Source);
Assert.True(difference == new Color(204, 0, 153)); Assert.True(difference == new Rgba32(204, 0, 153));
} }
[Fact] [Fact]
public void Exclusion() public void Exclusion()
{ {
Color exclusion = Color.Exclusion(Backdrop, Source); Rgba32 exclusion = Rgba32.Exclusion(Backdrop, Source);
Assert.True(exclusion == new Color(204, 122, 153)); Assert.True(exclusion == new Rgba32(204, 122, 153));
} }
} }
} }

38
tests/ImageSharp.Tests/Colors/ColorVectorTests.cs

@ -11,7 +11,7 @@ namespace ImageSharp.Tests
using Xunit; using Xunit;
/// <summary> /// <summary>
/// Tests the <see cref="ColorVector"/> struct. /// Tests the <see cref="RgbaVector"/> struct.
/// </summary> /// </summary>
public class ColorVectorTests public class ColorVectorTests
{ {
@ -21,12 +21,12 @@ namespace ImageSharp.Tests
[Fact] [Fact]
public void AreEqual() public void AreEqual()
{ {
ColorVector color1 = new ColorVector(0, 0, 0F); RgbaVector color1 = new RgbaVector(0, 0, 0F);
ColorVector color2 = new ColorVector(0, 0, 0, 1F); RgbaVector color2 = new RgbaVector(0, 0, 0, 1F);
ColorVector color3 = ColorVector.FromHex("#000"); RgbaVector color3 = RgbaVector.FromHex("#000");
ColorVector color4 = ColorVector.FromHex("#000F"); RgbaVector color4 = RgbaVector.FromHex("#000F");
ColorVector color5 = ColorVector.FromHex("#000000"); RgbaVector color5 = RgbaVector.FromHex("#000000");
ColorVector color6 = ColorVector.FromHex("#000000FF"); RgbaVector color6 = RgbaVector.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()
{ {
ColorVector color1 = new ColorVector(1, 0, 0, 1); RgbaVector color1 = new RgbaVector(1, 0, 0, 1);
ColorVector color2 = new ColorVector(0, 0, 0, 1); RgbaVector color2 = new RgbaVector(0, 0, 0, 1);
ColorVector color3 = ColorVector.FromHex("#000"); RgbaVector color3 = RgbaVector.FromHex("#000");
ColorVector color4 = ColorVector.FromHex("#000000"); RgbaVector color4 = RgbaVector.FromHex("#000000");
ColorVector color5 = ColorVector.FromHex("#FF000000"); RgbaVector color5 = RgbaVector.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()
{ {
ColorVector color1 = new ColorVector(1, .1F, .133F, .864F); RgbaVector color1 = new RgbaVector(1, .1F, .133F, .864F);
Assert.Equal(1F, color1.R); Assert.Equal(1F, color1.R);
Assert.Equal(.1F, color1.G); Assert.Equal(.1F, color1.G);
Assert.Equal(.133F, color1.B); Assert.Equal(.133F, color1.B);
Assert.Equal(.864F, color1.A); Assert.Equal(.864F, color1.A);
ColorVector color2 = new ColorVector(1, .1f, .133f); RgbaVector color2 = new RgbaVector(1, .1f, .133f);
Assert.Equal(1F, color2.R); Assert.Equal(1F, color2.R);
Assert.Equal(.1F, color2.G); Assert.Equal(.1F, color2.G);
Assert.Equal(.133F, color2.B); Assert.Equal(.133F, color2.B);
Assert.Equal(1F, color2.A); Assert.Equal(1F, color2.A);
ColorVector color4 = new ColorVector(new Vector3(1, .1f, .133f)); RgbaVector color4 = new RgbaVector(new Vector3(1, .1f, .133f));
Assert.Equal(1F, color4.R); Assert.Equal(1F, color4.R);
Assert.Equal(.1F, color4.G); Assert.Equal(.1F, color4.G);
Assert.Equal(.133F, color4.B); Assert.Equal(.133F, color4.B);
Assert.Equal(1F, color4.A); Assert.Equal(1F, color4.A);
ColorVector color5 = new ColorVector(new Vector4(1, .1f, .133f, .5f)); RgbaVector color5 = new RgbaVector(new Vector4(1, .1f, .133f, .5f));
Assert.Equal(1F, color5.R); Assert.Equal(1F, color5.R);
Assert.Equal(.1F, color5.G); Assert.Equal(.1F, color5.G);
Assert.Equal(.133F, color5.B); Assert.Equal(.133F, color5.B);
@ -90,7 +90,7 @@ namespace ImageSharp.Tests
[Fact] [Fact]
public void FromAndToHex() public void FromAndToHex()
{ {
ColorVector color = ColorVector.FromHex("#AABBCCDD"); RgbaVector color = RgbaVector.FromHex("#AABBCCDD");
Assert.Equal(170 / 255F, color.R); Assert.Equal(170 / 255F, color.R);
Assert.Equal(187 / 255F, color.G); Assert.Equal(187 / 255F, color.G);
Assert.Equal(204 / 255F, color.B); Assert.Equal(204 / 255F, color.B);
@ -118,8 +118,8 @@ namespace ImageSharp.Tests
[Fact] [Fact]
public void FloatLayout() public void FloatLayout()
{ {
ColorVector color = new ColorVector(1F, 2, 3, 4); RgbaVector color = new RgbaVector(1F, 2, 3, 4);
Vector4 colorBase = Unsafe.As<ColorVector, Vector4>(ref Unsafe.Add(ref color, 0)); Vector4 colorBase = Unsafe.As<RgbaVector, Vector4>(ref Unsafe.Add(ref color, 0));
float[] ordered = new float[4]; float[] ordered = new float[4];
colorBase.CopyTo(ordered); colorBase.CopyTo(ordered);

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

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

22
tests/ImageSharp.Tests/Colors/PackedPixelTests.cs

@ -715,26 +715,26 @@ namespace ImageSharp.Tests.Colors
public void Color() public void Color()
{ {
// Test the limits. // Test the limits.
Assert.Equal((uint)0x0, new Color(Vector4.Zero).PackedValue); Assert.Equal((uint)0x0, new Rgba32(Vector4.Zero).PackedValue);
Assert.Equal(0xFFFFFFFF, new Color(Vector4.One).PackedValue); Assert.Equal(0xFFFFFFFF, new Rgba32(Vector4.One).PackedValue);
// Test ToVector4. // Test ToVector4.
Assert.True(Equal(Vector4.One, new Color(Vector4.One).ToVector4())); Assert.True(Equal(Vector4.One, new Rgba32(Vector4.One).ToVector4()));
Assert.True(Equal(Vector4.Zero, new Color(Vector4.Zero).ToVector4())); Assert.True(Equal(Vector4.Zero, new Rgba32(Vector4.Zero).ToVector4()));
Assert.True(Equal(Vector4.UnitX, new Color(Vector4.UnitX).ToVector4())); Assert.True(Equal(Vector4.UnitX, new Rgba32(Vector4.UnitX).ToVector4()));
Assert.True(Equal(Vector4.UnitY, new Color(Vector4.UnitY).ToVector4())); Assert.True(Equal(Vector4.UnitY, new Rgba32(Vector4.UnitY).ToVector4()));
Assert.True(Equal(Vector4.UnitZ, new Color(Vector4.UnitZ).ToVector4())); Assert.True(Equal(Vector4.UnitZ, new Rgba32(Vector4.UnitZ).ToVector4()));
Assert.True(Equal(Vector4.UnitW, new Color(Vector4.UnitW).ToVector4())); Assert.True(Equal(Vector4.UnitW, new Rgba32(Vector4.UnitW).ToVector4()));
// Test clamping. // Test clamping.
Assert.True(Equal(Vector4.Zero, new Color(Vector4.One * -1234.0f).ToVector4())); Assert.True(Equal(Vector4.Zero, new Rgba32(Vector4.One * -1234.0f).ToVector4()));
Assert.True(Equal(Vector4.One, new Color(Vector4.One * +1234.0f).ToVector4())); Assert.True(Equal(Vector4.One, new Rgba32(Vector4.One * +1234.0f).ToVector4()));
float x = +0.1f; float x = +0.1f;
float y = -0.3f; float y = -0.3f;
float z = +0.5f; float z = +0.5f;
float w = -0.7f; float w = -0.7f;
Color rgba32 = new Color(x, y, z, w); Rgba32 rgba32 = new Rgba32(x, y, z, w);
Assert.Equal(0x80001Au, rgba32.PackedValue); Assert.Equal(0x80001Au, rgba32.PackedValue);
// Test ordering // Test ordering

44
tests/ImageSharp.Tests/Colors/UnPackedPixelTests.cs

@ -9,8 +9,8 @@
[Fact] [Fact]
public void Color_Types_From_Bytes_Produce_Equal_Scaled_Component_OutPut() public void Color_Types_From_Bytes_Produce_Equal_Scaled_Component_OutPut()
{ {
Color color = new Color(24, 48, 96, 192); Rgba32 color = new Rgba32(24, 48, 96, 192);
ColorVector colorVector = new ColorVector(24, 48, 96, 192); RgbaVector colorVector = new RgbaVector(24, 48, 96, 192);
Assert.Equal(color.R, (byte)(colorVector.R * 255)); Assert.Equal(color.R, (byte)(colorVector.R * 255));
Assert.Equal(color.G, (byte)(colorVector.G * 255)); Assert.Equal(color.G, (byte)(colorVector.G * 255));
@ -21,8 +21,8 @@
[Fact] [Fact]
public void Color_Types_From_Floats_Produce_Equal_Scaled_Component_OutPut() public void Color_Types_From_Floats_Produce_Equal_Scaled_Component_OutPut()
{ {
Color color = new Color(24 / 255F, 48 / 255F, 96 / 255F, 192 / 255F); Rgba32 color = new Rgba32(24 / 255F, 48 / 255F, 96 / 255F, 192 / 255F);
ColorVector colorVector = new ColorVector(24 / 255F, 48 / 255F, 96 / 255F, 192 / 255F); RgbaVector colorVector = new RgbaVector(24 / 255F, 48 / 255F, 96 / 255F, 192 / 255F);
Assert.Equal(color.R, (byte)(colorVector.R * 255)); Assert.Equal(color.R, (byte)(colorVector.R * 255));
Assert.Equal(color.G, (byte)(colorVector.G * 255)); Assert.Equal(color.G, (byte)(colorVector.G * 255));
@ -33,8 +33,8 @@
[Fact] [Fact]
public void Color_Types_From_Vector4_Produce_Equal_Scaled_Component_OutPut() public void Color_Types_From_Vector4_Produce_Equal_Scaled_Component_OutPut()
{ {
Color color = new Color(new Vector4(24 / 255F, 48 / 255F, 96 / 255F, 192 / 255F)); Rgba32 color = new Rgba32(new Vector4(24 / 255F, 48 / 255F, 96 / 255F, 192 / 255F));
ColorVector colorVector = new ColorVector(new Vector4(24 / 255F, 48 / 255F, 96 / 255F, 192 / 255F)); RgbaVector colorVector = new RgbaVector(new Vector4(24 / 255F, 48 / 255F, 96 / 255F, 192 / 255F));
Assert.Equal(color.R, (byte)(colorVector.R * 255)); Assert.Equal(color.R, (byte)(colorVector.R * 255));
Assert.Equal(color.G, (byte)(colorVector.G * 255)); Assert.Equal(color.G, (byte)(colorVector.G * 255));
@ -45,8 +45,8 @@
[Fact] [Fact]
public void Color_Types_From_Vector3_Produce_Equal_Scaled_Component_OutPut() public void Color_Types_From_Vector3_Produce_Equal_Scaled_Component_OutPut()
{ {
Color color = new Color(new Vector3(24 / 255F, 48 / 255F, 96 / 255F)); Rgba32 color = new Rgba32(new Vector3(24 / 255F, 48 / 255F, 96 / 255F));
ColorVector colorVector = new ColorVector(new Vector3(24 / 255F, 48 / 255F, 96 / 255F)); RgbaVector colorVector = new RgbaVector(new Vector3(24 / 255F, 48 / 255F, 96 / 255F));
Assert.Equal(color.R, (byte)(colorVector.R * 255)); Assert.Equal(color.R, (byte)(colorVector.R * 255));
Assert.Equal(color.G, (byte)(colorVector.G * 255)); Assert.Equal(color.G, (byte)(colorVector.G * 255));
@ -57,8 +57,8 @@
[Fact] [Fact]
public void Color_Types_From_Hex_Produce_Equal_Scaled_Component_OutPut() public void Color_Types_From_Hex_Produce_Equal_Scaled_Component_OutPut()
{ {
Color color = Color.FromHex("183060C0"); Rgba32 color = Rgba32.FromHex("183060C0");
ColorVector colorVector = ColorVector.FromHex("183060C0"); RgbaVector colorVector = RgbaVector.FromHex("183060C0");
Assert.Equal(color.R, (byte)(colorVector.R * 255)); Assert.Equal(color.R, (byte)(colorVector.R * 255));
Assert.Equal(color.G, (byte)(colorVector.G * 255)); Assert.Equal(color.G, (byte)(colorVector.G * 255));
@ -69,8 +69,8 @@
[Fact] [Fact]
public void Color_Types_To_Vector4_Produce_Equal_OutPut() public void Color_Types_To_Vector4_Produce_Equal_OutPut()
{ {
Color color = new Color(24, 48, 96, 192); Rgba32 color = new Rgba32(24, 48, 96, 192);
ColorVector colorVector = new ColorVector(24, 48, 96, 192); RgbaVector colorVector = new RgbaVector(24, 48, 96, 192);
Assert.Equal(color.ToVector4(), colorVector.ToVector4()); Assert.Equal(color.ToVector4(), colorVector.ToVector4());
} }
@ -78,8 +78,8 @@
[Fact] [Fact]
public void Color_Types_To_RgbBytes_Produce_Equal_OutPut() public void Color_Types_To_RgbBytes_Produce_Equal_OutPut()
{ {
Color color = new Color(24, 48, 96, 192); Rgba32 color = new Rgba32(24, 48, 96, 192);
ColorVector colorVector = new ColorVector(24, 48, 96, 192); RgbaVector colorVector = new RgbaVector(24, 48, 96, 192);
byte[] rgb = new byte[3]; byte[] rgb = new byte[3];
byte[] rgbVector = new byte[3]; byte[] rgbVector = new byte[3];
@ -93,8 +93,8 @@
[Fact] [Fact]
public void Color_Types_To_RgbaBytes_Produce_Equal_OutPut() public void Color_Types_To_RgbaBytes_Produce_Equal_OutPut()
{ {
Color color = new Color(24, 48, 96, 192); Rgba32 color = new Rgba32(24, 48, 96, 192);
ColorVector colorVector = new ColorVector(24, 48, 96, 192); RgbaVector colorVector = new RgbaVector(24, 48, 96, 192);
byte[] rgba = new byte[4]; byte[] rgba = new byte[4];
byte[] rgbaVector = new byte[4]; byte[] rgbaVector = new byte[4];
@ -108,8 +108,8 @@
[Fact] [Fact]
public void Color_Types_To_BgrBytes_Produce_Equal_OutPut() public void Color_Types_To_BgrBytes_Produce_Equal_OutPut()
{ {
Color color = new Color(24, 48, 96, 192); Rgba32 color = new Rgba32(24, 48, 96, 192);
ColorVector colorVector = new ColorVector(24, 48, 96, 192); RgbaVector colorVector = new RgbaVector(24, 48, 96, 192);
byte[] bgr = new byte[3]; byte[] bgr = new byte[3];
byte[] bgrVector = new byte[3]; byte[] bgrVector = new byte[3];
@ -123,8 +123,8 @@
[Fact] [Fact]
public void Color_Types_To_BgraBytes_Produce_Equal_OutPut() public void Color_Types_To_BgraBytes_Produce_Equal_OutPut()
{ {
Color color = new Color(24, 48, 96, 192); Rgba32 color = new Rgba32(24, 48, 96, 192);
ColorVector colorVector = new ColorVector(24, 48, 96, 192); RgbaVector colorVector = new RgbaVector(24, 48, 96, 192);
byte[] bgra = new byte[4]; byte[] bgra = new byte[4];
byte[] bgraVector = new byte[4]; byte[] bgraVector = new byte[4];
@ -138,8 +138,8 @@
[Fact] [Fact]
public void Color_Types_To_Hex_Produce_Equal_OutPut() public void Color_Types_To_Hex_Produce_Equal_OutPut()
{ {
Color color = new Color(24, 48, 96, 192); Rgba32 color = new Rgba32(24, 48, 96, 192);
ColorVector colorVector = new ColorVector(24, 48, 96, 192); RgbaVector colorVector = new RgbaVector(24, 48, 96, 192);
// 183060C0 // 183060C0
Assert.Equal(color.ToHex(), colorVector.ToHex()); Assert.Equal(color.ToHex(), colorVector.ToHex());

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

@ -412,12 +412,12 @@ namespace ImageSharp.Tests.Common
[Fact] [Fact]
public void Color32ToBytes() public void Color32ToBytes()
{ {
Color[] colors = { new Color(0, 1, 2, 3), new Color(4, 5, 6, 7), new Color(8, 9, 10, 11), }; Rgba32[] colors = { new Rgba32(0, 1, 2, 3), new Rgba32(4, 5, 6, 7), new Rgba32(8, 9, 10, 11), };
using (Buffer<Color> colorBuf = new Buffer<Color>(colors)) using (Buffer<Rgba32> colorBuf = new Buffer<Rgba32>(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(Color)); BufferSpan.Copy(colorBuf.Span.AsBytes(), byteBuf, colorBuf.Length * sizeof(Rgba32));
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()
{ {
Color[] pixels = PixelDataPool<Color>.Rent(1024); Rgba32[] pixels = PixelDataPool<Rgba32>.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()
{ {
Color[] pixels = new Color[1024]; Rgba32[] pixels = new Rgba32[1024];
PixelDataPool<Color>.Return(pixels); PixelDataPool<Rgba32>.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<Color>.CalculateMaxArrayLength(); : PixelDataPool<Rgba32>.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(Color.Blue) image.BackgroundColor(Rgba32.Blue)
.DrawBeziers(Color.HotPink, 5, .DrawBeziers(Rgba32.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<Color> sourcePixels = image.Lock()) using (PixelAccessor<Rgba32> sourcePixels = image.Lock())
{ {
//top of curve //top of curve
Assert.Equal(Color.HotPink, sourcePixels[138, 115]); Assert.Equal(Rgba32.HotPink, sourcePixels[138, 115]);
//start points //start points
Assert.Equal(Color.HotPink, sourcePixels[10, 400]); Assert.Equal(Rgba32.HotPink, sourcePixels[10, 400]);
Assert.Equal(Color.HotPink, sourcePixels[300, 400]); Assert.Equal(Rgba32.HotPink, sourcePixels[300, 400]);
//curve points should not be never be set //curve points should not be never be set
Assert.Equal(Color.Blue, sourcePixels[30, 10]); Assert.Equal(Rgba32.Blue, sourcePixels[30, 10]);
Assert.Equal(Color.Blue, sourcePixels[240, 30]); Assert.Equal(Rgba32.Blue, sourcePixels[240, 30]);
// inside shape should be empty // inside shape should be empty
Assert.Equal(Color.Blue, sourcePixels[200, 250]); Assert.Equal(Rgba32.Blue, sourcePixels[200, 250]);
} }
} }
} }
@ -59,13 +59,13 @@ namespace ImageSharp.Tests.Drawing
{ {
string path = this.CreateOutputDirectory("Drawing", "BezierLine"); string path = this.CreateOutputDirectory("Drawing", "BezierLine");
Color color = new Color(Color.HotPink.R, Color.HotPink.G, Color.HotPink.B, 150); Rgba32 color = new Rgba32(Rgba32.HotPink.R, Rgba32.HotPink.G, Rgba32.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(Color.Blue) image.BackgroundColor(Rgba32.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
Color mergedColor = new Color(Vector4.Lerp(Color.Blue.ToVector4(), Color.HotPink.ToVector4(), 150f / 255f)); Rgba32 mergedColor = new Rgba32(Vector4.Lerp(Rgba32.Blue.ToVector4(), Rgba32.HotPink.ToVector4(), 150f / 255f));
using (PixelAccessor<Color> sourcePixels = image.Lock()) using (PixelAccessor<Rgba32> 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(Color.Blue, sourcePixels[30, 10]); Assert.Equal(Rgba32.Blue, sourcePixels[30, 10]);
Assert.Equal(Color.Blue, sourcePixels[240, 30]); Assert.Equal(Rgba32.Blue, sourcePixels[240, 30]);
// inside shape should be empty // inside shape should be empty
Assert.Equal(Color.Blue, sourcePixels[200, 250]); Assert.Equal(Rgba32.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(Color.Blue) .BackgroundColor(Rgba32.Blue)
.Draw(Color.HotPink, 5, p) .Draw(Rgba32.HotPink, 5, p)
.Save(output); .Save(output);
} }
using (PixelAccessor<Color> sourcePixels = image.Lock()) using (PixelAccessor<Rgba32> sourcePixels = image.Lock())
{ {
Assert.Equal(Color.HotPink, sourcePixels[9, 9]); Assert.Equal(Rgba32.HotPink, sourcePixels[9, 9]);
Assert.Equal(Color.HotPink, sourcePixels[199, 149]); Assert.Equal(Rgba32.HotPink, sourcePixels[199, 149]);
Assert.Equal(Color.Blue, sourcePixels[50, 50]); Assert.Equal(Rgba32.Blue, sourcePixels[50, 50]);
} }
} }
} }
@ -60,7 +60,7 @@ namespace ImageSharp.Tests.Drawing
{ {
string path = this.CreateOutputDirectory("Drawing", "Path"); string path = this.CreateOutputDirectory("Drawing", "Path");
Color color = new Color(Color.HotPink.R, Color.HotPink.G, Color.HotPink.B, 150); Rgba32 color = new Rgba32(Rgba32.HotPink.R, Rgba32.HotPink.G, Rgba32.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(Color.Blue) .BackgroundColor(Rgba32.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
Color mergedColor = new Color(Vector4.Lerp(Color.Blue.ToVector4(), Color.HotPink.ToVector4(), 150f / 255f)); Rgba32 mergedColor = new Rgba32(Vector4.Lerp(Rgba32.Blue.ToVector4(), Rgba32.HotPink.ToVector4(), 150f / 255f));
using (PixelAccessor<Color> sourcePixels = image.Lock()) using (PixelAccessor<Rgba32> 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(Color.Blue, sourcePixels[50, 50]); Assert.Equal(Rgba32.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, Color background, IBrush<Color> brush, Color[,] expectedPattern) private void Test(string name, Rgba32 background, IBrush<Rgba32> brush, Rgba32[,] 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<Color> sourcePixels = image.Lock()) using (PixelAccessor<Rgba32> 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<Color> expectedPatternFast = new Fast2DArray<Color>(expectedPattern); Fast2DArray<Rgba32> expectedPatternFast = new Fast2DArray<Rgba32>(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;
Color expected = expectedPatternFast[y, x]; // inverted pattern Rgba32 expected = expectedPatternFast[y, x]; // inverted pattern
Color actual = sourcePixels[actualX, actualY]; Rgba32 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", Color.Blue, Brushes.Percent10(Color.HotPink, Color.LimeGreen), this.Test("Percent10", Rgba32.Blue, Brushes.Percent10(Rgba32.HotPink, Rgba32.LimeGreen),
new[,] new[,]
{ {
{ Color.HotPink , Color.LimeGreen, Color.LimeGreen, Color.LimeGreen}, { Rgba32.HotPink , Rgba32.LimeGreen, Rgba32.LimeGreen, Rgba32.LimeGreen},
{ Color.LimeGreen, Color.LimeGreen, Color.LimeGreen, Color.LimeGreen}, { Rgba32.LimeGreen, Rgba32.LimeGreen, Rgba32.LimeGreen, Rgba32.LimeGreen},
{ Color.LimeGreen, Color.LimeGreen, Color.HotPink , Color.LimeGreen}, { Rgba32.LimeGreen, Rgba32.LimeGreen, Rgba32.HotPink , Rgba32.LimeGreen},
{ Color.LimeGreen, Color.LimeGreen, Color.LimeGreen, Color.LimeGreen} { Rgba32.LimeGreen, Rgba32.LimeGreen, Rgba32.LimeGreen, Rgba32.LimeGreen}
}); });
} }
[Fact] [Fact]
public void ImageShouldBeFloodFilledWithPercent10Transparent() public void ImageShouldBeFloodFilledWithPercent10Transparent()
{ {
Test("Percent10_Transparent", Color.Blue, Brushes.Percent10(Color.HotPink), Test("Percent10_Transparent", Rgba32.Blue, Brushes.Percent10(Rgba32.HotPink),
new Color[,] { new Rgba32[,] {
{ Color.HotPink , Color.Blue, Color.Blue, Color.Blue}, { Rgba32.HotPink , Rgba32.Blue, Rgba32.Blue, Rgba32.Blue},
{ Color.Blue, Color.Blue, Color.Blue, Color.Blue}, { Rgba32.Blue, Rgba32.Blue, Rgba32.Blue, Rgba32.Blue},
{ Color.Blue, Color.Blue, Color.HotPink , Color.Blue}, { Rgba32.Blue, Rgba32.Blue, Rgba32.HotPink , Rgba32.Blue},
{ Color.Blue, Color.Blue, Color.Blue, Color.Blue} { Rgba32.Blue, Rgba32.Blue, Rgba32.Blue, Rgba32.Blue}
}); });
} }
[Fact] [Fact]
public void ImageShouldBeFloodFilledWithPercent20() public void ImageShouldBeFloodFilledWithPercent20()
{ {
Test("Percent20", Color.Blue, Brushes.Percent20(Color.HotPink, Color.LimeGreen), Test("Percent20", Rgba32.Blue, Brushes.Percent20(Rgba32.HotPink, Rgba32.LimeGreen),
new Color[,] { new Rgba32[,] {
{ Color.HotPink , Color.LimeGreen, Color.LimeGreen, Color.LimeGreen}, { Rgba32.HotPink , Rgba32.LimeGreen, Rgba32.LimeGreen, Rgba32.LimeGreen},
{ Color.LimeGreen, Color.LimeGreen, Color.HotPink , Color.LimeGreen}, { Rgba32.LimeGreen, Rgba32.LimeGreen, Rgba32.HotPink , Rgba32.LimeGreen},
{ Color.HotPink , Color.LimeGreen, Color.LimeGreen, Color.LimeGreen}, { Rgba32.HotPink , Rgba32.LimeGreen, Rgba32.LimeGreen, Rgba32.LimeGreen},
{ Color.LimeGreen, Color.LimeGreen, Color.HotPink , Color.LimeGreen} { Rgba32.LimeGreen, Rgba32.LimeGreen, Rgba32.HotPink , Rgba32.LimeGreen}
}); });
} }
[Fact] [Fact]
public void ImageShouldBeFloodFilledWithPercent20_transparent() public void ImageShouldBeFloodFilledWithPercent20_transparent()
{ {
Test("Percent20_Transparent", Color.Blue, Brushes.Percent20(Color.HotPink), Test("Percent20_Transparent", Rgba32.Blue, Brushes.Percent20(Rgba32.HotPink),
new Color[,] { new Rgba32[,] {
{ Color.HotPink , Color.Blue, Color.Blue, Color.Blue}, { Rgba32.HotPink , Rgba32.Blue, Rgba32.Blue, Rgba32.Blue},
{ Color.Blue, Color.Blue, Color.HotPink , Color.Blue}, { Rgba32.Blue, Rgba32.Blue, Rgba32.HotPink , Rgba32.Blue},
{ Color.HotPink , Color.Blue, Color.Blue, Color.Blue}, { Rgba32.HotPink , Rgba32.Blue, Rgba32.Blue, Rgba32.Blue},
{ Color.Blue, Color.Blue, Color.HotPink , Color.Blue} { Rgba32.Blue, Rgba32.Blue, Rgba32.HotPink , Rgba32.Blue}
}); });
} }
[Fact] [Fact]
public void ImageShouldBeFloodFilledWithHorizontal() public void ImageShouldBeFloodFilledWithHorizontal()
{ {
Test("Horizontal", Color.Blue, Brushes.Horizontal(Color.HotPink, Color.LimeGreen), Test("Horizontal", Rgba32.Blue, Brushes.Horizontal(Rgba32.HotPink, Rgba32.LimeGreen),
new Color[,] { new Rgba32[,] {
{ Color.LimeGreen , Color.LimeGreen, Color.LimeGreen, Color.LimeGreen}, { Rgba32.LimeGreen , Rgba32.LimeGreen, Rgba32.LimeGreen, Rgba32.LimeGreen},
{ Color.HotPink, Color.HotPink, Color.HotPink , Color.HotPink}, { Rgba32.HotPink, Rgba32.HotPink, Rgba32.HotPink , Rgba32.HotPink},
{ Color.LimeGreen , Color.LimeGreen, Color.LimeGreen, Color.LimeGreen}, { Rgba32.LimeGreen , Rgba32.LimeGreen, Rgba32.LimeGreen, Rgba32.LimeGreen},
{ Color.LimeGreen, Color.LimeGreen, Color.LimeGreen , Color.LimeGreen} { Rgba32.LimeGreen, Rgba32.LimeGreen, Rgba32.LimeGreen , Rgba32.LimeGreen}
}); });
} }
[Fact] [Fact]
public void ImageShouldBeFloodFilledWithHorizontal_transparent() public void ImageShouldBeFloodFilledWithHorizontal_transparent()
{ {
Test("Horizontal_Transparent", Color.Blue, Brushes.Horizontal(Color.HotPink), Test("Horizontal_Transparent", Rgba32.Blue, Brushes.Horizontal(Rgba32.HotPink),
new Color[,] { new Rgba32[,] {
{ Color.Blue , Color.Blue, Color.Blue, Color.Blue}, { Rgba32.Blue , Rgba32.Blue, Rgba32.Blue, Rgba32.Blue},
{ Color.HotPink, Color.HotPink, Color.HotPink , Color.HotPink}, { Rgba32.HotPink, Rgba32.HotPink, Rgba32.HotPink , Rgba32.HotPink},
{ Color.Blue , Color.Blue, Color.Blue, Color.Blue}, { Rgba32.Blue , Rgba32.Blue, Rgba32.Blue, Rgba32.Blue},
{ Color.Blue, Color.Blue, Color.Blue , Color.Blue} { Rgba32.Blue, Rgba32.Blue, Rgba32.Blue , Rgba32.Blue}
}); });
} }
@ -138,96 +138,96 @@ namespace ImageSharp.Tests.Drawing
[Fact] [Fact]
public void ImageShouldBeFloodFilledWithMin() public void ImageShouldBeFloodFilledWithMin()
{ {
Test("Min", Color.Blue, Brushes.Min(Color.HotPink, Color.LimeGreen), Test("Min", Rgba32.Blue, Brushes.Min(Rgba32.HotPink, Rgba32.LimeGreen),
new Color[,] { new Rgba32[,] {
{ Color.LimeGreen , Color.LimeGreen, Color.LimeGreen, Color.LimeGreen}, { Rgba32.LimeGreen , Rgba32.LimeGreen, Rgba32.LimeGreen, Rgba32.LimeGreen},
{ Color.LimeGreen , Color.LimeGreen, Color.LimeGreen, Color.LimeGreen}, { Rgba32.LimeGreen , Rgba32.LimeGreen, Rgba32.LimeGreen, Rgba32.LimeGreen},
{ Color.LimeGreen, Color.LimeGreen, Color.LimeGreen , Color.LimeGreen}, { Rgba32.LimeGreen, Rgba32.LimeGreen, Rgba32.LimeGreen , Rgba32.LimeGreen},
{ Color.HotPink, Color.HotPink, Color.HotPink , Color.HotPink} { Rgba32.HotPink, Rgba32.HotPink, Rgba32.HotPink , Rgba32.HotPink}
}); });
} }
[Fact] [Fact]
public void ImageShouldBeFloodFilledWithMin_transparent() public void ImageShouldBeFloodFilledWithMin_transparent()
{ {
Test("Min_Transparent", Color.Blue, Brushes.Min(Color.HotPink), Test("Min_Transparent", Rgba32.Blue, Brushes.Min(Rgba32.HotPink),
new Color[,] { new Rgba32[,] {
{ Color.Blue , Color.Blue, Color.Blue, Color.Blue}, { Rgba32.Blue , Rgba32.Blue, Rgba32.Blue, Rgba32.Blue},
{ Color.Blue , Color.Blue, Color.Blue, Color.Blue}, { Rgba32.Blue , Rgba32.Blue, Rgba32.Blue, Rgba32.Blue},
{ Color.Blue, Color.Blue, Color.Blue , Color.Blue}, { Rgba32.Blue, Rgba32.Blue, Rgba32.Blue , Rgba32.Blue},
{ Color.HotPink, Color.HotPink, Color.HotPink , Color.HotPink}, { Rgba32.HotPink, Rgba32.HotPink, Rgba32.HotPink , Rgba32.HotPink},
}); });
} }
[Fact] [Fact]
public void ImageShouldBeFloodFilledWithVertical() public void ImageShouldBeFloodFilledWithVertical()
{ {
Test("Vertical", Color.Blue, Brushes.Vertical(Color.HotPink, Color.LimeGreen), Test("Vertical", Rgba32.Blue, Brushes.Vertical(Rgba32.HotPink, Rgba32.LimeGreen),
new Color[,] { new Rgba32[,] {
{ Color.LimeGreen, Color.HotPink, Color.LimeGreen, Color.LimeGreen}, { Rgba32.LimeGreen, Rgba32.HotPink, Rgba32.LimeGreen, Rgba32.LimeGreen},
{ Color.LimeGreen, Color.HotPink, Color.LimeGreen, Color.LimeGreen}, { Rgba32.LimeGreen, Rgba32.HotPink, Rgba32.LimeGreen, Rgba32.LimeGreen},
{ Color.LimeGreen, Color.HotPink, Color.LimeGreen, Color.LimeGreen}, { Rgba32.LimeGreen, Rgba32.HotPink, Rgba32.LimeGreen, Rgba32.LimeGreen},
{ Color.LimeGreen, Color.HotPink, Color.LimeGreen, Color.LimeGreen} { Rgba32.LimeGreen, Rgba32.HotPink, Rgba32.LimeGreen, Rgba32.LimeGreen}
}); });
} }
[Fact] [Fact]
public void ImageShouldBeFloodFilledWithVertical_transparent() public void ImageShouldBeFloodFilledWithVertical_transparent()
{ {
Test("Vertical_Transparent", Color.Blue, Brushes.Vertical(Color.HotPink), Test("Vertical_Transparent", Rgba32.Blue, Brushes.Vertical(Rgba32.HotPink),
new Color[,] { new Rgba32[,] {
{ Color.Blue, Color.HotPink, Color.Blue, Color.Blue}, { Rgba32.Blue, Rgba32.HotPink, Rgba32.Blue, Rgba32.Blue},
{ Color.Blue, Color.HotPink, Color.Blue, Color.Blue}, { Rgba32.Blue, Rgba32.HotPink, Rgba32.Blue, Rgba32.Blue},
{ Color.Blue, Color.HotPink, Color.Blue, Color.Blue}, { Rgba32.Blue, Rgba32.HotPink, Rgba32.Blue, Rgba32.Blue},
{ Color.Blue, Color.HotPink, Color.Blue, Color.Blue} { Rgba32.Blue, Rgba32.HotPink, Rgba32.Blue, Rgba32.Blue}
}); });
} }
[Fact] [Fact]
public void ImageShouldBeFloodFilledWithForwardDiagonal() public void ImageShouldBeFloodFilledWithForwardDiagonal()
{ {
Test("ForwardDiagonal", Color.Blue, Brushes.ForwardDiagonal(Color.HotPink, Color.LimeGreen), Test("ForwardDiagonal", Rgba32.Blue, Brushes.ForwardDiagonal(Rgba32.HotPink, Rgba32.LimeGreen),
new Color[,] { new Rgba32[,] {
{ Color.LimeGreen, Color.LimeGreen, Color.LimeGreen, Color.HotPink}, { Rgba32.LimeGreen, Rgba32.LimeGreen, Rgba32.LimeGreen, Rgba32.HotPink},
{ Color.LimeGreen, Color.LimeGreen, Color.HotPink, Color.LimeGreen}, { Rgba32.LimeGreen, Rgba32.LimeGreen, Rgba32.HotPink, Rgba32.LimeGreen},
{ Color.LimeGreen, Color.HotPink, Color.LimeGreen, Color.LimeGreen}, { Rgba32.LimeGreen, Rgba32.HotPink, Rgba32.LimeGreen, Rgba32.LimeGreen},
{ Color.HotPink, Color.LimeGreen, Color.LimeGreen, Color.LimeGreen} { Rgba32.HotPink, Rgba32.LimeGreen, Rgba32.LimeGreen, Rgba32.LimeGreen}
}); });
} }
[Fact] [Fact]
public void ImageShouldBeFloodFilledWithForwardDiagonal_transparent() public void ImageShouldBeFloodFilledWithForwardDiagonal_transparent()
{ {
Test("ForwardDiagonal_Transparent", Color.Blue, Brushes.ForwardDiagonal(Color.HotPink), Test("ForwardDiagonal_Transparent", Rgba32.Blue, Brushes.ForwardDiagonal(Rgba32.HotPink),
new Color[,] { new Rgba32[,] {
{ Color.Blue, Color.Blue, Color.Blue, Color.HotPink}, { Rgba32.Blue, Rgba32.Blue, Rgba32.Blue, Rgba32.HotPink},
{ Color.Blue, Color.Blue, Color.HotPink, Color.Blue}, { Rgba32.Blue, Rgba32.Blue, Rgba32.HotPink, Rgba32.Blue},
{ Color.Blue, Color.HotPink, Color.Blue, Color.Blue}, { Rgba32.Blue, Rgba32.HotPink, Rgba32.Blue, Rgba32.Blue},
{ Color.HotPink, Color.Blue, Color.Blue, Color.Blue} { Rgba32.HotPink, Rgba32.Blue, Rgba32.Blue, Rgba32.Blue}
}); });
} }
[Fact] [Fact]
public void ImageShouldBeFloodFilledWithBackwardDiagonal() public void ImageShouldBeFloodFilledWithBackwardDiagonal()
{ {
Test("BackwardDiagonal", Color.Blue, Brushes.BackwardDiagonal(Color.HotPink, Color.LimeGreen), Test("BackwardDiagonal", Rgba32.Blue, Brushes.BackwardDiagonal(Rgba32.HotPink, Rgba32.LimeGreen),
new Color[,] { new Rgba32[,] {
{ Color.HotPink, Color.LimeGreen, Color.LimeGreen, Color.LimeGreen}, { Rgba32.HotPink, Rgba32.LimeGreen, Rgba32.LimeGreen, Rgba32.LimeGreen},
{ Color.LimeGreen, Color.HotPink, Color.LimeGreen, Color.LimeGreen}, { Rgba32.LimeGreen, Rgba32.HotPink, Rgba32.LimeGreen, Rgba32.LimeGreen},
{ Color.LimeGreen, Color.LimeGreen, Color.HotPink, Color.LimeGreen}, { Rgba32.LimeGreen, Rgba32.LimeGreen, Rgba32.HotPink, Rgba32.LimeGreen},
{ Color.LimeGreen, Color.LimeGreen, Color.LimeGreen, Color.HotPink} { Rgba32.LimeGreen, Rgba32.LimeGreen, Rgba32.LimeGreen, Rgba32.HotPink}
}); });
} }
[Fact] [Fact]
public void ImageShouldBeFloodFilledWithBackwardDiagonal_transparent() public void ImageShouldBeFloodFilledWithBackwardDiagonal_transparent()
{ {
Test("BackwardDiagonal_Transparent", Color.Blue, Brushes.BackwardDiagonal(Color.HotPink), Test("BackwardDiagonal_Transparent", Rgba32.Blue, Brushes.BackwardDiagonal(Rgba32.HotPink),
new Color[,] { new Rgba32[,] {
{ Color.HotPink, Color.Blue, Color.Blue, Color.Blue}, { Rgba32.HotPink, Rgba32.Blue, Rgba32.Blue, Rgba32.Blue},
{ Color.Blue, Color.HotPink, Color.Blue, Color.Blue}, { Rgba32.Blue, Rgba32.HotPink, Rgba32.Blue, Rgba32.Blue},
{ Color.Blue, Color.Blue, Color.HotPink, Color.Blue}, { Rgba32.Blue, Rgba32.Blue, Rgba32.HotPink, Rgba32.Blue},
{ Color.Blue, Color.Blue, Color.Blue, Color.HotPink} { Rgba32.Blue, Rgba32.Blue, Rgba32.Blue, Rgba32.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<Color>> brush = new Mock<IBrush<Color>>(); Mock<IBrush<Rgba32>> brush = new Mock<IBrush<Rgba32>>();
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<Color> processor = new FillRegionProcessor<Color>(brush.Object, region.Object, options); FillRegionProcessor<Rgba32> processor = new FillRegionProcessor<Rgba32>(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(Color.HotPink) .Fill(Rgba32.HotPink)
.Save(output); .Save(output);
} }
using (PixelAccessor<Color> sourcePixels = image.Lock()) using (PixelAccessor<Rgba32> sourcePixels = image.Lock())
{ {
Assert.Equal(Color.HotPink, sourcePixels[9, 9]); Assert.Equal(Rgba32.HotPink, sourcePixels[9, 9]);
Assert.Equal(Color.HotPink, sourcePixels[199, 149]); Assert.Equal(Rgba32.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(Color.Blue) .BackgroundColor(Rgba32.Blue)
.Fill(Color.HotPink) .Fill(Rgba32.HotPink)
.Save(output); .Save(output);
} }
using (PixelAccessor<Color> sourcePixels = image.Lock()) using (PixelAccessor<Rgba32> sourcePixels = image.Lock())
{ {
Assert.Equal(Color.HotPink, sourcePixels[9, 9]); Assert.Equal(Rgba32.HotPink, sourcePixels[9, 9]);
Assert.Equal(Color.HotPink, sourcePixels[199, 149]); Assert.Equal(Rgba32.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))
{ {
Color color = new Color(Color.HotPink.R, Color.HotPink.G, Color.HotPink.B, 150); Rgba32 color = new Rgba32(Rgba32.HotPink.R, Rgba32.HotPink.G, Rgba32.HotPink.B, 150);
using (FileStream output = File.OpenWrite($"{path}/Opacity.png")) using (FileStream output = File.OpenWrite($"{path}/Opacity.png"))
{ {
image image
.BackgroundColor(Color.Blue) .BackgroundColor(Rgba32.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
Color mergedColor = new Color(Vector4.Lerp(Color.Blue.ToVector4(), Color.HotPink.ToVector4(), 150f / 255f)); Rgba32 mergedColor = new Rgba32(Vector4.Lerp(Rgba32.Blue.ToVector4(), Rgba32.HotPink.ToVector4(), 150f / 255f));
using (PixelAccessor<Color> sourcePixels = image.Lock()) using (PixelAccessor<Rgba32> 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(Color.Blue) .BackgroundColor(Rgba32.Blue)
.Draw(Color.HotPink, 5, simplePath.Clip(hole1)) .Draw(Rgba32.HotPink, 5, simplePath.Clip(hole1))
.Save(output); .Save(output);
} }
using (PixelAccessor<Color> sourcePixels = image.Lock()) using (PixelAccessor<Rgba32> sourcePixels = image.Lock())
{ {
Assert.Equal(Color.HotPink, sourcePixels[10, 10]); Assert.Equal(Rgba32.HotPink, sourcePixels[10, 10]);
Assert.Equal(Color.HotPink, sourcePixels[200, 150]); Assert.Equal(Rgba32.HotPink, sourcePixels[200, 150]);
Assert.Equal(Color.HotPink, sourcePixels[50, 300]); Assert.Equal(Rgba32.HotPink, sourcePixels[50, 300]);
Assert.Equal(Color.HotPink, sourcePixels[37, 85]); Assert.Equal(Rgba32.HotPink, sourcePixels[37, 85]);
Assert.Equal(Color.HotPink, sourcePixels[93, 85]); Assert.Equal(Rgba32.HotPink, sourcePixels[93, 85]);
Assert.Equal(Color.HotPink, sourcePixels[65, 137]); Assert.Equal(Rgba32.HotPink, sourcePixels[65, 137]);
Assert.Equal(Color.Blue, sourcePixels[2, 2]); Assert.Equal(Rgba32.Blue, sourcePixels[2, 2]);
//inside hole //inside hole
Assert.Equal(Color.Blue, sourcePixels[57, 99]); Assert.Equal(Rgba32.Blue, sourcePixels[57, 99]);
//inside shape //inside shape
Assert.Equal(Color.Blue, sourcePixels[100, 192]); Assert.Equal(Rgba32.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(Color.Blue) .BackgroundColor(Rgba32.Blue)
.Draw(Color.HotPink, 5, simplePath.Clip(hole1)) .Draw(Rgba32.HotPink, 5, simplePath.Clip(hole1))
.Save(output); .Save(output);
} }
using (PixelAccessor<Color> sourcePixels = image.Lock()) using (PixelAccessor<Rgba32> sourcePixels = image.Lock())
{ {
Assert.Equal(Color.HotPink, sourcePixels[10, 10]); Assert.Equal(Rgba32.HotPink, sourcePixels[10, 10]);
Assert.Equal(Color.HotPink, sourcePixels[200, 150]); Assert.Equal(Rgba32.HotPink, sourcePixels[200, 150]);
Assert.Equal(Color.HotPink, sourcePixels[50, 300]); Assert.Equal(Rgba32.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(Color.Blue, sourcePixels[2, 2]); Assert.Equal(Rgba32.Blue, sourcePixels[2, 2]);
//inside hole //inside hole
Assert.Equal(Color.Blue, sourcePixels[57, 99]); Assert.Equal(Rgba32.Blue, sourcePixels[57, 99]);
//inside shape //inside shape
Assert.Equal(Color.Blue, sourcePixels[100, 192]); Assert.Equal(Rgba32.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(Color.Blue) .BackgroundColor(Rgba32.Blue)
.Draw(Color.HotPink, 5, simplePath.Clip(hole1)) .Draw(Rgba32.HotPink, 5, simplePath.Clip(hole1))
.Save(output); .Save(output);
} }
using (PixelAccessor<Color> sourcePixels = image.Lock()) using (PixelAccessor<Rgba32> sourcePixels = image.Lock())
{ {
Assert.Equal(Color.HotPink, sourcePixels[10, 10]); Assert.Equal(Rgba32.HotPink, sourcePixels[10, 10]);
Assert.Equal(Color.HotPink, sourcePixels[200, 150]); Assert.Equal(Rgba32.HotPink, sourcePixels[200, 150]);
Assert.Equal(Color.HotPink, sourcePixels[50, 300]); Assert.Equal(Rgba32.HotPink, sourcePixels[50, 300]);
Assert.Equal(Color.Blue, sourcePixels[130, 41]); Assert.Equal(Rgba32.Blue, sourcePixels[130, 41]);
Assert.Equal(Color.Blue, sourcePixels[2, 2]); Assert.Equal(Rgba32.Blue, sourcePixels[2, 2]);
//inside hole //inside hole
Assert.Equal(Color.Blue, sourcePixels[57, 99]); Assert.Equal(Rgba32.Blue, sourcePixels[57, 99]);
//inside shape //inside shape
Assert.Equal(Color.Blue, sourcePixels[100, 192]); Assert.Equal(Rgba32.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(Color.Blue) .BackgroundColor(Rgba32.Blue)
.Draw(Pens.Dash(Color.HotPink, 5), simplePath.Clip(hole1)) .Draw(Pens.Dash(Rgba32.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)));
Color color = new Color(Color.HotPink.R, Color.HotPink.G, Color.HotPink.B, 150); Rgba32 color = new Rgba32(Rgba32.HotPink.R, Rgba32.HotPink.G, Rgba32.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(Color.Blue) .BackgroundColor(Rgba32.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
Color mergedColor = new Color(Vector4.Lerp(Color.Blue.ToVector4(), Color.HotPink.ToVector4(), 150f / 255f)); Rgba32 mergedColor = new Rgba32(Vector4.Lerp(Rgba32.Blue.ToVector4(), Rgba32.HotPink.ToVector4(), 150f / 255f));
using (PixelAccessor<Color> sourcePixels = image.Lock()) using (PixelAccessor<Rgba32> 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(Color.Blue, sourcePixels[2, 2]); Assert.Equal(Rgba32.Blue, sourcePixels[2, 2]);
//inside hole //inside hole
Assert.Equal(Color.Blue, sourcePixels[57, 99]); Assert.Equal(Rgba32.Blue, sourcePixels[57, 99]);
//inside shape //inside shape
Assert.Equal(Color.Blue, sourcePixels[100, 192]); Assert.Equal(Rgba32.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(Color.Blue) .BackgroundColor(Rgba32.Blue)
.DrawLines(Color.HotPink, 5, .DrawLines(Rgba32.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<Color> sourcePixels = image.Lock()) using (PixelAccessor<Rgba32> sourcePixels = image.Lock())
{ {
Assert.Equal(Color.HotPink, sourcePixels[9, 9]); Assert.Equal(Rgba32.HotPink, sourcePixels[9, 9]);
Assert.Equal(Color.HotPink, sourcePixels[199, 149]); Assert.Equal(Rgba32.HotPink, sourcePixels[199, 149]);
Assert.Equal(Color.Blue, sourcePixels[50, 50]); Assert.Equal(Rgba32.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(Color.Blue) .BackgroundColor(Rgba32.Blue)
.DrawLines(Color.HotPink, 5, .DrawLines(Rgba32.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<Color> sourcePixels = image.Lock()) using (PixelAccessor<Rgba32> sourcePixels = image.Lock())
{ {
Assert.Equal(Color.HotPink, sourcePixels[9, 9]); Assert.Equal(Rgba32.HotPink, sourcePixels[9, 9]);
Assert.Equal(Color.HotPink, sourcePixels[199, 149]); Assert.Equal(Rgba32.HotPink, sourcePixels[199, 149]);
Assert.Equal(Color.Blue, sourcePixels[50, 50]); Assert.Equal(Rgba32.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(Color.Blue) .BackgroundColor(Rgba32.Blue)
.DrawLines(Pens.Dash(Color.HotPink, 5), .DrawLines(Pens.Dash(Rgba32.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(Color.Blue) .BackgroundColor(Rgba32.Blue)
.DrawLines(Pens.Dot(Color.HotPink, 5), .DrawLines(Pens.Dot(Rgba32.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(Color.Blue) .BackgroundColor(Rgba32.Blue)
.DrawLines(Pens.DashDot(Color.HotPink, 5), .DrawLines(Pens.DashDot(Rgba32.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(Color.Blue) .BackgroundColor(Rgba32.Blue)
.DrawLines(Pens.DashDotDot(Color.HotPink, 5), new[] { .DrawLines(Pens.DashDotDot(Rgba32.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");
Color color = new Color(Color.HotPink.R, Color.HotPink.G, Color.HotPink.B, 150); Rgba32 color = new Rgba32(Rgba32.HotPink.R, Rgba32.HotPink.G, Rgba32.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(Color.Blue) .BackgroundColor(Rgba32.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
Color mergedColor = new Color(Vector4.Lerp(Color.Blue.ToVector4(), Color.HotPink.ToVector4(), 150f/255f)); Rgba32 mergedColor = new Rgba32(Vector4.Lerp(Rgba32.Blue.ToVector4(), Rgba32.HotPink.ToVector4(), 150f/255f));
using (PixelAccessor<Color> sourcePixels = image.Lock()) using (PixelAccessor<Rgba32> 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(Color.Blue, sourcePixels[50, 50]); Assert.Equal(Rgba32.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(Color.Blue) .BackgroundColor(Rgba32.Blue)
.DrawLines(Color.HotPink, 10, new[] { .DrawLines(Rgba32.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<Color> sourcePixels = image.Lock()) using (PixelAccessor<Rgba32> sourcePixels = image.Lock())
{ {
Assert.Equal(Color.HotPink, sourcePixels[8, 8]); Assert.Equal(Rgba32.HotPink, sourcePixels[8, 8]);
Assert.Equal(Color.HotPink, sourcePixels[198, 10]); Assert.Equal(Rgba32.HotPink, sourcePixels[198, 10]);
Assert.Equal(Color.Blue, sourcePixels[10, 50]); Assert.Equal(Rgba32.Blue, sourcePixels[10, 50]);
Assert.Equal(Color.Blue, sourcePixels[50, 50]); Assert.Equal(Rgba32.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();
Color color = Color.HotPink; Rgba32 color = Rgba32.HotPink;
SolidBrush brush = Brushes.Solid(Color.HotPink); SolidBrush brush = Brushes.Solid(Rgba32.HotPink);
Pen pen = new Pen(Color.Firebrick, 99.9f); Pen pen = new Pen(Rgba32.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<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor); DrawPathProcessor<Rgba32> processor = Assert.IsType<DrawPathProcessor<Rgba32>>(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<Color> pen = Assert.IsType<Pen<Color>>(processor.Pen); Pen<Rgba32> pen = Assert.IsType<Pen<Rgba32>>(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<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor); DrawPathProcessor<Rgba32> processor = Assert.IsType<DrawPathProcessor<Rgba32>>(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<Color> pen = Assert.IsType<Pen<Color>>(processor.Pen); Pen<Rgba32> pen = Assert.IsType<Pen<Rgba32>>(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<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor); DrawPathProcessor<Rgba32> processor = Assert.IsType<DrawPathProcessor<Rgba32>>(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<Color> pen = Assert.IsType<Pen<Color>>(processor.Pen); Pen<Rgba32> pen = Assert.IsType<Pen<Rgba32>>(processor.Pen);
Assert.Equal(thickness, pen.Width); Assert.Equal(thickness, pen.Width);
SolidBrush<Color> brush = Assert.IsType<SolidBrush<Color>>(pen.Brush); SolidBrush<Rgba32> brush = Assert.IsType<SolidBrush<Rgba32>>(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<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor); DrawPathProcessor<Rgba32> processor = Assert.IsType<DrawPathProcessor<Rgba32>>(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<Color> pen = Assert.IsType<Pen<Color>>(processor.Pen); Pen<Rgba32> pen = Assert.IsType<Pen<Rgba32>>(processor.Pen);
Assert.Equal(thickness, pen.Width); Assert.Equal(thickness, pen.Width);
SolidBrush<Color> brush = Assert.IsType<SolidBrush<Color>>(pen.Brush); SolidBrush<Rgba32> brush = Assert.IsType<SolidBrush<Rgba32>>(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<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor); DrawPathProcessor<Rgba32> processor = Assert.IsType<DrawPathProcessor<Rgba32>>(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<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor); DrawPathProcessor<Rgba32> processor = Assert.IsType<DrawPathProcessor<Rgba32>>(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();
Color color = Color.HotPink; Rgba32 color = Rgba32.HotPink;
SolidBrush brush = Brushes.Solid(Color.HotPink); SolidBrush brush = Brushes.Solid(Rgba32.HotPink);
Pen pen = new Pen(Color.Gray, 99.9f); Pen pen = new Pen(Rgba32.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<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor); DrawPathProcessor<Rgba32> processor = Assert.IsType<DrawPathProcessor<Rgba32>>(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<Color> pen = Assert.IsType<Pen<Color>>(processor.Pen); Pen<Rgba32> pen = Assert.IsType<Pen<Rgba32>>(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<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor); DrawPathProcessor<Rgba32> processor = Assert.IsType<DrawPathProcessor<Rgba32>>(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<Color> pen = Assert.IsType<Pen<Color>>(processor.Pen); Pen<Rgba32> pen = Assert.IsType<Pen<Rgba32>>(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<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor); DrawPathProcessor<Rgba32> processor = Assert.IsType<DrawPathProcessor<Rgba32>>(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<Color> pen = Assert.IsType<Pen<Color>>(processor.Pen); Pen<Rgba32> pen = Assert.IsType<Pen<Rgba32>>(processor.Pen);
Assert.Equal(thickness, pen.Width); Assert.Equal(thickness, pen.Width);
SolidBrush<Color> brush = Assert.IsType<SolidBrush<Color>>(pen.Brush); SolidBrush<Rgba32> brush = Assert.IsType<SolidBrush<Rgba32>>(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<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor); DrawPathProcessor<Rgba32> processor = Assert.IsType<DrawPathProcessor<Rgba32>>(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<Color> pen = Assert.IsType<Pen<Color>>(processor.Pen); Pen<Rgba32> pen = Assert.IsType<Pen<Rgba32>>(processor.Pen);
Assert.Equal(thickness, pen.Width); Assert.Equal(thickness, pen.Width);
SolidBrush<Color> brush = Assert.IsType<SolidBrush<Color>>(pen.Brush); SolidBrush<Rgba32> brush = Assert.IsType<SolidBrush<Rgba32>>(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<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor); DrawPathProcessor<Rgba32> processor = Assert.IsType<DrawPathProcessor<Rgba32>>(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<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor); DrawPathProcessor<Rgba32> processor = Assert.IsType<DrawPathProcessor<Rgba32>>(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();
Color color = Color.HotPink; Rgba32 color = Rgba32.HotPink;
SolidBrush brush = Brushes.Solid(Color.HotPink); SolidBrush brush = Brushes.Solid(Rgba32.HotPink);
Pen pen = new Pen(Color.Gray, 99.9f); Pen pen = new Pen(Rgba32.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<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor); DrawPathProcessor<Rgba32> processor = Assert.IsType<DrawPathProcessor<Rgba32>>(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<Color> pen = Assert.IsType<Pen<Color>>(processor.Pen); Pen<Rgba32> pen = Assert.IsType<Pen<Rgba32>>(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<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor); DrawPathProcessor<Rgba32> processor = Assert.IsType<DrawPathProcessor<Rgba32>>(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<Color> pen = Assert.IsType<Pen<Color>>(processor.Pen); Pen<Rgba32> pen = Assert.IsType<Pen<Rgba32>>(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<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor); DrawPathProcessor<Rgba32> processor = Assert.IsType<DrawPathProcessor<Rgba32>>(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<Color> pen = Assert.IsType<Pen<Color>>(processor.Pen); Pen<Rgba32> pen = Assert.IsType<Pen<Rgba32>>(processor.Pen);
Assert.Equal(thickness, pen.Width); Assert.Equal(thickness, pen.Width);
SolidBrush<Color> brush = Assert.IsType<SolidBrush<Color>>(pen.Brush); SolidBrush<Rgba32> brush = Assert.IsType<SolidBrush<Rgba32>>(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<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor); DrawPathProcessor<Rgba32> processor = Assert.IsType<DrawPathProcessor<Rgba32>>(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<Color> pen = Assert.IsType<Pen<Color>>(processor.Pen); Pen<Rgba32> pen = Assert.IsType<Pen<Rgba32>>(processor.Pen);
Assert.Equal(thickness, pen.Width); Assert.Equal(thickness, pen.Width);
SolidBrush<Color> brush = Assert.IsType<SolidBrush<Color>>(pen.Brush); SolidBrush<Rgba32> brush = Assert.IsType<SolidBrush<Rgba32>>(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<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor); DrawPathProcessor<Rgba32> processor = Assert.IsType<DrawPathProcessor<Rgba32>>(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<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor); DrawPathProcessor<Rgba32> processor = Assert.IsType<DrawPathProcessor<Rgba32>>(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();
Color color = Color.HotPink; Rgba32 color = Rgba32.HotPink;
SolidBrush brush = Brushes.Solid(Color.HotPink); SolidBrush brush = Brushes.Solid(Rgba32.HotPink);
Pen pen = new Pen(Color.Gray, 99.9f); Pen pen = new Pen(Rgba32.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<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor); DrawPathProcessor<Rgba32> processor = Assert.IsType<DrawPathProcessor<Rgba32>>(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<Color> pen = Assert.IsType<Pen<Color>>(processor.Pen); Pen<Rgba32> pen = Assert.IsType<Pen<Rgba32>>(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<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor); DrawPathProcessor<Rgba32> processor = Assert.IsType<DrawPathProcessor<Rgba32>>(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<Color> pen = Assert.IsType<Pen<Color>>(processor.Pen); Pen<Rgba32> pen = Assert.IsType<Pen<Rgba32>>(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<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor); DrawPathProcessor<Rgba32> processor = Assert.IsType<DrawPathProcessor<Rgba32>>(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<Color> pen = Assert.IsType<Pen<Color>>(processor.Pen); Pen<Rgba32> pen = Assert.IsType<Pen<Rgba32>>(processor.Pen);
Assert.Equal(thickness, pen.Width); Assert.Equal(thickness, pen.Width);
SolidBrush<Color> brush = Assert.IsType<SolidBrush<Color>>(pen.Brush); SolidBrush<Rgba32> brush = Assert.IsType<SolidBrush<Rgba32>>(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<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor); DrawPathProcessor<Rgba32> processor = Assert.IsType<DrawPathProcessor<Rgba32>>(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<Color> pen = Assert.IsType<Pen<Color>>(processor.Pen); Pen<Rgba32> pen = Assert.IsType<Pen<Rgba32>>(processor.Pen);
Assert.Equal(thickness, pen.Width); Assert.Equal(thickness, pen.Width);
SolidBrush<Color> brush = Assert.IsType<SolidBrush<Color>>(pen.Brush); SolidBrush<Rgba32> brush = Assert.IsType<SolidBrush<Rgba32>>(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<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor); DrawPathProcessor<Rgba32> processor = Assert.IsType<DrawPathProcessor<Rgba32>>(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<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor); DrawPathProcessor<Rgba32> processor = Assert.IsType<DrawPathProcessor<Rgba32>>(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();
Color color = Color.HotPink; Rgba32 color = Rgba32.HotPink;
SolidBrush brush = Brushes.Solid(Color.HotPink); SolidBrush brush = Brushes.Solid(Rgba32.HotPink);
Pen pen = new Pen(Color.Gray, 99.9f); Pen pen = new Pen(Rgba32.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<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor); DrawPathProcessor<Rgba32> processor = Assert.IsType<DrawPathProcessor<Rgba32>>(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<Color> pen = Assert.IsType<Pen<Color>>(processor.Pen); Pen<Rgba32> pen = Assert.IsType<Pen<Rgba32>>(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<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor); DrawPathProcessor<Rgba32> processor = Assert.IsType<DrawPathProcessor<Rgba32>>(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<Color> pen = Assert.IsType<Pen<Color>>(processor.Pen); Pen<Rgba32> pen = Assert.IsType<Pen<Rgba32>>(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<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor); DrawPathProcessor<Rgba32> processor = Assert.IsType<DrawPathProcessor<Rgba32>>(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<Color> pen = Assert.IsType<Pen<Color>>(processor.Pen); Pen<Rgba32> pen = Assert.IsType<Pen<Rgba32>>(processor.Pen);
Assert.Equal(thickness, pen.Width); Assert.Equal(thickness, pen.Width);
SolidBrush<Color> brush = Assert.IsType<SolidBrush<Color>>(pen.Brush); SolidBrush<Rgba32> brush = Assert.IsType<SolidBrush<Rgba32>>(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<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor); DrawPathProcessor<Rgba32> processor = Assert.IsType<DrawPathProcessor<Rgba32>>(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<Color> pen = Assert.IsType<Pen<Color>>(processor.Pen); Pen<Rgba32> pen = Assert.IsType<Pen<Rgba32>>(processor.Pen);
Assert.Equal(thickness, pen.Width); Assert.Equal(thickness, pen.Width);
SolidBrush<Color> brush = Assert.IsType<SolidBrush<Color>>(pen.Brush); SolidBrush<Rgba32> brush = Assert.IsType<SolidBrush<Rgba32>>(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<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor); DrawPathProcessor<Rgba32> processor = Assert.IsType<DrawPathProcessor<Rgba32>>(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<Color> processor = Assert.IsType<DrawPathProcessor<Color>>(img.ProcessorApplications[0].processor); DrawPathProcessor<Rgba32> processor = Assert.IsType<DrawPathProcessor<Rgba32>>(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();
Color color = Color.HotPink; Rgba32 color = Rgba32.HotPink;
SolidBrush brush = Brushes.Solid(Color.HotPink); SolidBrush brush = Brushes.Solid(Rgba32.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<Color> processor = Assert.IsType<FillRegionProcessor<Color>>(img.ProcessorApplications[0].processor); FillRegionProcessor<Rgba32> processor = Assert.IsType<FillRegionProcessor<Rgba32>>(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<Color> processor = Assert.IsType<FillRegionProcessor<Color>>(img.ProcessorApplications[0].processor); FillRegionProcessor<Rgba32> processor = Assert.IsType<FillRegionProcessor<Rgba32>>(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<Color> processor = Assert.IsType<FillRegionProcessor<Color>>(img.ProcessorApplications[0].processor); FillRegionProcessor<Rgba32> processor = Assert.IsType<FillRegionProcessor<Rgba32>>(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<Color> brush = Assert.IsType<SolidBrush<Color>>(processor.Brush); SolidBrush<Rgba32> brush = Assert.IsType<SolidBrush<Rgba32>>(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<Color> processor = Assert.IsType<FillRegionProcessor<Color>>(img.ProcessorApplications[0].processor); FillRegionProcessor<Rgba32> processor = Assert.IsType<FillRegionProcessor<Rgba32>>(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<Color> brush = Assert.IsType<SolidBrush<Color>>(processor.Brush); SolidBrush<Rgba32> brush = Assert.IsType<SolidBrush<Rgba32>>(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();
Color color = Color.HotPink; Rgba32 color = Rgba32.HotPink;
SolidBrush brush = Brushes.Solid(Color.HotPink); SolidBrush brush = Brushes.Solid(Rgba32.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<Color> processor = Assert.IsType<FillRegionProcessor<Color>>(img.ProcessorApplications[0].processor); FillRegionProcessor<Rgba32> processor = Assert.IsType<FillRegionProcessor<Rgba32>>(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<Color> processor = Assert.IsType<FillRegionProcessor<Color>>(img.ProcessorApplications[0].processor); FillRegionProcessor<Rgba32> processor = Assert.IsType<FillRegionProcessor<Rgba32>>(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<Color> processor = Assert.IsType<FillRegionProcessor<Color>>(img.ProcessorApplications[0].processor); FillRegionProcessor<Rgba32> processor = Assert.IsType<FillRegionProcessor<Rgba32>>(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<Color> brush = Assert.IsType<SolidBrush<Color>>(processor.Brush); SolidBrush<Rgba32> brush = Assert.IsType<SolidBrush<Rgba32>>(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<Color> processor = Assert.IsType<FillRegionProcessor<Color>>(img.ProcessorApplications[0].processor); FillRegionProcessor<Rgba32> processor = Assert.IsType<FillRegionProcessor<Rgba32>>(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<Color> brush = Assert.IsType<SolidBrush<Color>>(processor.Brush); SolidBrush<Rgba32> brush = Assert.IsType<SolidBrush<Rgba32>>(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();
Color color = Color.HotPink; Rgba32 color = Rgba32.HotPink;
SolidBrush brush = Brushes.Solid(Color.HotPink); SolidBrush brush = Brushes.Solid(Rgba32.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<Color> processor = Assert.IsType<FillRegionProcessor<Color>>(img.ProcessorApplications[0].processor); FillRegionProcessor<Rgba32> processor = Assert.IsType<FillRegionProcessor<Rgba32>>(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<Color> processor = Assert.IsType<FillRegionProcessor<Color>>(img.ProcessorApplications[0].processor); FillRegionProcessor<Rgba32> processor = Assert.IsType<FillRegionProcessor<Rgba32>>(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<Color> processor = Assert.IsType<FillRegionProcessor<Color>>(img.ProcessorApplications[0].processor); FillRegionProcessor<Rgba32> processor = Assert.IsType<FillRegionProcessor<Rgba32>>(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<Color> brush = Assert.IsType<SolidBrush<Color>>(processor.Brush); SolidBrush<Rgba32> brush = Assert.IsType<SolidBrush<Rgba32>>(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<Color> processor = Assert.IsType<FillRegionProcessor<Color>>(img.ProcessorApplications[0].processor); FillRegionProcessor<Rgba32> processor = Assert.IsType<FillRegionProcessor<Rgba32>>(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<Color> brush = Assert.IsType<SolidBrush<Color>>(processor.Brush); SolidBrush<Rgba32> brush = Assert.IsType<SolidBrush<Rgba32>>(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.Color}" /> /// <seealso cref="ImageSharp.Image{ImageSharp.Rgba32}" />
public class ProcessorWatchingImage : Image<Color> public class ProcessorWatchingImage : Image<Rgba32>
{ {
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<Color> processor, Rectangle rectangle) public override void ApplyProcessor(IImageProcessor<Rgba32> 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<Color> processor; public IImageProcessor<Rgba32> 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(Color.Blue) .BackgroundColor(Rgba32.Blue)
.DrawPolygon(Color.HotPink, 5, .DrawPolygon(Rgba32.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<Color> sourcePixels = image.Lock()) using (PixelAccessor<Rgba32> sourcePixels = image.Lock())
{ {
Assert.Equal(Color.HotPink, sourcePixels[9, 9]); Assert.Equal(Rgba32.HotPink, sourcePixels[9, 9]);
Assert.Equal(Color.HotPink, sourcePixels[199, 149]); Assert.Equal(Rgba32.HotPink, sourcePixels[199, 149]);
Assert.Equal(Color.Blue, sourcePixels[50, 50]); Assert.Equal(Rgba32.Blue, sourcePixels[50, 50]);
Assert.Equal(Color.Blue, sourcePixels[2, 2]); Assert.Equal(Rgba32.Blue, sourcePixels[2, 2]);
} }
} }
} }
@ -58,30 +58,30 @@ namespace ImageSharp.Tests.Drawing
new Vector2(50, 300) new Vector2(50, 300)
}; };
Color color = new Color(Color.HotPink.R, Color.HotPink.G, Color.HotPink.B, 150); Rgba32 color = new Rgba32(Rgba32.HotPink.R, Rgba32.HotPink.G, Rgba32.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(Color.Blue) .BackgroundColor(Rgba32.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
Color mergedColor = new Color(Vector4.Lerp(Color.Blue.ToVector4(), Color.HotPink.ToVector4(), 150f / 255f)); Rgba32 mergedColor = new Rgba32(Vector4.Lerp(Rgba32.Blue.ToVector4(), Rgba32.HotPink.ToVector4(), 150f / 255f));
using (PixelAccessor<Color> sourcePixels = image.Lock()) using (PixelAccessor<Rgba32> 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(Color.Blue, sourcePixels[50, 50]); Assert.Equal(Rgba32.Blue, sourcePixels[50, 50]);
Assert.Equal(Color.Blue, sourcePixels[2, 2]); Assert.Equal(Rgba32.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(Color.Blue) .BackgroundColor(Rgba32.Blue)
.Draw(Color.HotPink, 10, new Rectangle(10, 10, 190, 140)) .Draw(Rgba32.HotPink, 10, new Rectangle(10, 10, 190, 140))
.Save(output); .Save(output);
} }
using (PixelAccessor<Color> sourcePixels = image.Lock()) using (PixelAccessor<Rgba32> sourcePixels = image.Lock())
{ {
Assert.Equal(Color.HotPink, sourcePixels[8, 8]); Assert.Equal(Rgba32.HotPink, sourcePixels[8, 8]);
Assert.Equal(Color.HotPink, sourcePixels[198, 10]); Assert.Equal(Rgba32.HotPink, sourcePixels[198, 10]);
Assert.Equal(Color.HotPink, sourcePixels[10, 50]); Assert.Equal(Rgba32.HotPink, sourcePixels[10, 50]);
Assert.Equal(Color.Blue, sourcePixels[50, 50]); Assert.Equal(Rgba32.Blue, sourcePixels[50, 50]);
Assert.Equal(Color.Blue, sourcePixels[2, 2]); Assert.Equal(Rgba32.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(Color.Yellow, Color.HotPink, 0.2f); RecolorBrush brush = new RecolorBrush(Rgba32.Yellow, Rgba32.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(Color.Yellow, Color.HotPink, 0.2f); RecolorBrush brush = new RecolorBrush(Rgba32.Yellow, Rgba32.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(Color.Blue) .BackgroundColor(Rgba32.Blue)
.Fill(Color.HotPink, new Polygon(new BezierLineSegment(simplePath))) .Fill(Rgba32.HotPink, new Polygon(new BezierLineSegment(simplePath)))
.Save(output); .Save(output);
} }
using (PixelAccessor<Color> sourcePixels = image.Lock()) using (PixelAccessor<Rgba32> sourcePixels = image.Lock())
{ {
Assert.Equal(Color.HotPink, sourcePixels[150, 300]); Assert.Equal(Rgba32.HotPink, sourcePixels[150, 300]);
//curve points should not be never be set //curve points should not be never be set
Assert.Equal(Color.Blue, sourcePixels[240, 30]); Assert.Equal(Rgba32.Blue, sourcePixels[240, 30]);
// inside shape should not be empty // inside shape should not be empty
Assert.Equal(Color.HotPink, sourcePixels[200, 250]); Assert.Equal(Rgba32.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)
}; };
Color color = new Color(Color.HotPink.R, Color.HotPink.G, Color.HotPink.B, 150); Rgba32 color = new Rgba32(Rgba32.HotPink.R, Rgba32.HotPink.G, Rgba32.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(Color.Blue) .BackgroundColor(Rgba32.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
Color mergedColor = new Color(Vector4.Lerp(Color.Blue.ToVector4(), Color.HotPink.ToVector4(), 150f / 255f)); Rgba32 mergedColor = new Rgba32(Vector4.Lerp(Rgba32.Blue.ToVector4(), Rgba32.HotPink.ToVector4(), 150f / 255f));
using (PixelAccessor<Color> sourcePixels = image.Lock()) using (PixelAccessor<Rgba32> 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(Color.Blue, sourcePixels[240, 30]); Assert.Equal(Rgba32.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(Color.Blue) .BackgroundColor(Rgba32.Blue)
.Fill(Color.HotPink, clipped) .Fill(Rgba32.HotPink, clipped)
.Save(output); .Save(output);
} }
using (PixelAccessor<Color> sourcePixels = image.Lock()) using (PixelAccessor<Rgba32> sourcePixels = image.Lock())
{ {
Assert.Equal(Color.HotPink, sourcePixels[20, 35]); Assert.Equal(Rgba32.HotPink, sourcePixels[20, 35]);
//inside hole //inside hole
Assert.Equal(Color.Blue, sourcePixels[60, 100]); Assert.Equal(Rgba32.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(Color.Blue) .BackgroundColor(Rgba32.Blue)
.Fill(Color.HotPink, simplePath.Clip(hole1)) .Fill(Rgba32.HotPink, simplePath.Clip(hole1))
.Save(output); .Save(output);
} }
using (PixelAccessor<Color> sourcePixels = image.Lock()) using (PixelAccessor<Rgba32> sourcePixels = image.Lock())
{ {
Assert.Equal(Color.HotPink, sourcePixels[20, 35]); Assert.Equal(Rgba32.HotPink, sourcePixels[20, 35]);
//inside hole //inside hole
Assert.Equal(Color.Blue, sourcePixels[60, 100]); Assert.Equal(Rgba32.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)));
Color color = new Color(Color.HotPink.R, Color.HotPink.G, Color.HotPink.B, 150); Rgba32 color = new Rgba32(Rgba32.HotPink.R, Rgba32.HotPink.G, Rgba32.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(Color.Blue) .BackgroundColor(Rgba32.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
Color mergedColor = new Color(Vector4.Lerp(Color.Blue.ToVector4(), Color.HotPink.ToVector4(), 150f / 255f)); Rgba32 mergedColor = new Rgba32(Vector4.Lerp(Rgba32.Blue.ToVector4(), Rgba32.HotPink.ToVector4(), 150f / 255f));
using (PixelAccessor<Color> sourcePixels = image.Lock()) using (PixelAccessor<Rgba32> sourcePixels = image.Lock())
{ {
Assert.Equal(mergedColor, sourcePixels[20, 35]); Assert.Equal(mergedColor, sourcePixels[20, 35]);
//inside hole //inside hole
Assert.Equal(Color.Blue, sourcePixels[60, 100]); Assert.Equal(Rgba32.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(Color.HotPink, simplePath, new GraphicsOptions(true)) .FillPolygon(Rgba32.HotPink, simplePath, new GraphicsOptions(true))
.Save(output); .Save(output);
} }
using (PixelAccessor<Color> sourcePixels = image.Lock()) using (PixelAccessor<Rgba32> sourcePixels = image.Lock())
{ {
Assert.Equal(Color.HotPink, sourcePixels[81, 145]); Assert.Equal(Rgba32.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(Color.HotPink), simplePath, new GraphicsOptions(true)) .FillPolygon(Brushes.Horizontal(Rgba32.HotPink), simplePath, new GraphicsOptions(true))
.Save(output); .Save(output);
} }
using (PixelAccessor<Color> sourcePixels = image.Lock()) using (PixelAccessor<Rgba32> sourcePixels = image.Lock())
{ {
Assert.Equal(Color.HotPink, sourcePixels[81, 145]); Assert.Equal(Rgba32.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(Color.Blue) .BackgroundColor(Rgba32.Blue)
.FillPolygon(Color.HotPink, simplePath, new GraphicsOptions(false)) .FillPolygon(Rgba32.HotPink, simplePath, new GraphicsOptions(false))
.Save(output); .Save(output);
using (PixelAccessor<Color> sourcePixels = image.Lock()) using (PixelAccessor<Rgba32> sourcePixels = image.Lock())
{ {
Assert.Equal(Color.HotPink, sourcePixels[11, 11]); Assert.Equal(Rgba32.HotPink, sourcePixels[11, 11]);
Assert.Equal(Color.HotPink, sourcePixels[199, 150]); Assert.Equal(Rgba32.HotPink, sourcePixels[199, 150]);
Assert.Equal(Color.HotPink, sourcePixels[50, 50]); Assert.Equal(Rgba32.HotPink, sourcePixels[50, 50]);
Assert.Equal(Color.Blue, sourcePixels[2, 2]); Assert.Equal(Rgba32.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(Color.Blue) .BackgroundColor(Rgba32.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)
}; };
Color color = new Color(Color.HotPink.R, Color.HotPink.G, Color.HotPink.B, 150); Rgba32 color = new Rgba32(Rgba32.HotPink.R, Rgba32.HotPink.G, Rgba32.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(Color.Blue) .BackgroundColor(Rgba32.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
Color mergedColor = new Color(Vector4.Lerp(Color.Blue.ToVector4(), Color.HotPink.ToVector4(), 150f / 255f)); Rgba32 mergedColor = new Rgba32(Vector4.Lerp(Rgba32.Blue.ToVector4(), Rgba32.HotPink.ToVector4(), 150f / 255f));
using (PixelAccessor<Color> sourcePixels = image.Lock()) using (PixelAccessor<Rgba32> sourcePixels = image.Lock())
{ {
Assert.Equal(Color.Blue, sourcePixels[2, 2]); Assert.Equal(Rgba32.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(Color.Blue) .BackgroundColor(Rgba32.Blue)
.Fill(Color.HotPink, new SixLabors.Shapes.Rectangle(10, 10, 190, 140)) .Fill(Rgba32.HotPink, new SixLabors.Shapes.Rectangle(10, 10, 190, 140))
.Save(output); .Save(output);
} }
using (PixelAccessor<Color> sourcePixels = image.Lock()) using (PixelAccessor<Rgba32> sourcePixels = image.Lock())
{ {
Assert.Equal(Color.HotPink, sourcePixels[11, 11]); Assert.Equal(Rgba32.HotPink, sourcePixels[11, 11]);
Assert.Equal(Color.HotPink, sourcePixels[198, 10]); Assert.Equal(Rgba32.HotPink, sourcePixels[198, 10]);
Assert.Equal(Color.HotPink, sourcePixels[10, 50]); Assert.Equal(Rgba32.HotPink, sourcePixels[10, 50]);
Assert.Equal(Color.HotPink, sourcePixels[50, 50]); Assert.Equal(Rgba32.HotPink, sourcePixels[50, 50]);
Assert.Equal(Color.Blue, sourcePixels[2, 2]); Assert.Equal(Rgba32.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(Color.Blue) .BackgroundColor(Rgba32.Blue)
.Fill(Color.HotPink, new RegularPolygon(50, 50, 3, 30)) .Fill(Rgba32.HotPink, new RegularPolygon(50, 50, 3, 30))
.Save(output); .Save(output);
} }
using (PixelAccessor<Color> sourcePixels = image.Lock()) using (PixelAccessor<Rgba32> sourcePixels = image.Lock())
{ {
Assert.Equal(Color.Blue, sourcePixels[30, 65]); Assert.Equal(Rgba32.Blue, sourcePixels[30, 65]);
Assert.Equal(Color.HotPink, sourcePixels[50, 50]); Assert.Equal(Rgba32.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(Color.Blue) .BackgroundColor(Rgba32.Blue)
.Fill(Color.HotPink, new RegularPolygon(50, 50, 7, 30, -(float)Math.PI)) .Fill(Rgba32.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(Color.Blue) .BackgroundColor(Rgba32.Blue)
.Fill(Color.HotPink, new Ellipse(50, 50, 30, 50) .Fill(Rgba32.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(Color.Blue) .Fill(Rgba32.Blue)
.FillPolygon(Color.HotPink, new[] .FillPolygon(Rgba32.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
{ {
Color color = Color.HotPink; Rgba32 color = Rgba32.HotPink;
SolidBrush brush = Brushes.Solid(Color.HotPink); SolidBrush brush = Brushes.Solid(Rgba32.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(Color.Red), Brushes.Solid(Rgba32.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<Color>>(this.img.ProcessorApplications[0].processor); Assert.IsType<FillRegionProcessor<Rgba32>>(this.img.ProcessorApplications[0].processor);
} }
[Fact] [Fact]
public void FillsForEachACharachterWhenBrushSetAndNotPenDefaultOptions() public void FillsForEachACharachterWhenBrushSetAndNotPenDefaultOptions()
{ {
this.img.DrawText("123", this.Font, Brushes.Solid(Color.Red), null, Vector2.Zero); this.img.DrawText("123", this.Font, Brushes.Solid(Rgba32.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<Color>>(this.img.ProcessorApplications[0].processor); Assert.IsType<FillRegionProcessor<Rgba32>>(this.img.ProcessorApplications[0].processor);
} }
[Fact] [Fact]
public void FillsForEachACharachterWhenBrushSet() public void FillsForEachACharachterWhenBrushSet()
{ {
this.img.DrawText("123", this.Font, Brushes.Solid(Color.Red), Vector2.Zero, new TextGraphicsOptions(true)); this.img.DrawText("123", this.Font, Brushes.Solid(Rgba32.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<Color>>(this.img.ProcessorApplications[0].processor); Assert.IsType<FillRegionProcessor<Rgba32>>(this.img.ProcessorApplications[0].processor);
} }
[Fact] [Fact]
public void FillsForEachACharachterWhenBrushSetDefaultOptions() public void FillsForEachACharachterWhenBrushSetDefaultOptions()
{ {
this.img.DrawText("123", this.Font, Brushes.Solid(Color.Red), Vector2.Zero); this.img.DrawText("123", this.Font, Brushes.Solid(Rgba32.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<Color>>(this.img.ProcessorApplications[0].processor); Assert.IsType<FillRegionProcessor<Rgba32>>(this.img.ProcessorApplications[0].processor);
} }
[Fact] [Fact]
public void FillsForEachACharachterWhenColorSet() public void FillsForEachACharachterWhenColorSet()
{ {
this.img.DrawText("123", this.Font, Color.Red, Vector2.Zero, new TextGraphicsOptions(true)); this.img.DrawText("123", this.Font, Rgba32.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<Color> processor = FillRegionProcessor<Rgba32> processor =
Assert.IsType<FillRegionProcessor<Color>>(this.img.ProcessorApplications[0].processor); Assert.IsType<FillRegionProcessor<Rgba32>>(this.img.ProcessorApplications[0].processor);
SolidBrush<Color> brush = Assert.IsType<SolidBrush<Color>>(processor.Brush); SolidBrush<Rgba32> brush = Assert.IsType<SolidBrush<Rgba32>>(processor.Brush);
Assert.Equal(Color.Red, brush.Color); Assert.Equal(Rgba32.Red, brush.Color);
} }
[Fact] [Fact]
public void FillsForEachACharachterWhenColorSetDefaultOptions() public void FillsForEachACharachterWhenColorSetDefaultOptions()
{ {
this.img.DrawText("123", this.Font, Color.Red, Vector2.Zero); this.img.DrawText("123", this.Font, Rgba32.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<Color>>(this.img.ProcessorApplications[0].processor); Assert.IsType<FillRegionProcessor<Rgba32>>(this.img.ProcessorApplications[0].processor);
FillRegionProcessor<Color> processor = FillRegionProcessor<Rgba32> processor =
Assert.IsType<FillRegionProcessor<Color>>(this.img.ProcessorApplications[0].processor); Assert.IsType<FillRegionProcessor<Rgba32>>(this.img.ProcessorApplications[0].processor);
SolidBrush<Color> brush = Assert.IsType<SolidBrush<Color>>(processor.Brush); SolidBrush<Rgba32> brush = Assert.IsType<SolidBrush<Rgba32>>(processor.Brush);
Assert.Equal(Color.Red, brush.Color); Assert.Equal(Rgba32.Red, brush.Color);
} }
[Fact] [Fact]
@ -129,43 +129,43 @@ namespace ImageSharp.Tests.Drawing.Text
"123", "123",
this.Font, this.Font,
null, null,
Pens.Dash(Color.Red, 1), Pens.Dash(Rgba32.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<Color>>(this.img.ProcessorApplications[0].processor); Assert.IsType<DrawPathProcessor<Rgba32>>(this.img.ProcessorApplications[0].processor);
} }
[Fact] [Fact]
public void DrawForEachACharachterWhenPenSetAndNotBrushDefaultOptions() public void DrawForEachACharachterWhenPenSetAndNotBrushDefaultOptions()
{ {
this.img.DrawText("123", this.Font, null, Pens.Dash(Color.Red, 1), Vector2.Zero); this.img.DrawText("123", this.Font, null, Pens.Dash(Rgba32.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<Color>>(this.img.ProcessorApplications[0].processor); Assert.IsType<DrawPathProcessor<Rgba32>>(this.img.ProcessorApplications[0].processor);
} }
[Fact] [Fact]
public void DrawForEachACharachterWhenPenSet() public void DrawForEachACharachterWhenPenSet()
{ {
this.img.DrawText("123", this.Font, Pens.Dash(Color.Red, 1), Vector2.Zero, new TextGraphicsOptions(true)); this.img.DrawText("123", this.Font, Pens.Dash(Rgba32.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<Color>>(this.img.ProcessorApplications[0].processor); Assert.IsType<DrawPathProcessor<Rgba32>>(this.img.ProcessorApplications[0].processor);
} }
[Fact] [Fact]
public void DrawForEachACharachterWhenPenSetDefaultOptions() public void DrawForEachACharachterWhenPenSetDefaultOptions()
{ {
this.img.DrawText("123", this.Font, Pens.Dash(Color.Red, 1), Vector2.Zero); this.img.DrawText("123", this.Font, Pens.Dash(Rgba32.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<Color>>(this.img.ProcessorApplications[0].processor); Assert.IsType<DrawPathProcessor<Rgba32>>(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(Color.Red), Brushes.Solid(Rgba32.Red),
Pens.Dash(Color.Red, 1), Pens.Dash(Rgba32.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(Color.Red), Pens.Dash(Color.Red, 1), Vector2.Zero); this.img.DrawText("123", this.Font, Brushes.Solid(Rgba32.Red), Pens.Dash(Rgba32.Red, 1), Vector2.Zero);
Assert.NotEmpty(this.img.ProcessorApplications); Assert.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(Color.Red), Brushes.Solid(Rgba32.Red),
Pens.Dash(Color.Red, 1), Pens.Dash(Rgba32.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<Color>>(this.img.ProcessorApplications[0].processor); Assert.IsType<FillRegionProcessor<Rgba32>>(this.img.ProcessorApplications[0].processor);
Assert.IsType<DrawPathProcessor<Color>>(this.img.ProcessorApplications[1].processor); Assert.IsType<DrawPathProcessor<Rgba32>>(this.img.ProcessorApplications[1].processor);
} }
[Fact] [Fact]
public void BrushAppliesBeforPenDefaultOptions() public void BrushAppliesBeforPenDefaultOptions()
{ {
this.img.DrawText("1", this.Font, Brushes.Solid(Color.Red), Pens.Dash(Color.Red, 1), Vector2.Zero); this.img.DrawText("1", this.Font, Brushes.Solid(Rgba32.Red), Pens.Dash(Rgba32.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<Color>>(this.img.ProcessorApplications[0].processor); Assert.IsType<FillRegionProcessor<Rgba32>>(this.img.ProcessorApplications[0].processor);
Assert.IsType<DrawPathProcessor<Color>>(this.img.ProcessorApplications[1].processor); Assert.IsType<DrawPathProcessor<Rgba32>>(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(Color.Red), Vector2.Zero, new TextGraphicsOptions(true) { this.img.DrawText("1", this.Font, Brushes.Solid(Rgba32.Red), Vector2.Zero, new TextGraphicsOptions(true) {
UseImageResolution = false UseImageResolution = false
}); });
this.img.DrawText("1", this.Font, Brushes.Solid(Color.Red), Vector2.Zero, new TextGraphicsOptions(true) this.img.DrawText("1", this.Font, Brushes.Solid(Rgba32.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<Color> ownResolution = Assert.IsType<FillRegionProcessor<Color>>(this.img.ProcessorApplications[0].processor); FillRegionProcessor<Rgba32> ownResolution = Assert.IsType<FillRegionProcessor<Rgba32>>(this.img.ProcessorApplications[0].processor);
FillRegionProcessor<Color> imgResolution = Assert.IsType<FillRegionProcessor<Color>>(this.img.ProcessorApplications[1].processor); FillRegionProcessor<Rgba32> imgResolution = Assert.IsType<FillRegionProcessor<Rgba32>>(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(Color.DarkBlue) img.Fill(Rgba32.DarkBlue)
.DrawText("AB\nAB", new Font(this.Font, 50), Color.Red, new Vector2(0, 0)); .DrawText("AB\nAB", new Font(this.Font, 50), Rgba32.Red, new Vector2(0, 0));
img.Save($"{this.CreateOutputDirectory("Drawing", "Text")}/AB.png"); img.Save($"{this.CreateOutputDirectory("Drawing", "Text")}/AB.png");
} }
} }

4
tests/ImageSharp.Tests/Formats/Jpg/BadEofJpegTests.cs

@ -27,7 +27,7 @@ namespace ImageSharp.Tests
} }
[Theory] [Theory]
[WithFile(TestImages.Jpeg.Baseline.Bad.MissingEOF, PixelTypes.Color)] [WithFile(TestImages.Jpeg.Baseline.Bad.MissingEOF, PixelTypes.Rgba32)]
public void LoadBaselineImage<TColor>(TestImageProvider<TColor> provider) public void LoadBaselineImage<TColor>(TestImageProvider<TColor> provider)
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>
{ {
@ -39,7 +39,7 @@ namespace ImageSharp.Tests
} }
[Theory] // TODO: #18 [Theory] // TODO: #18
[WithFile(TestImages.Jpeg.Progressive.Bad.BadEOF, PixelTypes.Color)] [WithFile(TestImages.Jpeg.Progressive.Bad.BadEOF, PixelTypes.Rgba32)]
public void LoadProgressiveImage<TColor>(TestImageProvider<TColor> provider) public void LoadProgressiveImage<TColor>(TestImageProvider<TColor> provider)
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>
{ {

4
tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs

@ -25,7 +25,7 @@ namespace ImageSharp.Tests
public static string[] ProgressiveTestJpegs = TestImages.Jpeg.Progressive.All; public static string[] ProgressiveTestJpegs = TestImages.Jpeg.Progressive.All;
[Theory] [Theory]
[WithFileCollection(nameof(BaselineTestJpegs), PixelTypes.Color | PixelTypes.StandardImageClass | PixelTypes.Argb32)] [WithFileCollection(nameof(BaselineTestJpegs), PixelTypes.Rgba32 | PixelTypes.StandardImageClass | PixelTypes.Argb32)]
public void OpenBaselineJpeg_SaveBmp<TColor>(TestImageProvider<TColor> provider) public void OpenBaselineJpeg_SaveBmp<TColor>(TestImageProvider<TColor> provider)
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>
{ {
@ -36,7 +36,7 @@ namespace ImageSharp.Tests
} }
[Theory] [Theory]
[WithFileCollection(nameof(ProgressiveTestJpegs), PixelTypes.Color | PixelTypes.StandardImageClass | PixelTypes.Argb32)] [WithFileCollection(nameof(ProgressiveTestJpegs), PixelTypes.Rgba32 | PixelTypes.StandardImageClass | PixelTypes.Argb32)]
public void OpenProgressiveJpeg_SaveBmp<TColor>(TestImageProvider<TColor> provider) public void OpenProgressiveJpeg_SaveBmp<TColor>(TestImageProvider<TColor> provider)
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>
{ {

4
tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.cs

@ -48,8 +48,8 @@ namespace ImageSharp.Tests
} }
[Theory] [Theory]
[WithFileCollection(nameof(AllBmpFiles), PixelTypes.Color | PixelTypes.StandardImageClass | PixelTypes.Argb32, JpegSubsample.Ratio420, 75)] [WithFileCollection(nameof(AllBmpFiles), PixelTypes.Rgba32 | PixelTypes.StandardImageClass | PixelTypes.Argb32, JpegSubsample.Ratio420, 75)]
[WithFileCollection(nameof(AllBmpFiles), PixelTypes.Color | PixelTypes.StandardImageClass | PixelTypes.Argb32, JpegSubsample.Ratio444, 75)] [WithFileCollection(nameof(AllBmpFiles), PixelTypes.Rgba32 | PixelTypes.StandardImageClass | PixelTypes.Argb32, JpegSubsample.Ratio444, 75)]
public void OpenBmp_SaveJpeg<TColor>(TestImageProvider<TColor> provider, JpegSubsample subSample, int quality) public void OpenBmp_SaveJpeg<TColor>(TestImageProvider<TColor> provider, JpegSubsample subSample, int quality)
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>
{ {

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<Color>[] testImages = Image<Rgba32>[] testImages =
testFiles.Select( testFiles.Select(
tf => TestImageProvider<Color>.File(tf, pixelTypeOverride: PixelTypes.StandardImageClass).GetImage()) tf => TestImageProvider<Rgba32>.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<Color> img in testImages) foreach (Image<Rgba32> 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 };

4
tests/ImageSharp.Tests/Formats/Jpg/JpegUtilsTests.cs

@ -39,7 +39,7 @@ namespace ImageSharp.Tests
} }
[Theory] [Theory]
[WithMemberFactory(nameof(CreateTestImage), PixelTypes.Color | PixelTypes.StandardImageClass | PixelTypes.Argb32)] [WithMemberFactory(nameof(CreateTestImage), PixelTypes.Rgba32| PixelTypes.StandardImageClass | PixelTypes.Argb32)]
public void CopyStretchedRGBTo_FromOrigo<TColor>(TestImageProvider<TColor> provider) public void CopyStretchedRGBTo_FromOrigo<TColor>(TestImageProvider<TColor> provider)
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>
{ {
@ -61,7 +61,7 @@ namespace ImageSharp.Tests
} }
[Theory] [Theory]
[WithMemberFactory(nameof(CreateTestImage), PixelTypes.Color | PixelTypes.StandardImageClass | PixelTypes.Argb32)] [WithMemberFactory(nameof(CreateTestImage), PixelTypes.Rgba32| PixelTypes.StandardImageClass | PixelTypes.Argb32)]
public void CopyStretchedRGBTo_WithOffset<TColor>(TestImageProvider<TColor> provider) public void CopyStretchedRGBTo_WithOffset<TColor>(TestImageProvider<TColor> provider)
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>
{ {

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<Color> returnImage; private Image<Rgba32> 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<Color>(It.IsAny<Configuration>(), It.IsAny<Stream>(), It.IsAny<IDecoderOptions>())) this.localDecoder.Setup(x => x.Decode<Rgba32>(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<Color> img = Image.Load<Color>(this.DataStream); Image<Rgba32> img = Image.Load<Rgba32>(this.DataStream);
Assert.NotNull(img); Assert.NotNull(img);
Assert.Equal(TestFormat.GlobalTestFormat.Sample<Color>(), img); Assert.Equal(TestFormat.GlobalTestFormat.Sample<Rgba32>(), 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<Color> img = Image.Load<Color>(this.DataStream, this.decoderOptions); Image<Rgba32> img = Image.Load<Rgba32>(this.DataStream, this.decoderOptions);
Assert.NotNull(img); Assert.NotNull(img);
Assert.Equal(TestFormat.GlobalTestFormat.Sample<Color>(), img); Assert.Equal(TestFormat.GlobalTestFormat.Sample<Rgba32>(), 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<Color>(this.LocalConfiguration, stream, null)); this.localDecoder.Verify(x => x.Decode<Rgba32>(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<Color> img = Image.Load<Color>(this.LocalConfiguration, stream); Image<Rgba32> img = Image.Load<Rgba32>(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<Color>(this.LocalConfiguration, stream, null)); this.localDecoder.Verify(x => x.Decode<Rgba32>(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<Color>(this.LocalConfiguration, stream, this.decoderOptions)); this.localDecoder.Verify(x => x.Decode<Rgba32>(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<Color> img = Image.Load<Color>(this.LocalConfiguration, stream, this.decoderOptions); Image<Rgba32> img = Image.Load<Rgba32>(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<Color>(this.LocalConfiguration, stream, this.decoderOptions)); this.localDecoder.Verify(x => x.Decode<Rgba32>(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<Color>(Configuration.Default, stream, null)); this.localDecoder.Verify(x => x.Decode<Rgba32>(Configuration.Default, stream, null));
} }
[Fact] [Fact]
public void LoadFromStreamWithTypeAndDecoder() public void LoadFromStreamWithTypeAndDecoder()
{ {
Stream stream = new MemoryStream(); Stream stream = new MemoryStream();
Image<Color> img = Image.Load<Color>(stream, this.localDecoder.Object); Image<Rgba32> img = Image.Load<Rgba32>(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<Color>(Configuration.Default, stream, null)); this.localDecoder.Verify(x => x.Decode<Rgba32>(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<Color>(Configuration.Default, stream, this.decoderOptions)); this.localDecoder.Verify(x => x.Decode<Rgba32>(Configuration.Default, stream, this.decoderOptions));
} }
[Fact] [Fact]
public void LoadFromStreamWithTypeAndDecoderAndOptions() public void LoadFromStreamWithTypeAndDecoderAndOptions()
{ {
Stream stream = new MemoryStream(); Stream stream = new MemoryStream();
Image<Color> img = Image.Load<Color>(stream, this.localDecoder.Object, this.decoderOptions); Image<Rgba32> img = Image.Load<Rgba32>(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<Color>(Configuration.Default, stream, this.decoderOptions)); this.localDecoder.Verify(x => x.Decode<Rgba32>(Configuration.Default, stream, this.decoderOptions));
} }
[Fact] [Fact]
@ -252,10 +252,10 @@ namespace ImageSharp.Tests
[Fact] [Fact]
public void LoadFromBytesWithType() public void LoadFromBytesWithType()
{ {
Image<Color> img = Image.Load<Color>(this.DataStream.ToArray()); Image<Rgba32> img = Image.Load<Rgba32>(this.DataStream.ToArray());
Assert.NotNull(img); Assert.NotNull(img);
Assert.Equal(TestFormat.GlobalTestFormat.Sample<Color>(), img); Assert.Equal(TestFormat.GlobalTestFormat.Sample<Rgba32>(), 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<Color> img = Image.Load<Color>(this.DataStream.ToArray(), this.decoderOptions); Image<Rgba32> img = Image.Load<Rgba32>(this.DataStream.ToArray(), this.decoderOptions);
Assert.NotNull(img); Assert.NotNull(img);
Assert.Equal(TestFormat.GlobalTestFormat.Sample<Color>(), img); Assert.Equal(TestFormat.GlobalTestFormat.Sample<Rgba32>(), 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<Color>(this.LocalConfiguration, It.IsAny<Stream>(), null)); this.localDecoder.Verify(x => x.Decode<Rgba32>(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<Color> img = Image.Load<Color>(this.LocalConfiguration, this.DataStream.ToArray()); Image<Rgba32> img = Image.Load<Rgba32>(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<Color>(this.LocalConfiguration, It.IsAny<Stream>(), null)); this.localDecoder.Verify(x => x.Decode<Rgba32>(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<Color>(this.LocalConfiguration, It.IsAny<Stream>(), this.decoderOptions)); this.localDecoder.Verify(x => x.Decode<Rgba32>(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<Color> img = Image.Load<Color>(this.LocalConfiguration, this.DataStream.ToArray(), this.decoderOptions); Image<Rgba32> img = Image.Load<Rgba32>(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<Color>(this.LocalConfiguration, It.IsAny<Stream>(), this.decoderOptions)); this.localDecoder.Verify(x => x.Decode<Rgba32>(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<Color>(Configuration.Default, It.IsAny<Stream>(), null)); this.localDecoder.Verify(x => x.Decode<Rgba32>(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<Color> img = Image.Load<Color>(this.DataStream.ToArray(), this.localDecoder.Object); Image<Rgba32> img = Image.Load<Rgba32>(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<Color>(Configuration.Default, It.IsAny<Stream>(), null)); this.localDecoder.Verify(x => x.Decode<Rgba32>(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<Color>(Configuration.Default, It.IsAny<Stream>(), this.decoderOptions)); this.localDecoder.Verify(x => x.Decode<Rgba32>(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<Color> img = Image.Load<Color>(this.DataStream.ToArray(), this.localDecoder.Object, this.decoderOptions); Image<Rgba32> img = Image.Load<Rgba32>(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<Color>(Configuration.Default, It.IsAny<Stream>(), this.decoderOptions)); this.localDecoder.Verify(x => x.Decode<Rgba32>(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<Color> img = Image.Load<Color>(this.DataStream); Image<Rgba32> img = Image.Load<Rgba32>(this.DataStream);
Assert.NotNull(img); Assert.NotNull(img);
Assert.Equal(TestFormat.GlobalTestFormat.Sample<Color>(), img); Assert.Equal(TestFormat.GlobalTestFormat.Sample<Rgba32>(), 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<Color> img = Image.Load<Color>(this.DataStream, this.decoderOptions); Image<Rgba32> img = Image.Load<Rgba32>(this.DataStream, this.decoderOptions);
Assert.NotNull(img); Assert.NotNull(img);
Assert.Equal(TestFormat.GlobalTestFormat.Sample<Color>(), img); Assert.Equal(TestFormat.GlobalTestFormat.Sample<Rgba32>(), 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<Color>(this.LocalConfiguration, this.DataStream, null)); this.localDecoder.Verify(x => x.Decode<Rgba32>(this.LocalConfiguration, this.DataStream, null));
} }
[Fact] [Fact]
public void LoadFromFileWithTypeAndConfig() public void LoadFromFileWithTypeAndConfig()
{ {
Image<Color> img = Image.Load<Color>(this.LocalConfiguration, this.FilePath); Image<Rgba32> img = Image.Load<Rgba32>(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<Color>(this.LocalConfiguration, this.DataStream, null)); this.localDecoder.Verify(x => x.Decode<Rgba32>(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<Color>(this.LocalConfiguration, this.DataStream, this.decoderOptions)); this.localDecoder.Verify(x => x.Decode<Rgba32>(this.LocalConfiguration, this.DataStream, this.decoderOptions));
} }
[Fact] [Fact]
public void LoadFromFileWithTypeAndConfigAndOptions() public void LoadFromFileWithTypeAndConfigAndOptions()
{ {
Image<Color> img = Image.Load<Color>(this.LocalConfiguration, this.FilePath, this.decoderOptions); Image<Rgba32> img = Image.Load<Rgba32>(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<Color>(this.LocalConfiguration, this.DataStream, this.decoderOptions)); this.localDecoder.Verify(x => x.Decode<Rgba32>(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<Color>(Configuration.Default, this.DataStream, null)); this.localDecoder.Verify(x => x.Decode<Rgba32>(Configuration.Default, this.DataStream, null));
} }
[Fact] [Fact]
public void LoadFromFileWithTypeAndDecoder() public void LoadFromFileWithTypeAndDecoder()
{ {
Image<Color> img = Image.Load<Color>(this.FilePath, this.localDecoder.Object); Image<Rgba32> img = Image.Load<Rgba32>(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<Color>(Configuration.Default, this.DataStream, null)); this.localDecoder.Verify(x => x.Decode<Rgba32>(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<Color>(Configuration.Default, this.DataStream, this.decoderOptions)); this.localDecoder.Verify(x => x.Decode<Rgba32>(Configuration.Default, this.DataStream, this.decoderOptions));
} }
[Fact] [Fact]
public void LoadFromFileWithTypeAndDecoderAndOptions() public void LoadFromFileWithTypeAndDecoderAndOptions()
{ {
Image<Color> img = Image.Load<Color>(this.FilePath, this.localDecoder.Object, this.decoderOptions); Image<Rgba32> img = Image.Load<Rgba32>(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<Color>(Configuration.Default, this.DataStream, this.decoderOptions)); this.localDecoder.Verify(x => x.Decode<Rgba32>(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<Color>(this.Image, stream, null)); this.encoder.Verify(x => x.Encode<Rgba32>(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<Color>(this.Image, stream, this.encoderOptions)); this.encoder.Verify(x => x.Encode<Rgba32>(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<Color>(this.Image, stream, null)); this.encoderNotInFormat.Verify(x => x.Encode<Rgba32>(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<Color>(this.Image, stream, this.encoderOptions)); this.encoderNotInFormat.Verify(x => x.Encode<Rgba32>(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<Color>(this.Image, stream, null)); this.encoderNotInFormat.Verify(x => x.Encode<Rgba32>(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<Color>(this.Image, stream, this.encoderOptions)); this.encoderNotInFormat.Verify(x => x.Encode<Rgba32>(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<Color>(this.Image, stream, null)); this.encoder.Verify(x => x.Encode<Rgba32>(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<Color>(this.Image, stream, this.encoderOptions)); this.encoder.Verify(x => x.Encode<Rgba32>(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<Color>(this.Image, stream, null)); this.encoderNotInFormat.Verify(x => x.Encode<Rgba32>(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<Color>(this.Image, stream, this.encoderOptions)); this.encoderNotInFormat.Verify(x => x.Encode<Rgba32>(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<Color>(this.Image, stream, null)); this.encoderNotInFormat.Verify(x => x.Encode<Rgba32>(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<Color>(this.Image, stream, this.encoderOptions)); this.encoderNotInFormat.Verify(x => x.Encode<Rgba32>(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<Color> image = new Image<Color>(1, 1)) using (Image<Rgba32> image = new Image<Rgba32>(1, 1))
{ {
CopyFromZYX(image); CopyFromZYX(image);
} }
@ -134,7 +134,7 @@ namespace ImageSharp.Tests
[Fact] [Fact]
public void CopyFromZYXW() public void CopyFromZYXW()
{ {
using (Image<Color> image = new Image<Color>(1, 1)) using (Image<Rgba32> image = new Image<Rgba32>(1, 1))
{ {
CopyFromZYXW(image); CopyFromZYXW(image);
} }
@ -143,7 +143,7 @@ namespace ImageSharp.Tests
[Fact] [Fact]
public void CopyToZYX() public void CopyToZYX()
{ {
using (Image<Color> image = new Image<Color>(1, 1)) using (Image<Rgba32> image = new Image<Rgba32>(1, 1))
{ {
CopyToZYX(image); CopyToZYX(image);
} }
@ -152,7 +152,7 @@ namespace ImageSharp.Tests
[Fact] [Fact]
public void CopyToZYXW() public void CopyToZYXW()
{ {
using (Image<Color> image = new Image<Color>(1, 1)) using (Image<Rgba32> image = new Image<Rgba32>(1, 1))
{ {
CopyToZYXW(image); CopyToZYXW(image);
} }
@ -176,7 +176,7 @@ namespace ImageSharp.Tests
pixels.CopyFrom(row, 0); pixels.CopyFrom(row, 0);
Color color = (Color)(object)pixels[0, 0]; Rgba32 color = (Rgba32)(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);
Color color = (Color)(object)pixels[0, 0]; Rgba32 color = (Rgba32)(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 Color(red, green, blue); pixels[0, 0] = (TColor)(object)new Rgba32(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 Color(red, green, blue, alpha); pixels[0, 0] = (TColor)(object)new Rgba32(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<Color> thumbnail = profile.CreateThumbnail<Color>(); Image<Rgba32> thumbnail = profile.CreateThumbnail<Rgba32>();
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(Color.HotPink).Save(output); image.BackgroundColor(Rgba32.HotPink).Save(output);
} }
} }
} }

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save