Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
tiledImages.push({
origname: tex.origname,
tex
});
}
}
// eager sort
blocks.sort((a, b) => Math.max(b.height, b.width) > Math.max(a.height, a.width));
// this is the beginning of a resulting string that will be written to res.js
let res = 'PIXI.Loader.shared';
let registry = {};
const atlases = []; // names of atlases' json files
const Packer = require('maxrects-packer').MaxRectsPacker;
const atlasWidth = 2048,
atlasHeight = 2048;
const pack = new Packer(atlasWidth, atlasHeight, 0);
// pack all the frames
pack.addArray(blocks);
// get all atlases
pack.bins.forEach((bin, binInd) => {
const atlas = document.createElement('canvas');
atlas.width = bin.width;
atlas.height = bin.height;
atlas.x = atlas.getContext('2d');
const atlasJSON = {
meta: {
app: 'https://ctjs.rocks/',
version: require('electron').remote.app.getVersion(),
image: `a${binInd}.png`,
format: 'RGBA8888',
size: {
pack(data, method) {
let options = {
smart: (method === METHOD.Smart || method === METHOD.SmartSquare),
pot: false,
square: (method === METHOD.Square || method === METHOD.SmartSquare)
};
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 = [];
for(let item of rects) {
item.data.frame.x = item.x;
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 = [];
for(let item of rects) {
item.data.frame.x = item.x;