Exemple #1
0
        public static HexColor Contrast(HexColor color)
        {
            Color sc  = (Color)color;
            float yiq = ((sc.R * 299) + (sc.G * 587) + (sc.B * 114)) / 1000;

            return((yiq >= 128) ? Black : White);
        }
Exemple #2
0
 public virtual void Add(HexColor color)
 {
     Expect.IsTrue(IsValidHexColor(color.Hex));
     if (!_colorsByName.ContainsKey(color.Name))
     {
         _colorsByName.Add(color.Name, color);
     }
 }
Exemple #3
0
 public void Set(HexColor color)
 {
     Expect.IsTrue(IsValidHexColor(color.Hex));
     if (!_colorsByName.ContainsKey(color.Name))
     {
         _colorsByName.Add(color.Name, color);
     }
     else
     {
         _colorsByName[color.Name] = color;
     }
 }
Exemple #4
0
        public void Set(string colorName, string hexColor)
        {
            HexColor color = new HexColor(colorName, hexColor);

            Set(color);
        }
Exemple #5
0
        /// <summary>
        /// Adds the specified color if one with the same name
        /// has not already been added.
        /// </summary>
        /// <param name="colorName"></param>
        /// <param name="hexColor"></param>
        public void Add(string colorName, string hexColor)
        {
            HexColor color = new HexColor(colorName, hexColor);

            Add(color);
        }