binpack 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/binpack.rb +12 -1
- data/lib/binpack/version.rb +1 -1
- metadata +1 -1
data/lib/binpack.rb
CHANGED
@@ -40,7 +40,7 @@ module Binpack
|
|
40
40
|
@rows[i + @padding, item.height].each{ |s|
|
41
41
|
s[idx + @padding, item.width] = "#{g}" * item.width
|
42
42
|
}
|
43
|
-
@items.push([item, idx
|
43
|
+
@items.push([item, idx, i])
|
44
44
|
return item
|
45
45
|
}
|
46
46
|
nil
|
@@ -75,3 +75,14 @@ module Binpack
|
|
75
75
|
end
|
76
76
|
end
|
77
77
|
end
|
78
|
+
|
79
|
+
items = []
|
80
|
+
12.times do |i|
|
81
|
+
items << Binpack::Item.new("Associated object #{i+1}", (rand(10)+2)/2.0, (rand(10)+2)/2.0)
|
82
|
+
end
|
83
|
+
|
84
|
+
# Pack the array of items into a bin where the default bin size is 16x10 with a padding of 1
|
85
|
+
bins = Binpack::Bin.pack(items, [], Binpack::Bin.new(16, 10, 1))
|
86
|
+
|
87
|
+
puts bins.join("\n\n")
|
88
|
+
puts bins[0].items.inspect
|
data/lib/binpack/version.rb
CHANGED