module Sass::Extras::Contrast::Color
Public Instance Methods
brightness()
click to toggle source
# File lib/sass/extras/contrast.rb, line 18 def brightness # W3C; Rec. 601 luma Utils.sum(Utils.mul(rgb, BRIGHTNESS_COEFS)) end
brightness_alt()
click to toggle source
# File lib/sass/extras/contrast.rb, line 23 def brightness_alt # http://alienryderflex.com/hsp.html Math.sqrt(Utils.sum(Utils.mul(Utils.sq(rgb), [0.241, 0.691, 0.068]))) end
diff(other)
click to toggle source
# File lib/sass/extras/contrast.rb, line 8 def diff(other) # W3C Utils.sum(Utils.abs(rgb, other.rgb)) end
diff_alt(other)
click to toggle source
# File lib/sass/extras/contrast.rb, line 13 def diff_alt(other) # 3D - Sqrt(dr^2+dg^2+db^2) Math.sqrt(Utils.sum(Utils.sq(Utils.abs(rgb, other.rgb)))) end
luminance()
click to toggle source
# File lib/sass/extras/contrast.rb, line 28 def luminance # http://www.w3.org/TR/WCAG20/#relativeluminancedef norm_rgb = rgb.map { |value| value.to_f / 255 } relative_luminance = norm_rgb.map { |v| v <= 0.03928 ? v / 12.92 : ((v + 0.055) / 1.055)**2.4 } Utils.sum(Utils.mul(relative_luminance, LUMINANCE_COEFS)) end