1.4.1 • Published 6 years ago

binpack-2d v1.4.1

Weekly downloads
5
License
MIT
Repository
github
Last release
6 years ago

Bin Pack 2D

binpack-2d is a simple 2-dimensional bin packing library. This library packs objects of known width and height into the container of the finite or infinite size.

Installation

npm install binpack-2d

Usage

import binpack from 'binpack-2d'
const objects = [
  {width: 10, height: 10},
  {width: 20, height: 10},
  {width: 10, height: 20},
]
const container = {width: 30, height: Infinity}
const options = {... options }
const result = binpack(container, objects, options)

Options available

align

default: left values: left, right, center

If objects will be aligned if there's an empty space left.

inPlace

default: false

If objects will be modified in-place instead of returning new ones.

Return value

If inPlace options is set to false:

{
  width: 30,
  height: 20,
  items: {
    {width: 10, height: 10, x: 0, y: 0},
    {width: 20, height: 10, x: 10, y: 0},
    {width: 10, height: 20, x: 0, y: 10},
  },
}

If inPlace option is set to true:

{
  width: 30,
  height: 20,
}

Contributing

Any contributions are highly appreciated.

License

MIT

1.4.1

6 years ago

1.4.0

6 years ago

1.3.2

7 years ago

1.3.1

7 years ago

1.3.0

7 years ago

1.2.4

7 years ago

1.2.3

7 years ago

1.2.2

7 years ago

1.2.1

7 years ago

1.2.0

7 years ago

1.1.2

7 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago