0.0.9 • Published 12 months ago

rectangle-packer v0.0.9

Weekly downloads
11
License
MIT
Repository
github
Last release
12 months ago

Rectangle Packer

多矩形最小面积打包

安装

npm:

npm install rectangle-packer --save

yarn:

yarn add rectangle-packer

使用

rectanglePacker(rectangleSizes);

返回新的对象列表

import rectanglePacker from "rectangle-packer";

const list = [
    { width: 105, height: 68 },
    { width: 117, height: 115 },
    { width: 62, height: 59 },
    { width: 604, height: 314 },
    { width: 3, height: 3 },
];

const packedList = rectanglePacker(list);

console.log(packedList);
// [
//     { width: 105, height: 68, x: 117, y: 314 },
//     { width: 117, height: 115, x: 0, y: 314 },
//     { width: 62, height: 59, x: 222, y: 314 },
//     { width: 604, height: 314, x: 0, y: 0 },
//     { width: 3, height: 3, x: 117, y: 382 },
// ];

在原有对象列表上扩展

import { rectanglePackerMutation } from "rectangle-packer";

const list = [
    { width: 105, height: 68 },
    { width: 117, height: 115 },
    { width: 62, height: 59 },
    { width: 604, height: 314 },
    { width: 3, height: 3 },
];

rectanglePackerMutation(list);

console.log(list);
// [
//     { width: 105, height: 68, x: 117, y: 314 },
//     { width: 117, height: 115, x: 0, y: 314 },
//     { width: 62, height: 59, x: 222, y: 314 },
//     { width: 604, height: 314, x: 0, y: 0 },
//     { width: 3, height: 3, x: 117, y: 382 },
// ];
0.0.9

12 months ago

0.0.8

3 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago

1.0.1

9 years ago

1.0.0

9 years ago