ShelfPack

index.js

Create a new ShelfPack bin allocator.

Uses the Shelf Best Height Fit algorithm from http://clb.demon.fi/files/RectangleBinPack.pdf

ShelfPack(w: [number], h: [number], options: [Object])
Parameters
w ([number] (default 64) ) Initial width of the sprite
h ([number] (default 64) ) Initial width of the sprite
options ([Object])
Name Description
options.autoResize [boolean] (default false) If true , the sprite will automatically grow
Example
var sprite = new ShelfPack(64, 64, { autoResize: false });
Instance Members
pack (bins, [options])
packOne (w, h, [id])
getBin (id)
ref (bin)
unref (bin)
clear ()
resize (w, h)

Create a new Bin object.

Bin(id: (number | string), x: number, y: number, w: number, h: number)
Parameters
id ((number | string)) Unique id of the bin
x (number) Left coordinate of the bin
y (number) Top coordinate of the bin
w (number) Width of the bin
h (number) Height of the bin
Example
var bin = new Bin('a', 0, 0, 12, 16);