# ndarray-bin-pack **Repository Path**: mirrors_Jam3/ndarray-bin-pack ## Basic Information - **Project Name**: ndarray-bin-pack - **Description**: bin-pack an array of rectangles into an atlas - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-11-23 - **Last Updated**: 2026-03-08 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # ndarray-bin-pack [![unstable](http://badges.github.io/stability-badges/dist/unstable.svg)](http://github.com/badges/stability-badges) A simple bin-packer for a list of [ndarray](https://www.npmjs.com/package/ndarray) objects. Guesses depth and dtype from the first ndarray object. Can be used for packing 2D sprites into a single texture atlas. ```js var pack = require('ndarray-bin-pack') //pack a list of ndarrays var atlas = pack(boxes) console.log(atlas.bins) // [ { position, shape }, { position, shape } ] console.log(atlas.array) // ndarray for the whole atlas console.log(atlas.array.shape) // size of final atlas ``` The input array must have a length greater than zero. See [demo/index.js](demo/index.js) for an example application. ## Usage [![NPM](https://nodei.co/npm/ndarray-bin-pack.png)](https://www.npmjs.com/package/ndarray-bin-pack) #### `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](http://github.com/Jam3/ndarray-bin-pack/blob/master/LICENSE.md) for details.