From decff28ece6dfd0e5c5ff1187ff2fe434576fab0 Mon Sep 17 00:00:00 2001 From: routersys Date: Fri, 23 Oct 2026 20:00:33 +0900 Subject: [PATCH] =?UTF-8?q?=E7=92=B0=E3=81=AE=E8=89=B2=E3=81=8C=E5=A4=AA?= =?UTF-8?q?=E9=99=BD=E3=81=AE=E8=89=B2=E3=81=A7=E7=99=BD=E3=81=8F=E4=BF=9D?= =?UTF-8?q?=E3=81=9F=E3=82=8C=E3=82=8B=E8=A9=A6=E9=A8=93=E3=82=92=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Halo.Tests/HaloTableTests.cs | 17 +++++++++++++++++ Halo/HaloTable.cs | 4 +++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/Halo.Tests/HaloTableTests.cs b/Halo.Tests/HaloTableTests.cs index 5aed851..a486f6e 100644 --- a/Halo.Tests/HaloTableTests.cs +++ b/Halo.Tests/HaloTableTests.cs @@ -178,6 +178,23 @@ public sealed class HaloTableTests Assert.True(HaloTable.ComposeRing(-1.0, 1.0, 1.0).AsSpan().SequenceEqual(HaloTable.ComposeRing(0.0, 1.0, 1.0))); } + [Fact] + public void ALightColoredLikeTheSunStaysWhiteInTheRingColors() + { + var white = SolarSpectrum.White; + var profile = new double[HaloSettings.RingTableWidth * HaloSettings.ColorChannels]; + for (var index = 0; index < HaloSettings.RingTableWidth; index++) + { + profile[index * HaloSettings.ColorChannels] = 2.0 * white.X; + profile[index * HaloSettings.ColorChannels + 1] = 2.0 * white.Y; + profile[index * HaloSettings.ColorChannels + 2] = 2.0 * white.Z; + } + + var colors = HaloTable.RingColors(1.0, profile); + + Assert.All(Enumerable.Range(0, colors.Length), index => Assert.Equal(2.0, colors[index], 1e-9)); + } + [Fact] public void TheRingTableIsTheSameForTheSameInput() { diff --git a/Halo/HaloTable.cs b/Halo/HaloTable.cs index 4f52c6f..9e43f8b 100644 --- a/Halo/HaloTable.cs +++ b/Halo/HaloTable.cs @@ -57,10 +57,12 @@ internal static class HaloTable } private static double[] RingColors(double sunDiameterDegrees) + => RingColors(sunDiameterDegrees, RingProfile.Radiance); + + public static double[] RingColors(double sunDiameterDegrees, double[] profile) { var width = HaloSettings.RingTableWidth; var channels = HaloSettings.ColorChannels; - var profile = RingProfile.Radiance; var kernel = SunKernel(sunDiameterDegrees); var half = kernel.Length / 2; var (whiteRed, whiteGreen, whiteBlue) = SolarSpectrum.ToLinearSrgb(SolarSpectrum.White);