From d7a38d4ed79920d2ee62e4166e8e93a47d0d84d0 Mon Sep 17 00:00:00 2001 From: routersys Date: Sun, 11 Oct 2026 21:21:29 +0900 Subject: [PATCH] =?UTF-8?q?=E9=9D=9E=E6=95=B0=E3=81=A8=E7=84=A1=E9=99=90?= =?UTF-8?q?=E5=A4=A7=E3=81=AE=E5=85=A5=E5=8A=9B=E3=81=AE=E6=A4=9C=E6=9F=BB?= =?UTF-8?q?=E3=82=921=E3=81=A4=E3=81=AB=E3=81=BE=E3=81=A8=E3=82=81?= =?UTF-8?q?=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SpectrumColorShift/SpectrumColorShiftCustomEffect.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/SpectrumColorShift/SpectrumColorShiftCustomEffect.cs b/SpectrumColorShift/SpectrumColorShiftCustomEffect.cs index cdc3a8b..4aaf381 100644 --- a/SpectrumColorShift/SpectrumColorShiftCustomEffect.cs +++ b/SpectrumColorShift/SpectrumColorShiftCustomEffect.cs @@ -50,7 +50,7 @@ namespace SpectrumColorShift get => _cb.Distance; set { - _cb.Distance = float.IsFinite(value) ? Math.Clamp(value, -MaxInputPixel, MaxInputPixel) : 0f; + _cb.Distance = Sanitize(value, -MaxInputPixel, MaxInputPixel); UpdateConstants(); } } @@ -85,7 +85,7 @@ namespace SpectrumColorShift get => _centerOffset.X; set { - _centerOffset.X = float.IsFinite(value) ? Math.Clamp(value, -MaxInputPixel, MaxInputPixel) : 0f; + _centerOffset.X = Sanitize(value, -MaxInputPixel, MaxInputPixel); RefreshGeometry(); UpdateConstants(); } @@ -97,7 +97,7 @@ namespace SpectrumColorShift get => _centerOffset.Y; set { - _centerOffset.Y = float.IsFinite(value) ? Math.Clamp(value, -MaxInputPixel, MaxInputPixel) : 0f; + _centerOffset.Y = Sanitize(value, -MaxInputPixel, MaxInputPixel); RefreshGeometry(); UpdateConstants(); } @@ -109,7 +109,7 @@ namespace SpectrumColorShift get => _cb.Strength; set { - _cb.Strength = float.IsFinite(value) ? Math.Clamp(value, 0f, 1f) : 0f; + _cb.Strength = Sanitize(value, 0f, 1f); UpdateConstants(); } } @@ -221,6 +221,9 @@ namespace SpectrumColorShift public override RawRect MapInvalidRect(int inputIndex, RawRect invalidInputRect) => ShiftGeometry.Output(invalidInputRect, _mode, _cb.Distance, _cb.Direction, _cb.Center, _cb.Radius); + private static float Sanitize(float value, float minimum, float maximum) + => float.IsNaN(value) ? 0f : Math.Clamp(value, minimum, maximum); + private void RefreshGeometry() { if (inputRect.Right <= inputRect.Left || inputRect.Bottom <= inputRect.Top)