No description
Find a file
2017-07-17 15:54:50 +03:00
.gitignore Initial commit 2017-07-12 17:24:09 +03:00
LICENSE Initial commit 2017-07-12 17:24:09 +03:00
README.md Update README.md 2017-07-13 01:25:54 +03:00
rect_packer.nim Added comments 2017-07-12 17:32:11 +03:00
rect_packer.nimble Removed nim dependency 2017-07-17 15:54:50 +03:00

rect_packer nimble

Simple algorithm for packing rects into a bigger rect.

Usage

import rect_packer

let 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)