put in the row fitter
This commit is contained in:
parent
cc26b98909
commit
370044ba77
@ -7,7 +7,7 @@ GIT
|
|||||||
PATH
|
PATH
|
||||||
remote: .
|
remote: .
|
||||||
specs:
|
specs:
|
||||||
compass (0.11.1.d9ca08f)
|
compass (0.11.1.cc26b98)
|
||||||
chunky_png (~> 1.1)
|
chunky_png (~> 1.1)
|
||||||
fssm (>= 0.2.7)
|
fssm (>= 0.2.7)
|
||||||
sass (~> 3.1)
|
sass (~> 3.1)
|
||||||
|
@ -71,16 +71,10 @@ module Compass
|
|||||||
# collects image sizes and input parameters for each sprite
|
# collects image sizes and input parameters for each sprite
|
||||||
def compute_image_positions!
|
def compute_image_positions!
|
||||||
imgs = @images.sort { |a,b| a.width <=> b.width }
|
imgs = @images.sort { |a,b| a.width <=> b.width }
|
||||||
rows = [::Compass::SassExtensions::Sprites::ImageRow.new(@width)]
|
|
||||||
imgs.each do |image|
|
fitter = ::Compass::SassExtensions::Sprites::RowFitter.new(imgs)
|
||||||
next if rows.last.add(image)
|
rows = fitter.fit!
|
||||||
|
|
||||||
rows << ::Compass::SassExtensions::Sprites::ImageRow.new(@width)
|
|
||||||
unless rows.last.add(image)
|
|
||||||
raise "Image failed to be added"
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
current_y = 0
|
current_y = 0
|
||||||
rows.each do |row|
|
rows.each do |row|
|
||||||
current_x = 0
|
current_x = 0
|
||||||
|
@ -1,18 +0,0 @@
|
|||||||
module Compass
|
|
||||||
module SassExtensions
|
|
||||||
module Sprites
|
|
||||||
class ImageGroup
|
|
||||||
attr_reader :images
|
|
||||||
|
|
||||||
def initialize(images = [])
|
|
||||||
@images = images
|
|
||||||
end
|
|
||||||
|
|
||||||
def best_fitting_rows
|
|
||||||
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
@ -8,6 +8,7 @@ module Compass
|
|||||||
|
|
||||||
attr_reader :images, :rows
|
attr_reader :images, :rows
|
||||||
def_delegators :rows, :[]
|
def_delegators :rows, :[]
|
||||||
|
|
||||||
def initialize(images)
|
def initialize(images)
|
||||||
@images = images
|
@images = images
|
||||||
@rows = []
|
@rows = []
|
||||||
@ -15,6 +16,7 @@ module Compass
|
|||||||
|
|
||||||
def fit!(style = :scan)
|
def fit!(style = :scan)
|
||||||
send("#{style}_fit")
|
send("#{style}_fit")
|
||||||
|
@rows
|
||||||
end
|
end
|
||||||
|
|
||||||
def width
|
def width
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
require 'test_helper'
|
|
||||||
require 'compass/sass_extensions/sprites/image_group'
|
|
||||||
|
|
||||||
class ImageGroupTest < Test::Unit::TestCase
|
|
||||||
def setup
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user