예제 #1
0
 public void Test1()
 {
     foreach (var item in DataSet)
     {
         Assert.AreEqual(item.De2000, ColorCalc.DeltaE2000(item.color[0], item.color[1]), 1e-3);
     }
 }
예제 #2
0
        /// <summary>
        /// Calculate closest color name and return it as string
        /// </summary>
        /// <param name="currentColor"></param>
        /// <returns>Closest color name</returns>
        private string CalculateCloseColor(Color currentColor)
        {
            double res      = double.MaxValue;
            var    resColor = AdvColor.CreateInstance(Color.Black);
            var    current  = AdvColor.CreateInstance(currentColor);

            foreach (var color in ColorsData.Colors)
            {
                double tmp = ColorCalc.DeltaE2000(color, current);
                if (!(res > tmp))
                {
                    continue;
                }
                resColor = color;
                res      = tmp;
            }
            return(resColor.Name);
        }
예제 #3
0
 /// <summary>
 /// Sets background of TextBox and Button to Color. Sets text color of TextBox and Button to black/white depending on input color.
 /// </summary>
 /// <param name="color"></param>
 private void SetBackgrounds(Color color)
 {
     Dispatcher.Invoke(() =>
     {
         var mColor = System.Windows.Media.Color.FromArgb(color.A, color.R, color.G, color.B);
         Background = new SolidColorBrush(mColor);
         if (ColorCalc.DeltaE2000(new AdvColor(color), new AdvColor(Color.Black)) < 30)
         {
             MyText.Foreground    = System.Windows.Media.Brushes.White;
             TopButton.Foreground = System.Windows.Media.Brushes.White;
         }
         else
         {
             MyText.Foreground    = System.Windows.Media.Brushes.Black;
             TopButton.Foreground = System.Windows.Media.Brushes.Black;
         }
         MyText.Background    = new SolidColorBrush(mColor);
         TopButton.Background = new SolidColorBrush(mColor);
     });
 }