summaryrefslogtreecommitdiff
path: root/public/assets/javascripts/rectangles/models/wall.js
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2014-10-16 16:06:47 -0400
committerJules Laplace <jules@okfoc.us>2014-10-16 16:06:47 -0400
commit6842a993ac6aef50e79a08df9fcb0a1d769592a1 (patch)
treee210630d2d544eb6db5e6b8c46dfa86ed1192915 /public/assets/javascripts/rectangles/models/wall.js
parent6733c7626f109373bcd526a1e1707c9ccfee75a8 (diff)
parente25af0a7106c359faae2f73a7c2295ea93db8341 (diff)
merge
Diffstat (limited to 'public/assets/javascripts/rectangles/models/wall.js')
-rw-r--r--public/assets/javascripts/rectangles/models/wall.js43
1 files changed, 26 insertions, 17 deletions
diff --git a/public/assets/javascripts/rectangles/models/wall.js b/public/assets/javascripts/rectangles/models/wall.js
index 7ff9015..eb445a7 100644
--- a/public/assets/javascripts/rectangles/models/wall.js
+++ b/public/assets/javascripts/rectangles/models/wall.js
@@ -104,7 +104,7 @@
else if (Scenery.nextWallpaper) {
var oldState = base.serialize()
base.wallpaper(Scenery.nextWallpaper)
- Scenery.nextWallpaper = null
+ // Scenery.nextWallpaper = null
UndoStack.push({
type: 'update-wallpaper',
@@ -213,7 +213,7 @@
this.$walls.css("background-color", color)
}
- Wall.prototype.wallpaper = function(background){
+ Wall.prototype.wallpaper = function(background, img){
if (! background) {
background = { src: "none" }
}
@@ -235,7 +235,7 @@
return
}
- var img = new Image ()
+ img = img || new Image ()
img.onload = function(){
this.backgroundImage = img
this.wallpaperLoad(this.background.src)
@@ -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