Module: Sass::Extras::InlineColorImage
- Defined in:
- lib/sass/extras/inline_color_image.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#inline_color_image(color) ⇒ Object
Generates a data-url for a PNG created from the given color.
Class Method Details
.included(base) ⇒ Object
6 7 8 |
# File 'lib/sass/extras/inline_color_image.rb', line 6 def self.included(base) base.declare :inline_color_image, [:color] end |
Instance Method Details
#inline_color_image(color) ⇒ Object
Generates a data-url for a PNG created from the given color. Can be used to set a alpha-transparent background for IE8<
15 16 17 18 19 |
# File 'lib/sass/extras/inline_color_image.rb', line 15 def inline_color_image(color) assert_type color, :Color chunky_color = ChunkyPNG::Color.rgba(color.red, color.green, color.blue, (color.alpha * 255).round) Sass::Script::String.new(ChunkyPNG::Image.new(32, 32, chunky_color).to_data_url) end |