Module: Sass::Script::Functions

Defined in:
lib/bootstrapped-rails/ie_hex_str.rb

Instance Method Summary collapse

Instance Method Details

#ie_hex_str(color) ⇒ Object

returns an IE hex string for a color with an alpha channel suitable for passing to IE filters. see msdn.microsoft.com/en-us/library/ms532930%28v=vs.85%29.aspx



7
8
9
10
11
12
13
14
# File 'lib/bootstrapped-rails/ie_hex_str.rb', line 7

def ie_hex_str(color)
  assert_type color, :Color
  alpha = (color.alpha * 255).round
  alpha = alpha.to_s(16).rjust(2, '0')
  color_string = color.rgb.map {|num| num.to_s(16).rjust(2, '0')} .join

  Sass::Script::String.new("##{alpha}#{color_string}")
end