Esempio n. 1
0
        //颜色匹配部分
        public int CompareDist(string mainColor)
        {
            TriditionalColor triditionalColors = new TriditionalColor();

            TridColor[] tridColors = new TridColor[630];
            tridColors = triditionalColors.InitTriditionalColors();

            double[] dists   = new double[630];
            double   minDist = 196608;
            int      minNub  = 0;

            ColorAbouts colorAbouts = new ColorAbouts();

            for (int i = 0; i < 629; i++)
            {
                dists[i] = colorAbouts.CalculateDist(mainColor, tridColors[i].Hex);

                if (dists[i] <= minDist)
                {
                    minDist = dists[i];
                    minNub  = i;
                }
            }

            return(minNub);
        }
Esempio n. 2
0
        public TridColor[] InitTriditionalColors()
        {
            TridColor[] tridColors = new TridColor[630];

            tridColors[0] = new TridColor("#000000", "出错啦");

            string colorContent = GetColorInTxt();

            string[] temp = colorContent.Split(';');

            int i = 0;

            foreach (string str in temp)
            {
                if (str.Contains("="))
                {
                    int index = str.IndexOf("=");
                    i++;
                    tridColors[i] = new TridColor(str.Substring(index + 1, str.Length - index - 1), str.Substring(3, index - 3));
                }
            }

            return(tridColors);
        }