Skip to content

Commit f992abe

Browse files
committed
Fixed two major bugs; where width and height was mixed up in the algorithm
1 parent b7c23ad commit f992abe

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

packing.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ grid.insert = function(self, width, height, data)
103103

104104
local overhangRight = height - self.currentHeight -- over hang cost
105105
if overhangRight > 0 then
106-
overhangRight = self.currentHeight * overhangRight
106+
overhangRight = self.currentWidth * overhangRight
107107
else
108108
overhangRight = 0
109109
end
@@ -218,7 +218,7 @@ grid.insert = function(self, width, height, data)
218218
-- create cell to fit gap between new cell height and current height
219219
insert(self.unoccupiedCells, cell.new(width, self.currentHeight, self.currentWidth-width, height))
220220
elseif self.currentWidth < width then
221-
insert(self.unoccupiedCells, cell.new(self.currentWidth, 0, width-self.currentWidth, self.currentWidth))
221+
insert(self.unoccupiedCells, cell.new(self.currentWidth, 0, width-self.currentWidth, self.currentHeight))
222222
self.currentWidth = width
223223
end
224224
self.currentHeight = self.currentHeight + height

0 commit comments

Comments
 (0)