multi-bin-packer
Advanced tools
Comparing version 1.1.1 to 1.1.2
@@ -13,3 +13,3 @@ "use strict"; | ||
add(width, height, data) { | ||
let node = this.findNode(this.rootNode, width, height) | ||
let node = this.findNode(this.rootNode, width + this.padding, height + this.padding) | ||
if (node) { | ||
@@ -16,0 +16,0 @@ node.children = this.createChildren(node, width + this.padding, height + this.padding); |
{ | ||
"name": "multi-bin-packer", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"description": "A 2d bin packer for the special purpose of creating spritesheets for CSS and games", | ||
@@ -20,2 +20,3 @@ "main": "lib/multi_bin_packer.js", | ||
"devDependencies": { | ||
"ascii-table": "0.0.9", | ||
"chai": "^3.5.0", | ||
@@ -22,0 +23,0 @@ "eslint": "^2.9.0", |
@@ -110,3 +110,42 @@ "use strict"; | ||
}); | ||
it("monkey testing", () => { | ||
bin = new BinaryTreeBin(1024, 1024, 40); | ||
let rects = []; | ||
while (true) { | ||
let width = Math.floor(Math.random() * 200); | ||
let height = Math.floor(Math.random() * 200); | ||
let position = bin.add(width, height); | ||
if (position) { | ||
expect(position.width).to.equal(width); | ||
expect(position.height).to.equal(height); | ||
rects.push(position); | ||
} else { | ||
break; | ||
} | ||
} | ||
expect(bin.width).to.not.be.above(1024); | ||
expect(bin.height).to.not.be.above(1024); | ||
rects.forEach(rect1 => { | ||
// Make sure rects are not overlapping | ||
rects.forEach(rect2 => { | ||
if (rect1 !== rect2) { | ||
let intersect = | ||
(rect1.x < rect2.x + rect2.width && | ||
rect2.x < rect1.x + rect1.width && | ||
rect1.y < rect2.y + rect2.height && | ||
rect2.y < rect1.y + rect1.height); | ||
expect(intersect).to.equal(false, "intersection detected: " + JSON.stringify(rect1) + " " + JSON.stringify(rect2)); | ||
} | ||
}); | ||
// Make sure no rect is outside bounds | ||
expect(rect1.x + rect1.width).to.not.be.above(bin.width); | ||
expect(rect1.y + rect1.height).to.not.be.above(bin.height); | ||
}); | ||
}); | ||
}); | ||
}); |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
361179
14
1721
5
1