diff --git a/InkDispersion.Tests/InkDispersionEffectProcessorTests.cs b/InkDispersion.Tests/InkDispersionEffectProcessorTests.cs index b6aeb57..695f6ba 100644 --- a/InkDispersion.Tests/InkDispersionEffectProcessorTests.cs +++ b/InkDispersion.Tests/InkDispersionEffectProcessorTests.cs @@ -1,6 +1,9 @@ using System.Globalization; +using System.Numerics; using System.Windows.Media; using ComputeWeave; +using Vortice.Direct2D1; +using Vortice.Direct2D1.Effects; using YukkuriMovieMaker.Commons; using YukkuriMovieMaker.Json; using YukkuriMovieMaker.Player.Video; @@ -102,6 +105,35 @@ public sealed class InkDispersionEffectProcessorTests }); } + [Theory] + [InlineData(100, 50)] + [InlineData(-37, 21)] + public void TheInkTravelsWithTheImage(int dx, int dy) + { + using var devices = new GraphicsDevices(); + using var context = devices.CreateContext(); + RequireInterop(context); + using var source = new SourceImage(context, Size, Size, CenteredSquare); + using var moved = new AffineTransform2D(context.DeviceContext) + { + InterPolationMode = AffineTransform2DInterpolationMode.NearestNeighbor, + BorderMode = BorderMode.Hard, + TransformMatrix = Matrix3x2.CreateTranslation(dx, dy), + }; + moved.SetInput(0, source.Bitmap, true); + using var movedOutput = moved.Output; + using var inPlaceProcessor = new InkDispersionEffect().CreateVideoEffect(context); + inPlaceProcessor.SetInput(source.Bitmap); + var inPlace = RenderFrame(context, inPlaceProcessor, 0); + using var travelledProcessor = new InkDispersionEffect().CreateVideoEffect(context); + travelledProcessor.SetInput(movedOutput); + + var travelled = RenderFrame(context, travelledProcessor, 0); + + Assert.Equal((inPlace.Left + dx, inPlace.Top + dy, inPlace.Width, inPlace.Height), (travelled.Left, travelled.Top, travelled.Width, travelled.Height)); + Assert.All(inPlace.Coordinates(), point => Assert.True(inPlace[point.X, point.Y] == travelled[point.X + dx, point.Y + dy], $"({point.X}, {point.Y})")); + } + public static readonly TheoryData> PassThroughSettings = new() { { nameof(InkDispersionEffect.Amount), effect => effect.Amount.Values[0].Value = 0d },