|
|
|
@ -29,14 +29,14 @@ namespace SixLabors.ImageSharp.Tests.Drawing |
|
|
|
{ |
|
|
|
using (Image<TPixel> image = provider.GetImage()) |
|
|
|
{ |
|
|
|
TPixel red = NamedColors<TPixel>.Red; |
|
|
|
Color red = Color.Red; |
|
|
|
|
|
|
|
var unicolorLinearGradientBrush = new LinearGradientBrush<TPixel>( |
|
|
|
var unicolorLinearGradientBrush = new LinearGradientBrush( |
|
|
|
new SixLabors.Primitives.Point(0, 0), |
|
|
|
new SixLabors.Primitives.Point(10, 0), |
|
|
|
GradientRepetitionMode.None, |
|
|
|
new ColorStop<TPixel>(0, red), |
|
|
|
new ColorStop<TPixel>(1, red)); |
|
|
|
new ColorStop(0, red), |
|
|
|
new ColorStop(1, red)); |
|
|
|
|
|
|
|
image.Mutate(x => x.Fill(unicolorLinearGradientBrush)); |
|
|
|
|
|
|
|
@ -58,12 +58,12 @@ namespace SixLabors.ImageSharp.Tests.Drawing |
|
|
|
TolerantComparer, |
|
|
|
image => |
|
|
|
{ |
|
|
|
var unicolorLinearGradientBrush = new LinearGradientBrush<TPixel>( |
|
|
|
var unicolorLinearGradientBrush = new LinearGradientBrush( |
|
|
|
new SixLabors.Primitives.Point(0, 0), |
|
|
|
new SixLabors.Primitives.Point(image.Width, 0), |
|
|
|
GradientRepetitionMode.None, |
|
|
|
new ColorStop<TPixel>(0, NamedColors<TPixel>.Blue), |
|
|
|
new ColorStop<TPixel>(1, NamedColors<TPixel>.Yellow)); |
|
|
|
new ColorStop(0, Color.Blue), |
|
|
|
new ColorStop(1, Color.Yellow)); |
|
|
|
|
|
|
|
image.Mutate(x => x.Fill(unicolorLinearGradientBrush)); |
|
|
|
}, |
|
|
|
@ -79,15 +79,15 @@ namespace SixLabors.ImageSharp.Tests.Drawing |
|
|
|
TolerantComparer, |
|
|
|
image => |
|
|
|
{ |
|
|
|
TPixel red = NamedColors<TPixel>.Red; |
|
|
|
TPixel yellow = NamedColors<TPixel>.Yellow; |
|
|
|
Color red = Color.Red; |
|
|
|
Color yellow = Color.Yellow; |
|
|
|
|
|
|
|
var unicolorLinearGradientBrush = new LinearGradientBrush<TPixel>( |
|
|
|
var unicolorLinearGradientBrush = new LinearGradientBrush( |
|
|
|
new SixLabors.Primitives.Point(0, 0), |
|
|
|
new SixLabors.Primitives.Point(image.Width, 0), |
|
|
|
GradientRepetitionMode.None, |
|
|
|
new ColorStop<TPixel>(0, red), |
|
|
|
new ColorStop<TPixel>(1, yellow)); |
|
|
|
new ColorStop(0, red), |
|
|
|
new ColorStop(1, yellow)); |
|
|
|
|
|
|
|
image.Mutate(x => x.Fill(unicolorLinearGradientBrush)); |
|
|
|
}, |
|
|
|
@ -109,15 +109,15 @@ namespace SixLabors.ImageSharp.Tests.Drawing |
|
|
|
TolerantComparer, |
|
|
|
image => |
|
|
|
{ |
|
|
|
TPixel red = NamedColors<TPixel>.Red; |
|
|
|
TPixel yellow = NamedColors<TPixel>.Yellow; |
|
|
|
Color red = Color.Red; |
|
|
|
Color yellow = Color.Yellow; |
|
|
|
|
|
|
|
var unicolorLinearGradientBrush = new LinearGradientBrush<TPixel>( |
|
|
|
var unicolorLinearGradientBrush = new LinearGradientBrush( |
|
|
|
new SixLabors.Primitives.Point(0, 0), |
|
|
|
new SixLabors.Primitives.Point(image.Width / 10, 0), |
|
|
|
repetitionMode, |
|
|
|
new ColorStop<TPixel>(0, red), |
|
|
|
new ColorStop<TPixel>(1, yellow)); |
|
|
|
new ColorStop(0, red), |
|
|
|
new ColorStop(1, yellow)); |
|
|
|
|
|
|
|
image.Mutate(x => x.Fill(unicolorLinearGradientBrush)); |
|
|
|
}, |
|
|
|
@ -140,26 +140,26 @@ namespace SixLabors.ImageSharp.Tests.Drawing |
|
|
|
// ensure the input data is valid
|
|
|
|
Assert.True(pattern.Length > 0); |
|
|
|
|
|
|
|
TPixel black = NamedColors<TPixel>.Black; |
|
|
|
TPixel white = NamedColors<TPixel>.White; |
|
|
|
Color black = Color.Black; |
|
|
|
Color white = Color.White; |
|
|
|
|
|
|
|
// create the input pattern: 0, followed by each of the arguments twice, followed by 1.0 - toggling black and white.
|
|
|
|
ColorStop<TPixel>[] colorStops = |
|
|
|
Enumerable.Repeat(new ColorStop<TPixel>(0, black), 1) |
|
|
|
ColorStop[] colorStops = |
|
|
|
Enumerable.Repeat(new ColorStop(0, black), 1) |
|
|
|
.Concat( |
|
|
|
pattern |
|
|
|
.SelectMany((f, index) => new[] |
|
|
|
{ |
|
|
|
new ColorStop<TPixel>(f, index % 2 == 0 ? black : white), |
|
|
|
new ColorStop<TPixel>(f, index % 2 == 0 ? white : black) |
|
|
|
new ColorStop(f, index % 2 == 0 ? black : white), |
|
|
|
new ColorStop(f, index % 2 == 0 ? white : black) |
|
|
|
})) |
|
|
|
.Concat(Enumerable.Repeat(new ColorStop<TPixel>(1, pattern.Length % 2 == 0 ? black : white), 1)) |
|
|
|
.Concat(Enumerable.Repeat(new ColorStop(1, pattern.Length % 2 == 0 ? black : white), 1)) |
|
|
|
.ToArray(); |
|
|
|
|
|
|
|
using (Image<TPixel> image = provider.GetImage()) |
|
|
|
{ |
|
|
|
var unicolorLinearGradientBrush = |
|
|
|
new LinearGradientBrush<TPixel>( |
|
|
|
new LinearGradientBrush( |
|
|
|
new SixLabors.Primitives.Point(0, 0), |
|
|
|
new SixLabors.Primitives.Point(image.Width, 0), |
|
|
|
GradientRepetitionMode.None, |
|
|
|
@ -196,15 +196,15 @@ namespace SixLabors.ImageSharp.Tests.Drawing |
|
|
|
provider.VerifyOperation( |
|
|
|
image => |
|
|
|
{ |
|
|
|
TPixel red = NamedColors<TPixel>.Red; |
|
|
|
TPixel yellow = NamedColors<TPixel>.Yellow; |
|
|
|
Color red = Color.Red; |
|
|
|
Color yellow = Color.Yellow; |
|
|
|
|
|
|
|
var unicolorLinearGradientBrush = new LinearGradientBrush<TPixel>( |
|
|
|
var unicolorLinearGradientBrush = new LinearGradientBrush( |
|
|
|
new SixLabors.Primitives.Point(0, 0), |
|
|
|
new SixLabors.Primitives.Point(0, image.Height), |
|
|
|
GradientRepetitionMode.None, |
|
|
|
new ColorStop<TPixel>(0, red), |
|
|
|
new ColorStop<TPixel>(1, yellow)); |
|
|
|
new ColorStop(0, red), |
|
|
|
new ColorStop(1, yellow)); |
|
|
|
|
|
|
|
image.Mutate(x => x.Fill(unicolorLinearGradientBrush)); |
|
|
|
|
|
|
|
@ -254,16 +254,16 @@ namespace SixLabors.ImageSharp.Tests.Drawing |
|
|
|
int endX = image.Height - startX - 1; |
|
|
|
int endY = image.Width - startY - 1; |
|
|
|
|
|
|
|
TPixel red = NamedColors<TPixel>.Red; |
|
|
|
TPixel yellow = NamedColors<TPixel>.Yellow; |
|
|
|
Color red = Color.Red; |
|
|
|
Color yellow = Color.Yellow; |
|
|
|
|
|
|
|
var unicolorLinearGradientBrush = |
|
|
|
new LinearGradientBrush<TPixel>( |
|
|
|
new LinearGradientBrush( |
|
|
|
new SixLabors.Primitives.Point(startX, startY), |
|
|
|
new SixLabors.Primitives.Point(endX, endY), |
|
|
|
GradientRepetitionMode.None, |
|
|
|
new ColorStop<TPixel>(0, red), |
|
|
|
new ColorStop<TPixel>(1, yellow)); |
|
|
|
new ColorStop(0, red), |
|
|
|
new ColorStop(1, yellow)); |
|
|
|
|
|
|
|
image.Mutate(x => x.Fill(unicolorLinearGradientBrush)); |
|
|
|
image.DebugSave( |
|
|
|
@ -310,22 +310,21 @@ namespace SixLabors.ImageSharp.Tests.Drawing |
|
|
|
int[] stopColorCodes) |
|
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
|
{ |
|
|
|
TPixel[] colors = |
|
|
|
Color[] colors = |
|
|
|
{ |
|
|
|
NamedColors<TPixel>.Navy, NamedColors<TPixel>.LightGreen, NamedColors<TPixel>.Yellow, |
|
|
|
NamedColors<TPixel>.Red |
|
|
|
Color.Navy, Color.LightGreen, Color.Yellow, |
|
|
|
Color.Red |
|
|
|
}; |
|
|
|
|
|
|
|
var coloringVariant = new StringBuilder(); |
|
|
|
var colorStops = new ColorStop<TPixel>[stopPositions.Length]; |
|
|
|
var colorStops = new ColorStop[stopPositions.Length]; |
|
|
|
|
|
|
|
for (int i = 0; i < stopPositions.Length; i++) |
|
|
|
{ |
|
|
|
TPixel color = colors[stopColorCodes[i % colors.Length]]; |
|
|
|
Color color = colors[stopColorCodes[i % colors.Length]]; |
|
|
|
float position = stopPositions[i]; |
|
|
|
colorStops[i] = new ColorStop<TPixel>(position, color); |
|
|
|
Rgba32 rgba = default; |
|
|
|
color.ToRgba32(ref rgba); |
|
|
|
colorStops[i] = new ColorStop(position, color); |
|
|
|
Rgba32 rgba = color; |
|
|
|
coloringVariant.AppendFormat(CultureInfo.InvariantCulture, "{0}@{1};", rgba.ToHex(), position); |
|
|
|
} |
|
|
|
|
|
|
|
@ -334,7 +333,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing |
|
|
|
provider.VerifyOperation( |
|
|
|
image => |
|
|
|
{ |
|
|
|
var unicolorLinearGradientBrush = new LinearGradientBrush<TPixel>( |
|
|
|
var unicolorLinearGradientBrush = new LinearGradientBrush( |
|
|
|
new SixLabors.Primitives.Point(startX, startY), |
|
|
|
new SixLabors.Primitives.Point(endX, endY), |
|
|
|
GradientRepetitionMode.None, |
|
|
|
@ -357,22 +356,21 @@ namespace SixLabors.ImageSharp.Tests.Drawing |
|
|
|
int[] stopColorCodes) |
|
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
|
{ |
|
|
|
TPixel[] colors = |
|
|
|
Color[] colors = |
|
|
|
{ |
|
|
|
NamedColors<TPixel>.Black, NamedColors<TPixel>.Blue, NamedColors<TPixel>.Red, |
|
|
|
NamedColors<TPixel>.White, NamedColors<TPixel>.Lime |
|
|
|
Color.Black, Color.Blue, Color.Red, |
|
|
|
Color.White, Color.Lime |
|
|
|
}; |
|
|
|
|
|
|
|
var coloringVariant = new StringBuilder(); |
|
|
|
var colorStops = new ColorStop<TPixel>[stopPositions.Length]; |
|
|
|
var colorStops = new ColorStop[stopPositions.Length]; |
|
|
|
|
|
|
|
for (int i = 0; i < stopPositions.Length; i++) |
|
|
|
{ |
|
|
|
TPixel color = colors[stopColorCodes[i % colors.Length]]; |
|
|
|
Color color = colors[stopColorCodes[i % colors.Length]]; |
|
|
|
float position = stopPositions[i]; |
|
|
|
colorStops[i] = new ColorStop<TPixel>(position, color); |
|
|
|
Rgba32 rgba = default; |
|
|
|
color.ToRgba32(ref rgba); |
|
|
|
colorStops[i] = new ColorStop(position, color); |
|
|
|
Rgba32 rgba = color; |
|
|
|
coloringVariant.AppendFormat(CultureInfo.InvariantCulture, "{0}@{1};", rgba.ToHex(), position); |
|
|
|
} |
|
|
|
|
|
|
|
@ -381,7 +379,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing |
|
|
|
provider.VerifyOperation( |
|
|
|
image => |
|
|
|
{ |
|
|
|
var unicolorLinearGradientBrush = new LinearGradientBrush<TPixel>( |
|
|
|
var unicolorLinearGradientBrush = new LinearGradientBrush( |
|
|
|
new SixLabors.Primitives.Point(startX, startY), |
|
|
|
new SixLabors.Primitives.Point(endX, endY), |
|
|
|
GradientRepetitionMode.None, |
|
|
|
|