From dd06777c08c5a67b3d15a009d1ca4bc1b491f9c3 Mon Sep 17 00:00:00 2001 From: routersys Date: Thu, 24 Sep 2026 10:41:11 +0900 Subject: [PATCH] =?UTF-8?q?=E3=82=A4=E3=83=B3=E3=82=AF=E3=81=8C=E7=94=BB?= =?UTF-8?q?=E5=83=8F=E3=81=A8=E4=B8=80=E7=B7=92=E3=81=AB=E5=8B=95=E3=81=8F?= =?UTF-8?q?=E8=A9=A6=E9=A8=93=E3=82=92=E8=BF=BD=E5=8A=A0=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../InkDispersionEffectProcessorTests.cs | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) 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 },