Exemplo n.º 1
0
    public void Equals_Different()
    {
        var first  = new LChuvColor(l: 11, c: 20.5, h: 45.445);
        var second = new LChuvColor(l: 10, c: 20.5, h: 45.445);

        CustomAssert.NotEqualsWithHashCode(first, second);
    }
Exemplo n.º 2
0
    public void Equals_Same()
    {
        var first  = new LChuvColor(l: 10, c: 20.5, h: 45.445);
        var second = new LChuvColor(l: 10, c: 20.5, h: 45.445);

        CustomAssert.EqualsWithHashCode(first, second);
    }
Exemplo n.º 3
0
        public void LChuvColor()
        {
            var first  = new LChuvColor(10, 20.5, 45.445);
            var second = new LChuvColor(10, 20.5, 45.445);

            Assert.Equal(first, (object)second);
        }
Exemplo n.º 4
0
    public void VectorCtor()
    {
        var first  = new LChuvColor(l: 10, c: 20.5, h: 45.445);
        var vector = new[] { 10, 20.5, 45.445 };
        var second = new LChuvColor(vector);

        CustomAssert.EqualsWithHashCode(first, second);
        Assert.Equal(vector, second.Vector);
    }
Exemplo n.º 5
0
    public void FromSaturationCtor()
    {
        var          first      = new LChuvColor(l: 10, c: 3, h: 20);
        const double saturation = 30d;
        var          second     = LChuvColor.FromSaturation(lightness: 10, hue: 20, saturation);

        CustomAssert.EqualsWithHashCode(first, second);
        Assert.Equal(saturation, second.Saturation);
    }
Exemplo n.º 6
0
    public void Dctor()
    {
        const double l1 = 10;
        const double c1 = 20.5;
        const double h1 = 45.445;

        var(l2, c2, h2) = new LChuvColor(l1, c1, h1);
        Assert.Equal(l1, l2);
        Assert.Equal(c1, c2);
        Assert.Equal(h1, h2);
    }
Exemplo n.º 7
0
    public void LChuvToRgb()
    {
        var inputLChuv      = new LChuvColor(53.04, 143.39, 10.53);
        var rgbWorkingSpace = RGBWorkingSpaces.sRGB;

        var lChuvToRgb = new ConverterBuilder().FromLChuv(rgbWorkingSpace.WhitePoint).ToRGB(rgbWorkingSpace).Build();
        var outputRgb  = lChuvToRgb.Convert(inputLChuv); // RGB [R=0.94, G=0.2, B=0.25]

        Assert.Equal(0.9370059187037388, outputRgb.R);
        Assert.Equal(0.19996423944042457, outputRgb.G);
        Assert.Equal(0.2510189456133648, outputRgb.B);
    }
Exemplo n.º 8
0
        public LinearRGBColor ToLinearRGB(LChuvColor color)
        {
            if (color == null)
            {
                throw new ArgumentNullException("color");
            }

            XYZColor       xyzColor = ToXYZ(color);
            LinearRGBColor result   = ToLinearRGB(xyzColor);

            return(result);
        }
        public HunterLabColor ToHunterLab(LChuvColor color)
        {
            if (color == null)
            {
                throw new ArgumentNullException("color");
            }

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

            return(result);
        }
Exemplo n.º 10
0
        public LChuvColor ToLChuv(XYZColor color)
        {
            if (color == null)
            {
                throw new ArgumentNullException("color");
            }

            LuvColor   luvColor = ToLuv(color);
            LChuvColor result   = ToLChuv(luvColor);

            return(result);
        }
