public void Convert_Luv_to_XYZ(double l, double u, double v, double x, double y, double z)
        {
            // arrange
            var input = new LuvColor(l, u, v, Illuminants.D65);
            var converter = new ColourfulConverter { WhitePoint = Illuminants.D65, TargetLuvWhitePoint = 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 void Convert_XYZ_to_Luv(double x, double y, double z, double l, double u, double v)
        {
            // arrange
            var input = new XYZColor(x, y, z);
            var converter = new ColourfulConverter { WhitePoint = Illuminants.D65, TargetLuvWhitePoint = Illuminants.D65 };

            // act
            LuvColor output = converter.ToLuv(input);

            // assert
            Assert.That(output.L, Is.EqualTo(l).Using(DoubleComparerLuvPrecision));
            Assert.That(output.u, Is.EqualTo(u).Using(DoubleComparerLuvPrecision));
            Assert.That(output.v, Is.EqualTo(v).Using(DoubleComparerLuvPrecision));
        }
        public void Convert_xyY_to_XYZ(double xyzX, double xyzY, double xyzZ, double x, double y, double Y)
        {
            // arrange
            var input = new xyYColor(x, y, Y);
            var converter = new ColourfulConverter();

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

            // assert
            Assert.That(output.X, Is.EqualTo(xyzX).Using(DoubleComparer));
            Assert.That(output.Y, Is.EqualTo(xyzY).Using(DoubleComparer));
            Assert.That(output.Z, Is.EqualTo(xyzZ).Using(DoubleComparer));
        }
        public void Convert_XYZ_to_xyY(double xyzX, double xyzY, double xyzZ, double x, double y, double Y)
        {
            // arrange
            var input = new XYZColor(xyzX, xyzY, xyzZ);
            var converter = new ColourfulConverter();

            // act
            xyYColor output = converter.ToxyY(input);

            // assert
            Assert.That(output.x, Is.EqualTo(x).Using(DoubleComparer));
            Assert.That(output.y, Is.EqualTo(y).Using(DoubleComparer));
            Assert.That(output.Luminance, Is.EqualTo(Y).Using(DoubleComparer));
        }
        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 void Convert_sRGB_to_XYZ_D65(double r, double g, double b, double x, double y, double z)
        {
            // arrange
            var input = new RGBColor(r, g, b);
            var converter = new ColourfulConverter { WhitePoint = Illuminants.D65 };

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

            // assert
            Assert.That(output.X, Is.EqualTo(x).Using(DoubleComparer));
            Assert.That(output.Y, Is.EqualTo(y).Using(DoubleComparer));
            Assert.That(output.Z, Is.EqualTo(z).Using(DoubleComparer));
        }
        public void Convert_XYZ_to_Lab(double x, double y, double z, double l, double a, double b)
        {
            // arrange
            var input = new XYZColor(x, y, z);
            var converter = new ColourfulConverter { WhitePoint = Illuminants.D65, TargetLabWhitePoint = Illuminants.D65 };

            // act
            LabColor output = converter.ToLab(input);

            // assert
            Assert.That(output.L, Is.EqualTo(l).Using(DoubleComparerLabPrecision));
            Assert.That(output.a, Is.EqualTo(a).Using(DoubleComparerLabPrecision));
            Assert.That(output.b, Is.EqualTo(b).Using(DoubleComparerLabPrecision));
        }
        public void Adapt_LChab_D50_To_D65(double l1, double c1, double h1, double l2, double c2, double h2)
        {
            // arrange
            var input = new LChabColor(l1, c1, h1, Illuminants.D50);
            var expectedOutput = new LChabColor(l2, c2, h2);
            var converter = new ColourfulConverter { TargetLabWhitePoint = Illuminants.D65 };

            // action
            LChabColor output = converter.Adapt(input);

            // assert
            Assert.That(output.L, Is.EqualTo(expectedOutput.L).Using(DoubleRoundingComparer));
            Assert.That(output.C, Is.EqualTo(expectedOutput.C).Using(DoubleRoundingComparer));
            Assert.That(output.h, Is.EqualTo(expectedOutput.h).Using(DoubleRoundingComparer));
        }
        public void Adapt_Lab_D65_To_D50(double l1, double a1, double b1, double l2, double a2, double b2)
        {
            // arrange
            var input = new LabColor(l1, a1, b1, Illuminants.D65);
            var expectedOutput = new LabColor(l2, a2, b2);
            var converter = new ColourfulConverter { TargetLabWhitePoint = Illuminants.D50 };

            // action
            LabColor output = converter.Adapt(input);

            // assert
            Assert.That(output.L, Is.EqualTo(expectedOutput.L).Using(DoublePrecisionComparer));
            Assert.That(output.a, Is.EqualTo(expectedOutput.a).Using(DoublePrecisionComparer));
            Assert.That(output.b, Is.EqualTo(expectedOutput.b).Using(DoublePrecisionComparer));
        }
        public void Adapt_RGB_sRGB_To_WideGamutRGB(double r1, double g1, double b1, double r2, double g2, double b2)
        {
            // arrange
            var input = new RGBColor(r1, g1, b1, RGBWorkingSpaces.sRGB);
            var expectedOutput = new RGBColor(r2, g2, b2, RGBWorkingSpaces.WideGamutRGB);
            var converter = new ColourfulConverter { TargetRGBWorkingSpace = RGBWorkingSpaces.WideGamutRGB };

            // action
            RGBColor output = converter.Adapt(input);

            // assert
            Assert.AreEqual(expectedOutput.WorkingSpace, output.WorkingSpace);
            Assert.That(output.R, Is.EqualTo(expectedOutput.R).Using(DoubleRoundingComparer));
            Assert.That(output.G, Is.EqualTo(expectedOutput.G).Using(DoubleRoundingComparer));
            Assert.That(output.B, Is.EqualTo(expectedOutput.B).Using(DoubleRoundingComparer));
        }
        public void Adapt_XYZ_D65_To_D50_XYZScaling(double x1, double y1, double z1, double x2, double y2, double z2)
        {
            // arrange
            var input = new XYZColor(x1, y1, z1);
            var expectedOutput = new XYZColor(x2, y2, z2);
            var converter = new ColourfulConverter
                {
                    ChromaticAdaptation = new VonKriesChromaticAdaptation(LMSTransformationMatrix.XYZScaling),
                    WhitePoint = Illuminants.D50
                };

            // action
            XYZColor output = converter.Adapt(input, Illuminants.D65);

            // assert
            Assert.That(output.X, Is.EqualTo(expectedOutput.X).Using(DoubleRoundingComparer));
            Assert.That(output.Y, Is.EqualTo(expectedOutput.Y).Using(DoubleRoundingComparer));
            Assert.That(output.Z, Is.EqualTo(expectedOutput.Z).Using(DoubleRoundingComparer));
        }
        public void Adapt_XYZ_D65_To_D50_Bradford(double x1, double y1, double z1, double x2, double y2, double z2)
        {
            // arrange
            var input = new XYZColor(x1, y1, z1);
            var expectedOutput = new XYZColor(x2, y2, z2);
            var converter = new ColourfulConverter
                {
                    WhitePoint = Illuminants.D50
                };

            // action
            XYZColor output = converter.Adapt(input, Illuminants.D65);

            // assert
            Assert.That(output.X, Is.EqualTo(expectedOutput.X).Using(DoubleRoundingComparer));
            Assert.That(output.Y, Is.EqualTo(expectedOutput.Y).Using(DoubleRoundingComparer));
            Assert.That(output.Z, Is.EqualTo(expectedOutput.Z).Using(DoubleRoundingComparer));
        }
        public void Convert_XYZ_as_vector_to_XYZ(double x, double y, double z)
        {
            // arrange
            IColorVector input = new XYZColor(x, y, z);

            var converter = new ColourfulConverter();

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

            // assert
            Assert.That(output.X, Is.EqualTo(x).Using(DoubleComparer));
            Assert.That(output.Y, Is.EqualTo(y).Using(DoubleComparer));
            Assert.That(output.Z, Is.EqualTo(z).Using(DoubleComparer));
        }
        public void Convert_XYZ_D65_to_sRGB(double x, double y, double z, double r, double g, double b)
        {
            // arange
            var input = new XYZColor(x, y, z);
            var converter = new ColourfulConverter { WhitePoint = Illuminants.D65, TargetRGBWorkingSpace = RGBWorkingSpaces.sRGB };

            // act
            RGBColor output = converter.ToRGB(input);

            // assert
            Assert.That(output.WorkingSpace, Is.EqualTo(RGBColor.DefaultWorkingSpace));
            Assert.That(output.R, Is.EqualTo(r).Using(DoubleComparer));
            Assert.That(output.G, Is.EqualTo(g).Using(DoubleComparer));
            Assert.That(output.B, Is.EqualTo(b).Using(DoubleComparer));
        }