Browse Source

Fix linear gradient brush test.

af/merge-core
James Jackson-South 8 years ago
parent
commit
b7bd7a98ba
  1. 11
      tests/ImageSharp.Tests/Drawing/FillLinearGradientBrushTests.cs
  2. 2
      tests/Images/External

11
tests/ImageSharp.Tests/Drawing/FillLinearGradientBrushTests.cs

@ -283,10 +283,12 @@ namespace SixLabors.ImageSharp.Tests.Drawing
{ {
// it's diagonal, so for any (a, a) on the gradient line, for all (a-x, b+x) - +/- depending on the diagonal direction - must be the same color) // it's diagonal, so for any (a, a) on the gradient line, for all (a-x, b+x) - +/- depending on the diagonal direction - must be the same color)
TPixel colorOnDiagonal = image[i, i]; TPixel colorOnDiagonal = image[i, i];
// TODO: This is incorrect. from -0 to < 0 ??
int orthoCount = 0; int orthoCount = 0;
for (int offset = -orthoCount; offset < orthoCount; offset++) for (int offset = -orthoCount; offset < orthoCount; offset++)
{ {
Assert.Equal(colorOnDiagonal, image[i + horizontalSign * offset, i + verticalSign * offset]); Assert.Equal(colorOnDiagonal, image[i + (horizontalSign * offset), i + (verticalSign * offset)]);
} }
} }
@ -312,20 +314,21 @@ namespace SixLabors.ImageSharp.Tests.Drawing
int[] stopColorCodes) int[] stopColorCodes)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
TPixel[] colors = { TPixel[] colors =
{
NamedColors<TPixel>.Navy, NamedColors<TPixel>.LightGreen, NamedColors<TPixel>.Yellow, NamedColors<TPixel>.Navy, NamedColors<TPixel>.LightGreen, NamedColors<TPixel>.Yellow,
NamedColors<TPixel>.Red NamedColors<TPixel>.Red
}; };
var coloringVariant = new StringBuilder(); var coloringVariant = new StringBuilder();
ColorStop<TPixel>[] colorStops = new ColorStop<TPixel>[stopPositions.Length]; var colorStops = new ColorStop<TPixel>[stopPositions.Length];
for (int i = 0; i < stopPositions.Length; i++) for (int i = 0; i < stopPositions.Length; i++)
{ {
TPixel color = colors[stopColorCodes[i % colors.Length]]; TPixel color = colors[stopColorCodes[i % colors.Length]];
float position = stopPositions[i]; float position = stopPositions[i];
colorStops[i] = new ColorStop<TPixel>(position, color); colorStops[i] = new ColorStop<TPixel>(position, color);
coloringVariant.AppendFormat(CultureInfo.InvariantCulture, "{0}@{1};", color, position); coloringVariant.AppendFormat(CultureInfo.InvariantCulture, "{0}@{1};", color.ToRgba32().ToHex(), position);
} }
FormattableString variant = $"({startX},{startY})_TO_({endX},{endY})__[{coloringVariant}]"; FormattableString variant = $"({startX},{startY})_TO_({endX},{endY})__[{coloringVariant}]";

2
tests/Images/External

@ -1 +1 @@
Subproject commit 03c7fa7582dea75cea0d49514ccb7e1b6dc9e780 Subproject commit 1a807d17b4cf5ab50558983d4137614cabe96ce3
Loading…
Cancel
Save