Exemplo n.º 11
0
        public xyYColor ToxyY(LChuvColor color)
        {
            if (color == null)
            {
                throw new ArgumentNullException("color");
            }

            XYZColor xyzColor = ToXYZ(color);
            xyYColor result   = ToxyY(xyzColor);

            return(result);
        }
        public void Convert_LChuv_to_Luv(double l, double c, double h, double l2, double u, double v)
        {
            // arrange
            var input = new LChuvColor(l, c, h);

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

            // assert
            Assert.That(output.L, Is.EqualTo(l2).Using(DoubleComparer));
            Assert.That(output.u, Is.EqualTo(u).Using(DoubleComparer));
            Assert.That(output.v, Is.EqualTo(v).Using(DoubleComparer));
        }
        public void Convert_LChuv_to_Luv(double l, double c, double h, double l2, double u, double v)
        {
            // arrange
            var input = new LChuvColor(l, c, h);

            // act
            var output = Converter.ToLuv(input);

            // assert
            Assert.Equal(output.L, l2, DoubleComparer);
            Assert.Equal(output.u, u, DoubleComparer);
            Assert.Equal(output.v, v, DoubleComparer);
        }
Exemplo n.º 14
0
        public void Convert_LChuv_to_Luv(double l, double c, double h, double l2, double u, double v)
        {
            // arrange
            var input = new LChuvColor(l, c, h);

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

            // assert
            Assert.That(output.L, Is.EqualTo(l2).Using(DoubleComparer));
            Assert.That(output.u, Is.EqualTo(u).Using(DoubleComparer));
            Assert.That(output.v, Is.EqualTo(v).Using(DoubleComparer));
        }
Exemplo n.º 15
0
        public void Convert_Luv_to_LChuv(double l, double u, double v, double l2, double c, double h)
        {
            // arrange
            var input = new LuvColor(l, u, v);

            // act
            LChuvColor output = Converter.ToLChuv(input);

            // assert
            Assert.That(output.L, Is.EqualTo(l2).Using(DoubleComparer));
            Assert.That(output.C, Is.EqualTo(c).Using(DoubleComparer));
            Assert.That(output.h, Is.EqualTo(h).Using(DoubleComparer));
        }
Exemplo n.º 16
0
    public void SamplesLChuv()
    {
        // red
        var c1 = new LChuvColor(53.04, 143.39, 10.53);

        // white
        var c2 = new LChuvColor(100, 0, 0);

        // gray
        var c3 = new LChuvColor(53.39, 0, 0);

        // black
        var c4 = new LChuvColor(0, 0, 0);
    }
Exemplo n.º 17
0
        public LChuvColor ToLChuv(LuvColor color)
        {
            if (color == null)
            {
                throw new ArgumentNullException("color");
            }

            // adaptation to target luv white point (LuvWhitePoint)
            LuvColor adapted = IsChromaticAdaptationPerformed ? Adapt(color) : color;

            // conversion (perserving white point)
            var        converter = new LuvToLChuvConverter();
            LChuvColor result    = converter.Convert(adapted);

            return(result);
        }
Exemplo n.º 18
0
        public XYZColor ToXYZ(LChuvColor color)
        {
            if (color == null)
            {
                throw new ArgumentNullException("color");
            }

            // conversion to Luv
            var      luvConverter = new LChuvToLuvConverter();
            LuvColor labColor     = luvConverter.Convert(color);

            // conversion to XYZ (incl. adaptation)
            XYZColor result = ToXYZ(labColor);

            return(result);
        }
Exemplo n.º 19
0
        public LChuvColor ToLChuv <T>(T color) where T : IColorVector
        {
            if (color == null)
            {
                throw new ArgumentNullException("color");
            }

            LChuvColor converted = color as LChuvColor;

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

                return(ToLChuv(source));
            }
        }
Exemplo n.º 20
0
        public LuvColor ToLuv(LChuvColor color)
        {
            if (color == null)
            {
                throw new ArgumentNullException("color");
            }

            // conversion (perserving white point)
            var      converter = new LChuvToLuvConverter();
            LuvColor unadapted = converter.Convert(color);

            if (!IsChromaticAdaptationPerformed)
            {
                return(unadapted);
            }

            // adaptation to target luv white point (LuvWhitePoint)
            LuvColor adapted = Adapt(unadapted);

            return(adapted);
        }
Exemplo n.º 21
0
    public void ToString_Simple()
    {
        var color = new LChuvColor(l: 10, c: 20.5, h: 45.445);

        Assert.Equal("LChuv [L=10, C=20.5, h=45.45]", color.ToString());
    }