How to use the maxrects-packer.PACKING_LOGIC.MAX_EDGE function in maxrects-packer

To help you get started, we’ve selected a few maxrects-packer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github odrick / free-tex-packer-core / packers / MaxRectsPacker.js View on Github external
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 = [];

maxrects-packer

A max rectangle 2d bin packer for packing glyphs or images into multiple sprite-sheet/atlas

MIT
Latest version published 2 years ago

Package Health Score

50 / 100
Full package analysis