|
|
@ -2,24 +2,24 @@ |
|
|
// Licensed under the Apache License, Version 2.0.
|
|
|
// Licensed under the Apache License, Version 2.0.
|
|
|
|
|
|
|
|
|
using System.Numerics; |
|
|
using System.Numerics; |
|
|
|
|
|
|
|
|
using SixLabors.ImageSharp.PixelFormats; |
|
|
using SixLabors.ImageSharp.PixelFormats; |
|
|
|
|
|
using SixLabors.ImageSharp.Processing; |
|
|
using SixLabors.ImageSharp.Processing.Drawing; |
|
|
using SixLabors.ImageSharp.Processing.Drawing; |
|
|
using SixLabors.ImageSharp.Processing.Drawing.Pens; |
|
|
using SixLabors.ImageSharp.Processing.Drawing.Pens; |
|
|
|
|
|
using SixLabors.ImageSharp.Processing.Overlays; |
|
|
|
|
|
|
|
|
using Xunit; |
|
|
using Xunit; |
|
|
|
|
|
|
|
|
namespace SixLabors.ImageSharp.Tests.Drawing |
|
|
namespace SixLabors.ImageSharp.Tests.Drawing |
|
|
{ |
|
|
{ |
|
|
using SixLabors.ImageSharp.Processing; |
|
|
|
|
|
using SixLabors.ImageSharp.Processing.Overlays; |
|
|
|
|
|
|
|
|
|
|
|
public class LineTests : FileTestBase |
|
|
public class LineTests : FileTestBase |
|
|
{ |
|
|
{ |
|
|
[Fact] |
|
|
[Fact] |
|
|
public void ImageShouldBeOverlayedByPath() |
|
|
public void ImageShouldBeOverlayedByPath() |
|
|
{ |
|
|
{ |
|
|
string path = TestEnvironment.CreateOutputDirectory("Drawing", "Lines"); |
|
|
string path = TestEnvironment.CreateOutputDirectory("Drawing", "Lines"); |
|
|
using (Image<Rgba32> image = new Image<Rgba32>(500, 500)) |
|
|
using (var image = new Image<Rgba32>(500, 500)) |
|
|
{ |
|
|
{ |
|
|
image.Mutate(x => x |
|
|
image.Mutate(x => x |
|
|
.BackgroundColor(Rgba32.Blue) |
|
|
.BackgroundColor(Rgba32.Blue) |
|
|
@ -46,7 +46,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing |
|
|
public void ImageShouldBeOverlayedByPath_NoAntialias() |
|
|
public void ImageShouldBeOverlayedByPath_NoAntialias() |
|
|
{ |
|
|
{ |
|
|
string path = TestEnvironment.CreateOutputDirectory("Drawing", "Lines"); |
|
|
string path = TestEnvironment.CreateOutputDirectory("Drawing", "Lines"); |
|
|
using (Image<Rgba32> image = new Image<Rgba32>(500, 500)) |
|
|
using (var image = new Image<Rgba32>(500, 500)) |
|
|
{ |
|
|
{ |
|
|
image.Mutate(x => x |
|
|
image.Mutate(x => x |
|
|
.BackgroundColor(Rgba32.Blue) |
|
|
.BackgroundColor(Rgba32.Blue) |
|
|
@ -76,7 +76,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing |
|
|
public void ImageShouldBeOverlayedByPathDashed() |
|
|
public void ImageShouldBeOverlayedByPathDashed() |
|
|
{ |
|
|
{ |
|
|
string path = TestEnvironment.CreateOutputDirectory("Drawing", "Lines"); |
|
|
string path = TestEnvironment.CreateOutputDirectory("Drawing", "Lines"); |
|
|
using (Image<Rgba32> image = new Image<Rgba32>(500, 500)) |
|
|
using (var image = new Image<Rgba32>(500, 500)) |
|
|
{ |
|
|
{ |
|
|
image.Mutate(x => x |
|
|
image.Mutate(x => x |
|
|
.BackgroundColor(Rgba32.Blue) |
|
|
.BackgroundColor(Rgba32.Blue) |
|
|
@ -94,7 +94,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing |
|
|
public void ImageShouldBeOverlayedByPathDotted() |
|
|
public void ImageShouldBeOverlayedByPathDotted() |
|
|
{ |
|
|
{ |
|
|
string path = TestEnvironment.CreateOutputDirectory("Drawing", "Lines"); |
|
|
string path = TestEnvironment.CreateOutputDirectory("Drawing", "Lines"); |
|
|
using (Image<Rgba32> image = new Image<Rgba32>(500, 500)) |
|
|
using (var image = new Image<Rgba32>(500, 500)) |
|
|
{ |
|
|
{ |
|
|
image.Mutate(x => x |
|
|
image.Mutate(x => x |
|
|
.BackgroundColor(Rgba32.Blue) |
|
|
.BackgroundColor(Rgba32.Blue) |
|
|
@ -112,7 +112,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing |
|
|
public void ImageShouldBeOverlayedByPathDashDot() |
|
|
public void ImageShouldBeOverlayedByPathDashDot() |
|
|
{ |
|
|
{ |
|
|
string path = TestEnvironment.CreateOutputDirectory("Drawing", "Lines"); |
|
|
string path = TestEnvironment.CreateOutputDirectory("Drawing", "Lines"); |
|
|
using (Image<Rgba32> image = new Image<Rgba32>(500, 500)) |
|
|
using (var image = new Image<Rgba32>(500, 500)) |
|
|
{ |
|
|
{ |
|
|
image.Mutate(x => x |
|
|
image.Mutate(x => x |
|
|
.BackgroundColor(Rgba32.Blue) |
|
|
.BackgroundColor(Rgba32.Blue) |
|
|
@ -130,7 +130,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing |
|
|
public void ImageShouldBeOverlayedByPathDashDotDot() |
|
|
public void ImageShouldBeOverlayedByPathDashDotDot() |
|
|
{ |
|
|
{ |
|
|
string path = TestEnvironment.CreateOutputDirectory("Drawing", "Lines"); |
|
|
string path = TestEnvironment.CreateOutputDirectory("Drawing", "Lines"); |
|
|
Image<Rgba32> image = new Image<Rgba32>(500, 500); |
|
|
var image = new Image<Rgba32>(500, 500); |
|
|
|
|
|
|
|
|
image.Mutate(x => x |
|
|
image.Mutate(x => x |
|
|
.BackgroundColor(Rgba32.Blue) |
|
|
.BackgroundColor(Rgba32.Blue) |
|
|
@ -147,9 +147,9 @@ namespace SixLabors.ImageSharp.Tests.Drawing |
|
|
{ |
|
|
{ |
|
|
string path = TestEnvironment.CreateOutputDirectory("Drawing", "Lines"); |
|
|
string path = TestEnvironment.CreateOutputDirectory("Drawing", "Lines"); |
|
|
|
|
|
|
|
|
Rgba32 color = new Rgba32(Rgba32.HotPink.R, Rgba32.HotPink.G, Rgba32.HotPink.B, 150); |
|
|
var color = new Rgba32(Rgba32.HotPink.R, Rgba32.HotPink.G, Rgba32.HotPink.B, 150); |
|
|
|
|
|
|
|
|
Image<Rgba32> image = new Image<Rgba32>(500, 500); |
|
|
var image = new Image<Rgba32>(500, 500); |
|
|
|
|
|
|
|
|
image.Mutate(x => x |
|
|
image.Mutate(x => x |
|
|
.BackgroundColor(Rgba32.Blue) |
|
|
.BackgroundColor(Rgba32.Blue) |
|
|
@ -161,7 +161,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing |
|
|
image.Save($"{path}/Opacity.png"); |
|
|
image.Save($"{path}/Opacity.png"); |
|
|
|
|
|
|
|
|
//shift background color towards forground color by the opacity amount
|
|
|
//shift background color towards forground color by the opacity amount
|
|
|
Rgba32 mergedColor = new Rgba32(Vector4.Lerp(Rgba32.Blue.ToVector4(), Rgba32.HotPink.ToVector4(), 150f / 255f)); |
|
|
var mergedColor = new Rgba32(Vector4.Lerp(Rgba32.Blue.ToVector4(), Rgba32.HotPink.ToVector4(), 150f / 255f)); |
|
|
|
|
|
|
|
|
using (PixelAccessor<Rgba32> sourcePixels = image.Lock()) |
|
|
using (PixelAccessor<Rgba32> sourcePixels = image.Lock()) |
|
|
{ |
|
|
{ |
|
|
@ -178,7 +178,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing |
|
|
{ |
|
|
{ |
|
|
string path = TestEnvironment.CreateOutputDirectory("Drawing", "Lines"); |
|
|
string path = TestEnvironment.CreateOutputDirectory("Drawing", "Lines"); |
|
|
|
|
|
|
|
|
Image<Rgba32> image = new Image<Rgba32>(500, 500); |
|
|
var image = new Image<Rgba32>(500, 500); |
|
|
|
|
|
|
|
|
image.Mutate(x => x |
|
|
image.Mutate(x => x |
|
|
.BackgroundColor(Rgba32.Blue) |
|
|
.BackgroundColor(Rgba32.Blue) |
|
|
|