{"library":"rectangle-packer","title":"Rectangle Packer","description":"rectangle-packer is a Python library for efficiently packing a set of 2D rectangles into a minimal bounding box. It utilizes an optimized best-fit heuristic algorithm to achieve high packing density. The current stable version is 2.1.0, and it maintains a moderate release cadence, with updates addressing performance and edge cases, primarily focusing on its core `pack` functionality.","language":"python","status":"active","last_verified":"Fri Apr 17","install":{"commands":["pip install rectangle-packer"],"cli":null},"imports":["from rpack import pack","from rpack import pack # 'group' was removed","from rpack import pack # '_rpack' was removed"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import rpack\n\n# Rectangles are defined as (width, height) tuples\nrects = [\n    (10, 20),\n    (5, 15),\n    (12, 12),\n    (30, 10),\n    (8, 25)\n]\n\n# Pack the rectangles, returns a list of (x, y) positions\n# (0,0) is top-left, increasing x to the right, increasing y downwards\npositions = rpack.pack(rects)\n\n# The positions correspond to the input rectangles order\nfor i, (x, y) in enumerate(positions):\n    print(f\"Rectangle {i+1} (w={rects[i][0]}, h={rects[i][1]}): Position ({x}, {y})\")\n\n# You can find the enclosing dimensions of the packed layout\nwidth, height = rpack.util.enclosing_size(rects, positions)\nprint(f\"Total enclosing size: Width={width}, Height={height}\")","lang":"python","description":"This quickstart demonstrates how to define a list of rectangles as (width, height) tuples and use `rpack.pack()` to find their optimal positions within a minimal bounding box. It then prints the calculated (x, y) positions for each rectangle and the overall dimensions of the packed area.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}