in src/Desktop/ColorContrastAnalyzer/ColorContrastResult.cs [26:62]
internal ColorContrastResult Add(ColorPair newColorPair)
{
var newTextColor = newColorPair.foregroundColor;
var newBackgroundColor = newColorPair.backgroundColor;
if (mostContrastingPair == null ||
mostContrastingPair.ColorContrast() < newColorPair.ColorContrast())
{
mostContrastingPair = newColorPair;
}
foreach (var alternativePair in alternatives)
{
if (!alternativePair.IsVisiblySimilarTo(newColorPair))
{
numDifferentBackgroundColors++;
numVisiblyDifferentTextColors++;
}
}
if (numDifferentBackgroundColors > 3 || numVisiblyDifferentTextColors > 3)
{
confidence = Confidence.Low;
}
else if (numDifferentBackgroundColors > 1 || numVisiblyDifferentTextColors > 1)
{
confidence = Confidence.Mid;
} else
{
this.confidence = Confidence.High;
}
alternatives.Add(newColorPair);
return this;
}