# File lib/color/palette/monocontrast.rb, line 134 def calculate_foreground(background, foreground) nfg = nil # Loop through brighter and darker versions of the foreground color. The # numbers here represent the amount of foreground color to mix with # black and white. [100, 75, 50, 25, 0].each do |percent| dfg = foreground.darken_by(percent) lfg = foreground.lighten_by(percent) dbd = brightness_diff(background, dfg) lbd = brightness_diff(background, lfg) if lbd > dbd nfg = lfg nbd = lbd else nfg = dfg nbd = dbd end ncd = color_diff(background, nfg) break if nbd >= @minimum_brightness_diff and ncd >= @minimum_color_diff end nfg end