Пример #1
0
    public void HowToComputeColorFromCCT()
    {
        double         temperature  = 3000; // in K
        xyChromaticity chromaticity = CCTConverter.GetChromaticityOfCCT(temperature);

        // asserts
        Assert.Equal(0.43657898148148144, chromaticity.x, DoubleComparer);
        Assert.Equal(0.4041745241092054, chromaticity.y, DoubleComparer);

        IColorConverter <xyChromaticity, RGBColor> converter = new ConverterBuilder().Fromxy(Illuminants.D65).ToRGB(RGBWorkingSpaces.sRGB).Build();
        RGBColor color = converter.Convert(chromaticity);

        // asserts
        Assert.Equal(1.282323002024544, color.R, DoubleComparer);
        Assert.Equal(0.92870160729369322, color.G, DoubleComparer);
        Assert.Equal(0.55886769485605214, color.B, DoubleComparer);

        color = color.NormalizeIntensity();

        // asserts
        Assert.Equal(1, color.R, DoubleComparer);
        Assert.Equal(0.72423375844264681, color.G, DoubleComparer);
        Assert.Equal(0.4358244326692311, color.B, DoubleComparer);

        color.ToRGB8Bit(out var r, out var g, out var b);

        // asserts
        Assert.Equal(255, r);
        Assert.Equal(185, g);
        Assert.Equal(111, b);
    }
Пример #2
0
        public void ChromaticityFromCCT(double expectedX, double expectedY, double cct)
        {
            // action
            var chromaticity = CCTConverter.GetChromaticityOfCCT(cct);

            // assert
            var deltaComparer = new DoubleDeltaComparer(0.02);

            Assert.Equal(chromaticity.x, expectedX, deltaComparer);
            Assert.Equal(chromaticity.y, expectedY, deltaComparer);
        }
Пример #3
0
        public void ChromaticityFromCCT(double expectedX, double expectedY, double cct)
        {
            // arrange
            var approximation = new CCTConverter();

            // action
            xyChromaticityCoordinates chromaticity = approximation.GetChromaticityOfCCT(cct);

            // assert
            var deltaComparer = new DoubleDeltaComparer(0.02);

            Assert.That(chromaticity.x, Is.EqualTo(expectedX).Using(deltaComparer));
            Assert.That(chromaticity.y, Is.EqualTo(expectedY).Using(deltaComparer));
        }
Пример #4
0
        public void ChromaticityFromCCT(double expectedX, double expectedY, double cct)
        {
            // arrange
            var approximation = new CCTConverter();

            // action
            xyChromaticityCoordinates chromaticity = approximation.GetChromaticityOfCCT(cct);

            // assert
            var deltaComparer = new DoubleDeltaComparer(0.02);
            Assert.That(chromaticity.x, Is.EqualTo(expectedX).Using(deltaComparer));
            Assert.That(chromaticity.y, Is.EqualTo(expectedY).Using(deltaComparer));
        }