From 1e18582f44cd1ccdbd3373c28e402a6396e335b0 Mon Sep 17 00:00:00 2001 From: routersys Date: Thu, 24 Sep 2026 10:41:00 +0900 Subject: [PATCH] =?UTF-8?q?=E3=82=A4=E3=83=B3=E3=82=AF=E3=81=AE=E8=89=B2?= =?UTF-8?q?=E3=81=AE=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 | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/InkDispersion.Tests/InkDispersionEffectProcessorTests.cs b/InkDispersion.Tests/InkDispersionEffectProcessorTests.cs index fb27ccf..b6aeb57 100644 --- a/InkDispersion.Tests/InkDispersionEffectProcessorTests.cs +++ b/InkDispersion.Tests/InkDispersionEffectProcessorTests.cs @@ -43,6 +43,8 @@ public sealed class InkDispersionEffectProcessorTests static bool HasInkOutside(Rendering rendering, SourceImage source) => rendering.Coordinates().Any(point => (!source.Contains(point.X, point.Y) || source[point.X, point.Y].Alpha == 0) && rendering[point.X, point.Y].Alpha > 0); + static bool Tinted(byte channel, byte alpha, byte color) => Math.Abs(channel - color * alpha / 255d) <= 2d; + [Fact] public void TheProcessorHandsTheDrawDescriptionBackUnchanged() { @@ -80,6 +82,26 @@ public sealed class InkDispersionEffectProcessorTests }); } + [Fact] + public void TheInkTakesTheChosenColor() + { + using var devices = new GraphicsDevices(); + using var context = devices.CreateContext(); + RequireInterop(context); + using var source = new SourceImage(context, Size, Size, CenteredSquare); + using var processor = new InkDispersionEffect { InkColor = Color.FromRgb(32, 96, 160) }.CreateVideoEffect(context); + processor.SetInput(source.Bitmap); + + var rendering = RenderFrame(context, processor, 0); + + Assert.True(HasInkOutside(rendering, source)); + Assert.All(rendering.Coordinates().Where(point => !source.Contains(point.X, point.Y) || source[point.X, point.Y].Alpha == 0), point => + { + var pixel = rendering[point.X, point.Y]; + Assert.True(Tinted(pixel.Red, pixel.Alpha, 32) && Tinted(pixel.Green, pixel.Alpha, 96) && Tinted(pixel.Blue, pixel.Alpha, 160), $"({point.X}, {point.Y}) {pixel}"); + }); + } + public static readonly TheoryData> PassThroughSettings = new() { { nameof(InkDispersionEffect.Amount), effect => effect.Amount.Values[0].Value = 0d },