public void Convert_HunterLab_to_XYZ_D65(double l, double a, double b, double x, double y, double z)
        {
            // arrange
            var input = new HunterLabColor(l, a, b);
            var converter = new ColourfulConverter { WhitePoint = Illuminants.D65 };

            // act
            XYZColor output = converter.ToXYZ(input);

            // assert
            Assert.That(output.X, Is.EqualTo(x).Using(DoubleComparerXYZPrecision));
            Assert.That(output.Y, Is.EqualTo(y).Using(DoubleComparerXYZPrecision));
            Assert.That(output.Z, Is.EqualTo(z).Using(DoubleComparerXYZPrecision));
        }
        public HunterLabColor ToHunterLab <T>(T color) where T : IColorVector
        {
            if (color == null)
            {
                throw new ArgumentNullException("color");
            }

            HunterLabColor converted = color as HunterLabColor;

            if (converted != null)
            {
                return(converted);
            }
            else
            {
                dynamic source = color;

                return(ToHunterLab(source));
            }
        }
Пример #3
0
        /// <summary>
        /// Adapts Lab color from the source white point to white point set in <see cref="TargetHunterLabWhitePoint"/>.
        /// </summary>
        public HunterLabColor Adapt(HunterLabColor color)
        {
            if (color == null)
            {
                throw new ArgumentNullException("color");
            }

            if (!IsChromaticAdaptationPerformed)
            {
                throw new InvalidOperationException("Cannot perform chromatic adaptation, provide chromatic adaptation method and white point.");
            }

            if (color.WhitePoint.Equals(TargetHunterLabWhitePoint))
            {
                return(color);
            }

            XYZColor       xyzColor = ToXYZ(color);
            HunterLabColor result   = ToHunterLab(xyzColor);

            return(result);
        }
Пример #4
0
 public void HunterLabColor()
 {
     var color = new HunterLabColor(10, 20.5, 45.445);
     Assert.AreEqual("HunterLab [L=10, a=20.5, b=45.45]", color.ToString());
 }
        /// <summary>
        /// Adapts Lab color from the source white point to white point set in <see cref="TargetHunterLabWhitePoint"/>.
        /// </summary>
        public HunterLabColor Adapt(HunterLabColor color)
        {
            if (color == null) throw new ArgumentNullException("color");

            if (!IsChromaticAdaptationPerformed)
                throw new InvalidOperationException("Cannot perform chromatic adaptation, provide chromatic adaptation method and white point.");

            if (color.WhitePoint.Equals(TargetHunterLabWhitePoint))
                return color;

            XYZColor xyzColor = ToXYZ(color);
            HunterLabColor result = ToHunterLab(xyzColor);
            return result;
        }
Пример #6
0
    public void ToString_Simple()
    {
        var color = new HunterLabColor(l: 10, a: 20.5, b: 45.445);

        Assert.Equal("HunterLab [L=10, a=20.5, b=45.45]", color.ToString());
    }
Пример #7
0
        public void HunterLabColor()
        {
            var color = new HunterLabColor(10, 20.5, 45.445);

            Assert.Equal("HunterLab [L=10, a=20.5, b=45.45]", color.ToString());
        }