Ejemplo n.º 1
0
        public void Equals_RgbRgb_Correct()
        {
            var source = new RGB(30, 20, 50);
            var target = new RGB(30, 20, 50);

            Assert.True(ColorComparer.Equals(source, target));
        }
Ejemplo n.º 2
0
        public void Equals_RgbHsl_Incorrect()
        {
            var source = new RGB(10, 10, 20);
            var target = new CMYK(50, 50, 50, 50);

            Assert.False(ColorComparer.Equals(source, target));
        }
Ejemplo n.º 3
0
        public void Equals_XyzHsl_Correct()
        {
            var source = new XYZ(7.204152260786181, 6.508662463833722, 5.291475940262422);
            var target = new HSL(10, 20, 30);

            Assert.True(ColorComparer.Equals(source, target));
        }
Ejemplo n.º 4
0
        public void Equals_XyzXyz_Correct()
        {
            var source = new XYZ(10, 20, 32);
            var target = new XYZ(10, 20, 32);

            Assert.True(ColorComparer.Equals(source, target));
        }
Ejemplo n.º 5
0
        public void Equals_XyzCmyk_Correct()
        {
            var source = new XYZ(43.51851344932272, 47.11567032831833, 41.45089374761614);
            var target = new CMYK(10, 10, 20, 20);

            Assert.True(ColorComparer.Equals(source, target));
        }
Ejemplo n.º 6
0
        public void Equals_XyzHsv_Correct()
        {
            var source = new XYZ(20.862806611491127, 19.133352252151763, 12.718731377483968);
            var target = new HSV(20, 40, 60);

            Assert.True(ColorComparer.Equals(source, target));
        }
Ejemplo n.º 7
0
        public void Equals_HslHex_Correct()
        {
            var source = new HSL(20, 100, 20);
            var target = new HEX("662200");

            Assert.True(ColorComparer.Equals(source, target));
        }
Ejemplo n.º 8
0
        public void Equals_XyzHex_Correct()
        {
            var source = new XYZ(5.699791412405596, 9.958316792578774, 3.135110923508634);
            var target = new HEX("226622");

            Assert.True(ColorComparer.Equals(source, target));
        }
Ejemplo n.º 9
0
        public void Equals_HslRgb_Correct()
        {
            var source = new HSL(250, 92, 36);
            var target = new RGB(35, 7, 176);

            Assert.True(ColorComparer.Equals(source, target));
        }
Ejemplo n.º 10
0
        public void Equals_RgbCmyk_Correct()
        {
            var source = new RGB(53, 53, 59);
            var target = new CMYK(9, 9, 0, 77);

            Assert.True(ColorComparer.Equals(source, target));
        }
Ejemplo n.º 11
0
        public void Equals_HsvXyz_Incorrect()
        {
            var source = new HSV(12, 12, 12);
            var target = new XYZ(10, 10, 10);

            Assert.False(ColorComparer.Equals(source, target));
        }
Ejemplo n.º 12
0
        public void Equals_HsvXyz_Correct()
        {
            var source = new HSV(100, 20, 100);
            var target = new XYZ(76.47787698308086, 91.25178542741659, 70.70928495701926);

            Assert.True(ColorComparer.Equals(source, target));
        }
Ejemplo n.º 13
0
        public void Equals_HsvHsl_Correct()
        {
            var source = new HSV(261, 61, 20);
            var target = new HSL(261, 44, 14);

            Assert.True(ColorComparer.Equals(source, target));
        }
Ejemplo n.º 14
0
        public void Equals_HsvCmyk_Incorrect()
        {
            var source = new HSV(261, 61, 20);
            var target = new CMYK(0, 100, 0, 100);

            Assert.False(ColorComparer.Equals(source, target));
        }
Ejemplo n.º 15
0
        public void Equals_HslHex_Incorrect()
        {
            var source = new HSL(250, 48, 36);
            var target = new HEX("ffff66");

            Assert.False(ColorComparer.Equals(source, target));
        }
Ejemplo n.º 16
0
        public void Equals_XyzRgb_Incorrect()
        {
            var source = new XYZ(0, 0, 0);
            var target = new RGB(100, 100, 100);

            Assert.False(ColorComparer.Equals(source, target));
        }
Ejemplo n.º 17
0
        public void Equals_HslCmyk_Correct()
        {
            var source = new HSL(100, 74, 18);
            var target = new CMYK(57, 0, 85, 68);

            Assert.True(ColorComparer.Equals(source, target));
        }
Ejemplo n.º 18
0
        public void Equals_XyzHex_Incorrect()
        {
            var source = new XYZ(100, 100, 100);
            var target = new HEX("ababab");

            Assert.False(ColorComparer.Equals(source, target));
        }
