Skip to content

Commit

Permalink
fail and warn when spriteatlas is full
Browse files Browse the repository at this point in the history
ref #1633
  • Loading branch information
ansis committed Jan 6, 2016
1 parent 4fd3fd9 commit b016729
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions js/symbol/sprite_atlas.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ SpriteAtlas.prototype.allocateImage = function(pixelWidth, pixelHeight) {
// We have to allocate a new area in the bin, and store an empty image in it.
// Add a 1px border around every image.
var rect = this.bin.allocate(packWidth, packHeight);
if (rect.w === 0) {
if (rect.x < 0) {
console.warn('SpriteAtlas out of space.');
return rect;
}

Expand All @@ -145,7 +146,7 @@ SpriteAtlas.prototype.getImage = function(name, wrap) {
var width = pos.width / pos.pixelRatio;
var height = pos.height / pos.pixelRatio;
var rect = this.allocateImage(width, height);
if (rect.w === 0) {
if (rect.x < 0) {
return rect;
}

Expand Down

0 comments on commit b016729

Please sign in to comment.