diff options
| author | Jules Laplace <jules@okfoc.us> | 2014-10-31 16:03:31 -0400 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2014-10-31 16:03:31 -0400 |
| commit | d94ab5ee18e321f28df32005add4c11946d5d922 (patch) | |
| tree | 562997584cefa7a169fe167026da18847d91786e /public/assets/javascripts/rectangles/models | |
| parent | f369426f5054149d7ca7ef493b94289009b658f7 (diff) | |
| parent | f599c7edf7e635241e839fc024e4016ae0dcc210 (diff) | |
merge
Diffstat (limited to 'public/assets/javascripts/rectangles/models')
| -rw-r--r-- | public/assets/javascripts/rectangles/models/rect.js | 6 | ||||
| -rw-r--r-- | public/assets/javascripts/rectangles/models/surface.js | 9 | ||||
| -rw-r--r-- | public/assets/javascripts/rectangles/models/vec2.js | 5 |
3 files changed, 19 insertions, 1 deletions
diff --git a/public/assets/javascripts/rectangles/models/rect.js b/public/assets/javascripts/rectangles/models/rect.js index 00f2c55..c667cf5 100644 --- a/public/assets/javascripts/rectangles/models/rect.js +++ b/public/assets/javascripts/rectangles/models/rect.js @@ -169,6 +169,12 @@ var s = "[" + this.x.toString() + " " + this.y.toString() + "] " + sides return s } + Rect.prototype.exactString = function(){ + var sides = sidesToString(this.sides) + var s = "[" + this.x.exactString() + " " + this.y.exactString() + "] " + sides + return s + } + Rect.prototype.serialize = function(){ return { x: this.x.serialize(), y: this.y.serialize() } } diff --git a/public/assets/javascripts/rectangles/models/surface.js b/public/assets/javascripts/rectangles/models/surface.js index 3a6c449..fc4aae4 100644 --- a/public/assets/javascripts/rectangles/models/surface.js +++ b/public/assets/javascripts/rectangles/models/surface.js @@ -154,6 +154,15 @@ } return -1 } + Surface.prototype.face_for_x = function(x, min_i){ + min_i = min_i || 0 + for (var i = min_i; i < this.faces.length; i++) { + if (this.faces[i].x.contains(x)) { + return this.faces[i] + } + } + return null + } Surface.prototype.bounds_at_index_with_dimensions = function(index, dimensions){ var faces = this.faces diff --git a/public/assets/javascripts/rectangles/models/vec2.js b/public/assets/javascripts/rectangles/models/vec2.js index 49613c3..f28df54 100644 --- a/public/assets/javascripts/rectangles/models/vec2.js +++ b/public/assets/javascripts/rectangles/models/vec2.js @@ -200,7 +200,10 @@ } vec2.prototype.toString = function(){ - return "[" + ~~this.a + " " + ~~this.b + "]" + return "[" + round(this.a) + " " + round(this.b) + "]" + } + vec2.prototype.exactString = function(){ + return "[" + this.a + " " + this.b + "]" } vec2.prototype.serialize = function(){ return [ ~~this.a, ~~this.b ] |
