public byte GetSimilarityPercents(GeneticColor anotherColor)
 {
     switch (this.ComparsionMethod)
     {
         case (ComparsionMethods.Linear):
             return GetSimilarityLinearPercents(anotherColor);
         case (ComparsionMethods.Square):
             return GetSimilaritySquarePercents(anotherColor);
         default:
             return 0;
     }
 }
 public int GetSimilarityUnits(GeneticColor anotherColor)
 {
     switch (this.ComparsionMethod)
     {
         case (ComparsionMethods.Linear):
             return GetSimilarityLinearUnits(anotherColor);
         case (ComparsionMethods.Square):
             return GetSimilaritySquareUnits(anotherColor);
         default:
             return -1;
     }
 }
 public int GetDifferenceUnits(GeneticColor anotherColor)
 {
     switch (this.ComparsionMethod)
     {
         case (ComparsionMethods.Linear):
             return GetDifferenceLinearUnits(anotherColor);
         case (ComparsionMethods.Square):
             return GetDifferenceSquareUnits(anotherColor);
         default:
             return -1;
     }
 }
 private byte GetDifferenceLinearPercents(GeneticColor anotherColor)
 {
     //3*255
     return (byte)(100 * GetDifferenceLinearUnits(anotherColor) / LinearBaseMax);
 }
        public GeneticColor Blend(GeneticColor anotherColor, byte percentage)
        {
            if (percentage > 100)
                percentage = 100;

            var blend = new GeneticColor
            {
                Red = Convert.ToByte(0.01 * (percentage * this.Red + (100 - percentage) * anotherColor.Red)),
                Green = Convert.ToByte(0.01 * (percentage * this.Green + (100 - percentage) * anotherColor.Green)),
                Blue = Convert.ToByte(0.01 * (percentage * this.Blue + (100 - percentage) * anotherColor.Blue)),
            };

            return blend;
        }
 private int GetSimilaritySquareUnits(GeneticColor anotherColor)
 {
     return SquareBaseMax - GetDifferenceSquareUnits(anotherColor);
 }
 public GeneticBlackBox(GeneticColor target, ComparsionMethods method)
 {
     _target = target;
     ComparsionMethod = method;
 }
 private byte GetSimilaritySquarePercents(GeneticColor anotherColor)
 {
     return (byte)(100 - GetDifferenceSquarePercents(anotherColor));
 }
 private int GetSimilarityLinearUnits(GeneticColor anotherColor)
 {
     return LinearBaseMax - GetDifferenceLinearUnits(anotherColor);
 }
 private int GetDifferenceSquareUnits(GeneticColor anotherColor)
 {
     var dr = _target.Red - anotherColor.Red;
     var dg = _target.Green - anotherColor.Green;
     var db = _target.Blue - anotherColor.Blue;
     int result = 0;
     if (dr != 0 || dg != 0 || db != 0)
         result = Convert.ToInt32(Math.Ceiling(Math.Sqrt(dr * dr + dg * dg + db * db)));
     return result;
 }
 private byte GetDifferenceSquarePercents(GeneticColor anotherColor)
 {
     //[sqrt(3*255*255)]
     return (byte)(100 * GetDifferenceSquareUnits(anotherColor) / SquareBaseMax);
 }
 private int GetDifferenceLinearUnits(GeneticColor anotherColor)
 {
     var dr = Math.Abs(_target.Red - anotherColor.Red);
     var dg = Math.Abs(_target.Green - anotherColor.Green);
     var db = Math.Abs(_target.Blue - anotherColor.Blue);
     return (dr + dg + db);
 }