https://github.com/yglukhov/rect_packer
Pack rects into bigger rect
https://github.com/yglukhov/rect_packer
Last synced: about 1 month ago
JSON representation
Pack rects into bigger rect
- Host: GitHub
- URL: https://github.com/yglukhov/rect_packer
- Owner: yglukhov
- License: mit
- Created: 2017-07-12T14:24:09.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-07-17T12:54:57.000Z (about 8 years ago)
- Last Synced: 2024-10-14T15:04:47.116Z (12 months ago)
- Language: Nim
- Size: 3.91 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# rect_packer [](https://github.com/yglukhov/nimble-tag)
Simple algorithm for packing rects into a bigger rect.# Usage
```nim
import rect_packerlet p = newPacker(1024, 1024)
let sizesToPack = [ (100, 100), (50, 50), (100, 50) ]
for i, s in sizesToPack:
let res = p.pack(s[0].int32, s[1].int32)
echo "Rect ", i, " coords: ", res
```
Output:
```
Rect 0 coords: (x: 0, y: 0)
Rect 1 coords: (x: 100, y: 0)
Rect 2 coords: (x: 150, y: 0)
```