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);