module Sass::Script::Functions
Public Instance Methods
svg_icon_map(map, icon_name, color, size)
click to toggle source
# File lib/compass-svg-sprite/sass_extensions.rb, line 21 def svg_icon_map(map, icon_name, color, size) icon = map_get(map, icon_name) icon_width = map_get(icon, value_to_sass('width')).value.to_f icon_height = map_get(icon, value_to_sass('height')).value.to_f x = svg_icon_position_x(map, icon_name, color).value.to_f y = svg_icon_position_y(map, icon_name, color).value.to_f bg_w = svg_sprite_width / icon_width * 100 bg_h = svg_sprite_height / icon_height * 100 new_x = x / (svg_sprite_width - icon_width) * 100 new_y = y / (svg_sprite_height - icon_height) * 100 if size.value k = icon_height / size.value new_width = icon_width / k new_height = icon_height / k icon_map = value_to_sass({ 'width' => new_width.to_f.round, 'height' => new_height.to_f.round, 'background-size' => "#{bg_w}% #{bg_h}%", 'background-position' => "#{new_x}% #{new_y}%" }) else icon_map = value_to_sass({ 'width' => icon_width, 'height' => icon_height, 'background-size' => "#{bg_w}% #{bg_h}%", 'background-position' => "#{new_x}% #{new_y}%" }) end return icon_map end
svg_icon_position_x(map, icon_name, color)
click to toggle source
# File lib/compass-svg-sprite/sass_extensions.rb, line 11 def svg_icon_position_x(map, icon_name, color) icon = get_icon_map(map, icon_name, color) return map_get(icon, value_to_sass('x')) end
svg_icon_position_y(map, icon_name, color)
click to toggle source
# File lib/compass-svg-sprite/sass_extensions.rb, line 16 def svg_icon_position_y(map, icon_name, color) icon = get_icon_map(map, icon_name, color) return map_get(icon, value_to_sass('y')) end
svg_sprite_map(config)
click to toggle source
# File lib/compass-svg-sprite/sass_extensions.rb, line 6 def svg_sprite_map(config) SvgSprite.new(config) SvgSprite.get_map end
Private Instance Methods
get_icon_map(map, icon_name, color)
click to toggle source
# File lib/compass-svg-sprite/sass_extensions.rb, line 53 def get_icon_map(map, icon_name, color) icon_data = map_get(map, icon_name) icon_variants = map_get(icon_data, value_to_sass('colors')) if !map_has_key(icon_variants, color).value return map_get(icon_variants, value_to_sass('default')) else return map_get(icon_variants, color) end end
svg_sprite_height()
click to toggle source
# File lib/compass-svg-sprite/sass_extensions.rb, line 67 def svg_sprite_height return SvgSprite.get_height end
svg_sprite_width()
click to toggle source
# File lib/compass-svg-sprite/sass_extensions.rb, line 63 def svg_sprite_width return SvgSprite.get_width end