ndarray-bin-pack
A simple bin-packer for a list of ndarray objects. Guesses depth and dtype from the first ndarray object.
Can be used for packing 2D sprites into a single texture atlas.
var pack = //pack a list of ndarraysvar atlas = console// [ { position, shape }, { position, shape } ] console// ndarray for the whole atlas console// size of final atlas
The input array must have a length greater than zero.
See demo/index.js for an example application.
Usage
atlas = pack(ndarrays)
Bin-packs the list of ndarrays
(must be a non-empty list) into a single atlas.
The return value is:
{
array: array, //the ndarray for the whole atlas
bins: [
{ position: [x, y], shape: [w, h, d] },
... etc
]
}
Where bins
is parallel to the array that was provided as input.
License
MIT, see LICENSE.md for details.