sprite 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -77,6 +77,7 @@ Configuration of `sprite` is done via `config/sprite.yml`. It allows you to set
77
77
  - `public_path:` defines the root folder where static assets live (defaults to `public/`)
78
78
  - `sprites_class:` defines the class name that gets added to all sprite stylesheet rules (defaults to `sprites`)
79
79
  - `default_format:` defines the default file image format of the generated files. (defaults to `png`)
80
+ - `default_spacing:` defines the default pixel spacing between sprites (defaults to 0)
80
81
  - `class_separator:` used to generated the class name by separating the image name and sprite name (defaults to `-`)
81
82
 
82
83
  * `images:` section provides an array of configurations which define which image files are built, and where they get their sprites from. each image setup provides the following config options:
@@ -101,6 +102,7 @@ All image and style paths should be set relative to the public folder (which is
101
102
  sprites_class: 'sprites'
102
103
  class_separator: '-'
103
104
  default_format: png
105
+ default_spacing: 50
104
106
 
105
107
  # defines what sprite collections get created
106
108
  images:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.5
1
+ 0.1.6
@@ -59,7 +59,7 @@ module Sprite
59
59
 
60
60
  name = image['name']
61
61
  format = image['format'] || config["default_format"]
62
- spaced_by = image['spaced_by'] || 0
62
+ spaced_by = image['spaced_by'] || config["default_spacing"] || 0
63
63
 
64
64
  combiner = ImageCombiner.new
65
65
 
@@ -70,11 +70,13 @@ module Sprite
70
70
  if image['align'].to_s == 'horizontal'
71
71
  x = dest_image.columns + spaced_by
72
72
  y = 0
73
+ align = "horizontal"
73
74
  else
74
75
  x = 0
75
76
  y = dest_image.rows + spaced_by
77
+ align = "vertical"
76
78
  end
77
- results << combiner.image_properties(source_image).merge(:x => -x, :y => -y, :group => name)
79
+ results << combiner.image_properties(source_image).merge(:x => -x, :y => -y, :group => name, :align => align)
78
80
  dest_image = combiner.composite_images(dest_image, source_image, x, y)
79
81
  end
80
82
 
@@ -108,6 +110,7 @@ module Sprite
108
110
  @config['default_format'] ||= 'png'
109
111
  @config['class_separator'] ||= '-'
110
112
  @config["sprites_class"] ||= 'sprites'
113
+ @config["default_spacing"] ||= 0
111
114
  end
112
115
 
113
116
  # if no image configs are detected, set some intelligent defaults
@@ -11,7 +11,7 @@ module Sprite
11
11
  File.open(File.join(Sprite.root, path), 'w') do |f|
12
12
  add_else = false
13
13
 
14
- f.puts "= sprite(!group_name, !image_name)"
14
+ f.puts "= sprite(!group_name, !image_name, !offset=0)"
15
15
  sprite_files.each do |sprite_file, sprites|
16
16
  sprites.each do |sprite|
17
17
 
@@ -20,9 +20,16 @@ module Sprite
20
20
  f << "else "
21
21
  end
22
22
  add_else = true
23
+ #{sprite[:x]}px #{sprite[:y]}px
24
+
25
+ if sprite[:align] == 'horizontal'
26
+ background_offset = "\#{#{sprite[:x]}+!offset}px #{sprite[:y]}px"
27
+ else
28
+ background_offset = "#{sprite[:x]}px \#{#{sprite[:y]}+!offset}px"
29
+ end
23
30
 
24
31
  f.puts %{if !group_name == "#{sprite[:group]}" and !image_name == "#{sprite[:name]}"}
25
- f.puts " background: url('/#{@builder.config['image_output_path']}#{sprite_file}') no-repeat #{sprite[:x]}px #{sprite[:y]}px"
32
+ f.puts " background: url('/#{@builder.config['image_output_path']}#{sprite_file}') no-repeat #{background_offset}"
26
33
  f.puts " width: #{sprite[:width]}px"
27
34
  f.puts " height: #{sprite[:height]}px"
28
35
  end
data/sprite.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{sprite}
8
- s.version = "0.1.5"
8
+ s.version = "0.1.6"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jacques Crocker"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sprite
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jacques Crocker