|
|
@ -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}]"; |
|
|
|