From 0cdcf11fbe94f282841da98871e742839731bf18 Mon Sep 17 00:00:00 2001 From: routersys Date: Thu, 24 Sep 2026 10:41:22 +0900 Subject: [PATCH] =?UTF-8?q?=E5=88=B0=E9=81=94=E8=B7=9D=E9=9B=A2=E3=81=8C?= =?UTF-8?q?=E9=95=B7=E8=BE=BA=E3=82=92=E5=9F=BA=E6=BA=96=E3=81=AB=E3=81=99?= =?UTF-8?q?=E3=82=8B=E8=A9=A6=E9=A8=93=E3=82=92=E8=BF=BD=E5=8A=A0=E3=81=99?= =?UTF-8?q?=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../InkDispersionEffectProcessorTests.cs | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/InkDispersion.Tests/InkDispersionEffectProcessorTests.cs b/InkDispersion.Tests/InkDispersionEffectProcessorTests.cs index 695f6ba..444b104 100644 --- a/InkDispersion.Tests/InkDispersionEffectProcessorTests.cs +++ b/InkDispersion.Tests/InkDispersionEffectProcessorTests.cs @@ -48,6 +48,13 @@ public sealed class InkDispersionEffectProcessorTests static bool Tinted(byte channel, byte alpha, byte color) => Math.Abs(channel - color * alpha / 255d) <= 2d; + static double DistanceFrom(SourceImage source, int x, int y) + { + var dx = Math.Max(Math.Max(-x, x - (source.Width - 1)), 0); + var dy = Math.Max(Math.Max(-y, y - (source.Height - 1)), 0); + return Math.Sqrt(dx * dx + dy * dy); + } + [Fact] public void TheProcessorHandsTheDrawDescriptionBackUnchanged() { @@ -134,6 +141,29 @@ public sealed class InkDispersionEffectProcessorTests Assert.All(inPlace.Coordinates(), point => Assert.True(inPlace[point.X, point.Y] == travelled[point.X + dx, point.Y + dy], $"({point.X}, {point.Y})")); } + [Fact] + public void TheReachIsMeasuredAgainstTheLongSideOfTheImage() + { + using var devices = new GraphicsDevices(); + using var context = devices.CreateContext(); + RequireInterop(context); + using var source = SourceImage.Solid(context, 96, 24, Gray); + var effect = new InkDispersionEffect(); + effect.Water.Values[0].Value = 100d; + effect.Reach.Values[0].Value = 25d; + using var processor = effect.CreateVideoEffect(context); + processor.SetInput(source.Bitmap); + + var rendering = RenderFrame(context, processor, 0); + + var distances = rendering.Coordinates() + .Where(point => !source.Contains(point.X, point.Y) && rendering[point.X, point.Y].Alpha > 0) + .Select(point => DistanceFrom(source, point.X, point.Y)) + .ToArray(); + Assert.Contains(distances, distance => distance > 12d); + Assert.All(distances, distance => Assert.True(distance <= 30d, $"{distance}")); + } + public static readonly TheoryData> PassThroughSettings = new() { { nameof(InkDispersionEffect.Amount), effect => effect.Amount.Values[0].Value = 0d },