lib/sprite/builder.rb in sprite-0.1.5 vs lib/sprite/builder.rb in sprite-0.1.6

- old
+ new

@@ -57,26 +57,28 @@ sources = image['sources'].to_a return unless sources.length > 0 name = image['name'] format = image['format'] || config["default_format"] - spaced_by = image['spaced_by'] || 0 + spaced_by = image['spaced_by'] || config["default_spacing"] || 0 combiner = ImageCombiner.new dest_image = combiner.get_image(sources.shift) results << combiner.image_properties(dest_image).merge(:x => 0, :y => 0, :group => name) sources.each do |source| source_image = combiner.get_image(source) if image['align'].to_s == 'horizontal' x = dest_image.columns + spaced_by y = 0 + align = "horizontal" else x = 0 y = dest_image.rows + spaced_by + align = "vertical" end - results << combiner.image_properties(source_image).merge(:x => -x, :y => -y, :group => name) + results << combiner.image_properties(source_image).merge(:x => -x, :y => -y, :group => name, :align => align) dest_image = combiner.composite_images(dest_image, source_image, x, y) end # set up path path = image_output_path(name, format) @@ -106,9 +108,10 @@ @config['image_source_path'] ||= 'images/' @config['public_path'] ||= 'public/' @config['default_format'] ||= 'png' @config['class_separator'] ||= '-' @config["sprites_class"] ||= 'sprites' + @config["default_spacing"] ||= 0 end # if no image configs are detected, set some intelligent defaults def set_image_defaults return unless @images.size == 0 \ No newline at end of file