diff options
| author | Jules Laplace <jules@okfoc.us> | 2014-07-22 16:24:46 -0400 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2014-07-22 16:24:46 -0400 |
| commit | e082a27d835495f7ea27292ffdc62688a22a67a1 (patch) | |
| tree | 7f551cf42c69cb1ea9dfe0490f70e1a0d8d94834 | |
| parent | 8148d5c821e0c1bc5bbaf5fd766b57677b23ae8e (diff) | |
| parent | e2b1d4ca8c7a83b41fe4c0fc6c4d9490a6736c68 (diff) | |
merge
5 files changed, 146 insertions, 116 deletions
diff --git a/public/assets/javascripts/rectangles/models/rect.js b/public/assets/javascripts/rectangles/models/rect.js index a4fbd87..315adef 100644 --- a/public/assets/javascripts/rectangles/models/rect.js +++ b/public/assets/javascripts/rectangles/models/rect.js @@ -1,5 +1,5 @@ -window.Rect = (function(){ +(function(){ var Rect = function (x0,y0,x1,y1){ if (x0 instanceof vec2) { this.x = x0 @@ -180,6 +180,11 @@ window.Rect = (function(){ return splits } - return Rect + if ('window' in this) { + window.Rect = Rect + } + else if ('module' in this) { + module.exports = Rect + } })() diff --git a/public/assets/javascripts/rectangles/models/vec2.js b/public/assets/javascripts/rectangles/models/vec2.js index b8dba93..9233aec 100644 --- a/public/assets/javascripts/rectangles/models/vec2.js +++ b/public/assets/javascripts/rectangles/models/vec2.js @@ -1,113 +1,122 @@ -function vec2(a,b){ - this.a = a - this.b = b -} -vec2.prototype.magnitude = function(){ - return this.b-this.a -} -vec2.prototype.length = function(){ - return abs(this.b-this.a) -} -vec2.prototype.dist = function(){ - return dist(0,this.a,0,this.b) -} -vec2.prototype.clone = function(){ - return new vec2(this.a, this.b) -} -vec2.prototype.abs = function(){ - if (this.b < this.a) { - this.invert() +(function(){ + var vec2 = function (a,b){ + this.a = a + this.b = b } - return this -} -vec2.prototype.invert = function(){ - this.a = this.a ^ this.b - this.b = this.a ^ this.b - this.a = this.a ^ this.b - return this -} -vec2.prototype.midpoint = function(){ - return lerp(0.5, this.a, this.b) -} -vec2.prototype.eq = function(v){ - return this.a == v.a && this.b == v.b -} -vec2.prototype.add = function(n){ - this.a += n - this.b += n - return this -} -vec2.prototype.sub = function(n){ - this.a -= n - this.b -= n - return this -} -vec2.prototype.mul = function(n){ - this.a *= n - this.b *= n - return this -} -vec2.prototype.div = function(n){ - this.a /= n - this.b /= n - return this -} -vec2.prototype.setPosition = function(n){ - var len = this.length() - this.a = n - this.b = n + len -} -vec2.prototype.setLength = function(n){ - this.b = this.a + n -} -vec2.prototype.normalize = function(){ - var dim = max(this.a, this.b) - this.a = this.a/dim - this.b = this.b/dim - return this -} -vec2.prototype.contains = function(n){ - return this.a <= n && n <= this.b -} -vec2.prototype.containsDisc = function(n,r){ - return this.a <= n-r && n+r <= this.b -} -vec2.prototype.clamp = function(n){ - return clamp(n, this.a, this.b) -} -vec2.prototype.clampDisc = function(n,r){ - return clamp(n, this.a+r, this.b-r) -} -vec2.prototype.intersects = function(v){ - if (this.a < v.a) { - return (v.a < this.b && this.b <= v.b) || (this.a < v.b && v.b <= this.b) + vec2.prototype.magnitude = function(){ + return this.b-this.a } - else if (this.a == v.a) { - return true + vec2.prototype.length = function(){ + return abs(this.b-this.a) } - else if (this.a > v.a) { - return (this.a < v.b && v.b <= this.b) || (v.a < this.b && this.b <= v.b) + vec2.prototype.dist = function(){ + return dist(0,this.a,0,this.b) } -} -vec2.prototype.union = function(v){ - if (this.intersects(v)) { - return new vec2( min(this.a,v.a), max(this.b, v.b) ) + vec2.prototype.clone = function(){ + return new vec2(this.a, this.b) } -} -vec2.prototype.intersection = function(v){ - if (this.intersects(v)) { - return new vec2( max(this.a,v.a), min(this.b, v.b) ) + vec2.prototype.abs = function(){ + if (this.b < this.a) { + this.invert() + } + return this } -} -vec2.prototype.toString = function(){ - return "[" + ~~this.a + " " + ~~this.b + "]" -} -vec2.prototype.serialize = function(){ - return [ ~~this.a, ~~this.b ] -} -vec2.prototype.quantize = function(n){ - n = n || 10 - this.a = quantize(this.a, n) - this.b = quantize(this.b, n) -} - + vec2.prototype.invert = function(){ + this.a = this.a ^ this.b + this.b = this.a ^ this.b + this.a = this.a ^ this.b + return this + } + vec2.prototype.midpoint = function(){ + return lerp(0.5, this.a, this.b) + } + vec2.prototype.eq = function(v){ + return this.a == v.a && this.b == v.b + } + vec2.prototype.add = function(n){ + this.a += n + this.b += n + return this + } + vec2.prototype.sub = function(n){ + this.a -= n + this.b -= n + return this + } + vec2.prototype.mul = function(n){ + this.a *= n + this.b *= n + return this + } + vec2.prototype.div = function(n){ + this.a /= n + this.b /= n + return this + } + vec2.prototype.setPosition = function(n){ + var len = this.length() + this.a = n + this.b = n + len + } + vec2.prototype.setLength = function(n){ + this.b = this.a + n + } + vec2.prototype.normalize = function(){ + var dim = max(this.a, this.b) + this.a = this.a/dim + this.b = this.b/dim + return this + } + vec2.prototype.contains = function(n){ + return this.a <= n && n <= this.b + } + vec2.prototype.containsDisc = function(n,r){ + return this.a <= n-r && n+r <= this.b + } + vec2.prototype.clamp = function(n){ + return clamp(n, this.a, this.b) + } + vec2.prototype.clampDisc = function(n,r){ + return clamp(n, this.a+r, this.b-r) + } + vec2.prototype.intersects = function(v){ + if (this.a < v.a) { + return (v.a < this.b && this.b <= v.b) || (this.a < v.b && v.b <= this.b) + } + else if (this.a == v.a) { + return true + } + else if (this.a > v.a) { + return (this.a < v.b && v.b <= this.b) || (v.a < this.b && this.b <= v.b) + } + } + vec2.prototype.union = function(v){ + if (this.intersects(v)) { + return new vec2( min(this.a,v.a), max(this.b, v.b) ) + } + } + vec2.prototype.intersection = function(v){ + if (this.intersects(v)) { + return new vec2( max(this.a,v.a), min(this.b, v.b) ) + } + } + vec2.prototype.toString = function(){ + return "[" + ~~this.a + " " + ~~this.b + "]" + } + vec2.prototype.serialize = function(){ + return [ ~~this.a, ~~this.b ] + } + vec2.prototype.quantize = function(n){ + n = n || 10 + this.a = quantize(this.a, n) + this.b = quantize(this.b, n) + } + + if ('window' in this) { + window.vec2 = vec2 + } + else if ('module' in this) { + module.exports = vec2 + } + +})()
\ No newline at end of file diff --git a/public/assets/javascripts/rectangles/models/wall.js b/public/assets/javascripts/rectangles/models/wall.js index 7ff4ccb..176bd7c 100644 --- a/public/assets/javascripts/rectangles/models/wall.js +++ b/public/assets/javascripts/rectangles/models/wall.js @@ -125,14 +125,35 @@ window.Wall = (function(){ var walls = Rooms.list[this.room].walls.filter(function(w){ return (w.side | w.half_side) & match }) - return walls; + return walls } Wall.prototype.randomize_colors = function(){ var color = window.grayColors[ this.side | this.half_side ] - this.siblings().forEach(function(w){ w.color(color) }) + var siblings = this.siblings() + siblings.forEach(function(w, i){ + if (! w.$walls) return + w.color(color) + }) } + Wall.prototype.stroke_colors = function(){ + var color = "#fff" + var siblings = this.siblings() + siblings.forEach(function(w, i){ + if (! w.$walls) return + w.color(color) + if (i == 0) { + w.$walls.css("border-left", "1px solid #000") + } + if (i == siblings.length-1) { + w.$walls.css("border-right", "1px solid #000") + } + w.$walls.css("border-top", "1px solid #000") + w.$walls.css("border-bottom", "1px solid #000") + }) + } + return Wall })() diff --git a/public/assets/javascripts/ui/builder/BuilderInfo.js b/public/assets/javascripts/ui/builder/BuilderInfo.js index 2a7c8d9..56f1338 100644 --- a/public/assets/javascripts/ui/builder/BuilderInfo.js +++ b/public/assets/javascripts/ui/builder/BuilderInfo.js @@ -55,8 +55,6 @@ var BuilderInfo = View.extend({ this.$height.unitVal( room.height ) this.$x.unitVal( room.rect.x.a ) this.$y.unitVal( room.rect.y.a ) - - console.log(room) }, destroy: function(room){ @@ -89,12 +87,10 @@ var BuilderInfo = View.extend({ this.room.rect.y.setPosition( this.$y.unitVal() ) Rooms.clipper.update() }, - changeUnits: function(){ app.units = this.$units.val() this.$('.units').resetUnitVal() }, - changeViewHeight: function(){ window.viewHeight = this.$viewHeight.unitVal( ) }, diff --git a/public/assets/javascripts/ui/site/ProjectList.js b/public/assets/javascripts/ui/site/ProjectList.js index b72c832..d772b20 100644 --- a/public/assets/javascripts/ui/site/ProjectList.js +++ b/public/assets/javascripts/ui/site/ProjectList.js @@ -9,7 +9,6 @@ var ProjectList = View.extend({ }, initialize: function(){ -console.log("PISS") }, spinOn: function(e){ |
