diff options
| author | Jules Laplace <jules@okfoc.us> | 2014-06-20 12:14:51 -0400 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2014-06-20 12:14:51 -0400 |
| commit | 8aede8cb98669537213eb267e8602dc3e8266c97 (patch) | |
| tree | ce5397403a63a7129e765585830e499ab3e19112 /public/assets/javascripts/rectangles/models/wall.js | |
| parent | 1a1009d5cbfb1deb7cc110bacf3fd76236cf25a9 (diff) | |
preserve proportions on scale (also smoother now)
Diffstat (limited to 'public/assets/javascripts/rectangles/models/wall.js')
| -rw-r--r-- | public/assets/javascripts/rectangles/models/wall.js | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/public/assets/javascripts/rectangles/models/wall.js b/public/assets/javascripts/rectangles/models/wall.js index e327070..d0a2045 100644 --- a/public/assets/javascripts/rectangles/models/wall.js +++ b/public/assets/javascripts/rectangles/models/wall.js @@ -49,19 +49,20 @@ window.Wall = (function(){ }) } - Wall.prototype.bounds_for = function(img) { + Wall.prototype.bounds_for = function(img, scale) { + scale = scale || 1 var coord = this.side & FRONT_BACK ? this.rect.x : this.rect.y - var halfWidth = img.width/2 * img.scale - var halfHeight = img.height/2 * img.scale + var halfWidth = img.width/2 * scale + var halfHeight = img.height/2 * scale return new Rect( new vec2( coord.a + halfWidth, coord.b - halfWidth ), new vec2( halfHeight, Rooms.list[this.room].height - halfHeight ) ) } - Wall.prototype.fits = function(img){ - if (this.side & FRONT_BACK && this.rect.x.length() < img.width * img.scale) { + Wall.prototype.fits = function(img, scale){ + if (this.side & FRONT_BACK && this.rect.x.length() < img.width * scale) { return false } - if (this.side & LEFT_RIGHT && this.rect.y.length() < img.width * img.scale) { + if (this.side & LEFT_RIGHT && this.rect.y.length() < img.width * scale) { return false } return true |
