Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
pack(data, method) {
let options = {
smart: (method === METHOD.Smart || method === METHOD.SmartArea || method === METHOD.SmartSquare || method === METHOD.SmartSquareArea),
pot: false,
square: (method === METHOD.Square || method === METHOD.SquareArea || method === METHOD.SmartSquare || method === METHOD.SmartSquareArea),
allowRotation: this.allowRotate,
logic: (method === METHOD.Smart || method === METHOD.Square || method === METHOD.SmartSquare) ? PACKING_LOGIC.MAX_EDGE : PACKING_LOGIC.MAX_AREA
};
let packer = new MaxRectsPackerEngine(this.binWidth, this.binHeight, 0, options);
let input = [];
for(let item of data) {
input.push({width: item.frame.w, height: item.frame.h, data: item});
}
packer.addArray(input);
let bin = packer.bins[0];
let rects = bin.rects;
let res = [];