From f885f2caca46af82ae49149e361a25e3419fedc0 Mon Sep 17 00:00:00 2001 From: Julie Lala Date: Wed, 15 Oct 2014 23:40:12 -0400 Subject: fix wallpaper tiling bug --- .../assets/javascripts/rectangles/models/wall.js | 37 ++++++++++++++-------- 1 file changed, 23 insertions(+), 14 deletions(-) (limited to 'public/assets/javascripts/rectangles/models') diff --git a/public/assets/javascripts/rectangles/models/wall.js b/public/assets/javascripts/rectangles/models/wall.js index 7ff9015..2ee88d9 100644 --- a/public/assets/javascripts/rectangles/models/wall.js +++ b/public/assets/javascripts/rectangles/models/wall.js @@ -260,24 +260,34 @@ this.background.y = background.y || this.background.y this.background.scale = background.scale || this.background.scale || 1 - var useX = this.side & FRONT_BACK - var shouldFlip = this.side & (LEFT | BACK) - var mx, dx, dy var w = Math.round( this.backgroundImage.naturalWidth * this.background.scale ) var h = Math.round( this.backgroundImage.naturalHeight * this.background.scale ) this.surface.faces.forEach(function(face, i){ - - if (shouldFlip) { - mx = this.mx[this.mx.length-1-i] - dx = Math.round( this.background.x + face.x.a ) - dy = Math.round( this.background.y + face.y.b ) - } - else { - mx = this.mx[i] - dx = Math.round( this.background.x - face.x.b ) - dy = Math.round( this.background.y + face.y.b ) + // this.mx[i].el.innerHTML = sidesToString(this.side) + + switch (this.side) { + case LEFT: + mx = this.mx[this.mx.length-1-i] + dx = Math.round( this.background.x + face.x.a ) + dy = Math.round( this.background.y + face.y.b ) + break + case RIGHT: + mx = this.mx[this.mx.length-1-i] + dx = Math.round( this.background.x + face.x.b ) + dy = Math.round( this.background.y + face.y.b ) + break + case FRONT: + mx = this.mx[this.mx.length-1-i] + dx = Math.round( this.background.x + face.x.b ) + dy = Math.round( this.background.y + face.y.b ) + break + case BACK: + mx = this.mx[i] + dx = Math.round( this.background.x - face.x.a ) + dy = Math.round( this.background.y + face.y.b ) + break } mx.el.style.backgroundPosition = dx + 'px ' + dy + 'px' @@ -286,7 +296,6 @@ } Wall.prototype.outline = function(wallColor, outlineColor){ - var useX = this.side & FRONT_BACK var mx = this.mx var len = this.mx.length -- cgit v1.2.3-70-g09d2