43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/sass/extras/contrast.rb', line 43
def contrast_color(color, seed_color = nil, wcag20_level = Sass::Script::String.new("aa"))
seed_color ||= color
assert_type color, :Color, :color
assert_type seed_color, :Color, :seed_color
assert_type wcag20_level, :String, :wcag20_level
direction = color.brightness > 127 ? darken_method : lighten_method
new_color = seed_color
percentage = 0.0
until conform(new_color, color, wcag20_level.value) || percentage > 100.0
amount = Sass::Script::Number.new percentage, ['%']
new_color = send(direction, seed_color, amount)
percentage += 0.1
end
new_color
end
|