Ejemplo n.º 19
0
        public void Equals_HslCmyk_Incorrect()
        {
            var source = new HSL(20, 20, 80);
            var target = new CMYK(0, 10, 0, 10);

            Assert.False(ColorComparer.Equals(source, target));
        }
Ejemplo n.º 20
0
        public void Equals_XyzCmyk_Incorrect()
        {
            var source = new XYZ(20, 36, 48);
            var target = new CMYK(0, 100, 20, 160);

            Assert.False(ColorComparer.Equals(source, target));
        }
Ejemplo n.º 21
0
        public void Equals_HslHsv_Correct()
        {
            var source = new HSL(360, 100, 50);
            var target = new HSV(360, 100, 100);

            Assert.True(ColorComparer.Equals(source, target));
        }
Ejemplo n.º 22
0
        public void Equals_XyzHsv_Incorrect()
        {
            var source = new XYZ(100, 0, 100);
            var target = new HSV(20, 0, 20);

            Assert.False(ColorComparer.Equals(source, target));
        }
Ejemplo n.º 23
0
        public void Equals_HslHsl_Correct()
        {
            var source = new HSL(250, 63, 15);
            var target = new HSL(250, 63, 15);

            Assert.True(ColorComparer.Equals(source, target));
        }
Ejemplo n.º 24
0
        public void Equals_RgbHsv_Correct()
        {
            var source = new RGB(10, 10, 20);
            var target = new HSV(240, 50, 8);

            Assert.True(ColorComparer.Equals(source, target));
        }
Ejemplo n.º 25
0
        public void Equals_HslHsl_Incorrect()
        {
            var source = new HSL(100, 100, 100);
            var target = new HSL(0, 0, 0);

            Assert.False(ColorComparer.Equals(source, target));
        }
Ejemplo n.º 26
0
        public void Equals_XyzXyz_Incorrect()
        {
            var source = new XYZ(20, 20, 20);
            var target = new XYZ(30, 30, 30);

            Assert.False(ColorComparer.Equals(source, target));
        }
Ejemplo n.º 27
0
        public void Equals_HslXyz_Correct()
        {
            var source = new HSL(344, 4, 50);
            var target = new XYZ(20, 20, 22);

            Assert.True(ColorComparer.Equals(source, target));
        }
Ejemplo n.º 28
0
        public void Equals_RgbHsl_Correct()
        {
            var source = new RGB(158, 0, 92);
            var target = new HSL(325, 100, 31);

            Assert.True(ColorComparer.Equals(source, target));
        }
Ejemplo n.º 29
0
        public void Equals_HslXyz_Incorrect()
        {
            var source = new HSL(1, 10, 100);
            var target = new XYZ(2, 20, 200);

            Assert.False(ColorComparer.Equals(source, target));
        }
Ejemplo n.º 30
0
        public void Equals_RgbXyz_Correct()
        {
            var source = new RGB(10, 20, 10);
            var target = new XYZ(0.43011701684271597, 0.5867562215079294, 0.37774575807786603);

            Assert.True(ColorComparer.Equals(source, target));
        }
Ejemplo n.º 31
0
            /**
             * Finds the point within this box's lowerIndex and upperIndex index of where to split.
             *
             * This is calculated by finding the longest color dimension, and then sorting the
             * sub-array based on that dimension value in each color. The colors are then iterated over
             * until a color is found with at least the midpoint of the whole box's dimension midpoint.
             *
             * @return the index of the colors array to split from
             */
            public int findSplitPoint()
            {
                int longestDimension = getLongestColorDimension();

                IComparer<Color> colorComparer = null;
                switch (longestDimension)
                {
                    case COMPONENT_RED:
                        colorComparer = new ColorComparer();
                        break;
                    case COMPONENT_GREEN:
                        colorComparer = new ColorComparerByGreen();
                        break;
                    case COMPONENT_BLUE:
                        colorComparer = new ColorComparerByBlue();
                        break;
                }

                Array.Sort(mColors, lowerIndex, upperIndex - lowerIndex, colorComparer);

                int dimensionMidPoint = midPoint(longestDimension);

                for (int i = lowerIndex; i < upperIndex; i++)
                {
                    Color color = mColors[i];

                    switch (longestDimension)
                    {
                        case COMPONENT_RED:
                            if (color.R >= dimensionMidPoint)
                            {
                                return i;
                            }
                            break;
                        case COMPONENT_GREEN:
                            if (color.G >= dimensionMidPoint)
                            {
                                return i;
                            }
                            break;
                        case COMPONENT_BLUE:
                            if (color.B >= dimensionMidPoint)
                            {
                                return i;
                            }
                            break;
                    }
                }

                return lowerIndex;
            }