Skip to content

Commit

Permalink
Merge pull request #9 from neekfenwick/linear-algo-tallest-first
Browse files Browse the repository at this point in the history
Make Linear algorithm sort tallest to shortest, rather than widest to…
  • Loading branch information
dagmike authored Feb 27, 2021
2 parents ec35f70 + 9749baa commit 191794f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dagmike/bin-packing",
"version": "1.7.1",
"version": "1.7.2",
"description": "2D bin packing PHP implementation",
"type": "library",
"license": "MIT",
Expand Down
3 changes: 2 additions & 1 deletion src/Algorithms/Linear.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ public static function findNewPosition(
if ($freeRect->getWidth() >= $rectangle->getWidth()) {
$bestNode->setX($freeRect->getX());
$bestNode->setY($freeRect->getY());
$bestX = $freeRect->getWidth() - $rectangle->getWidth();
// Favour the tallest items first.
$bestY = $freeRect->getHeight() - $rectangle->getHeight();
return $bestNode;
}
}
Expand Down

0 comments on commit 191794f

Please sign in to comment.