summaryrefslogtreecommitdiff
path: root/public/assets/javascripts/rectangles/models/surface.js
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2014-08-18 18:42:41 -0400
committerJules Laplace <jules@okfoc.us>2014-08-18 18:42:41 -0400
commit559799f707a8c7fbd0d6296dfbce81ac6f9b376a (patch)
treeb78ada84ac441413cd552d0b5875c63efd5c151f /public/assets/javascripts/rectangles/models/surface.js
parent0ce017601ea3393f6ea1d0cab105737a6e460138 (diff)
translation tests
Diffstat (limited to 'public/assets/javascripts/rectangles/models/surface.js')
-rw-r--r--public/assets/javascripts/rectangles/models/surface.js23
1 files changed, 21 insertions, 2 deletions
diff --git a/public/assets/javascripts/rectangles/models/surface.js b/public/assets/javascripts/rectangles/models/surface.js
index 0e0926f..3f43ec2 100644
--- a/public/assets/javascripts/rectangles/models/surface.js
+++ b/public/assets/javascripts/rectangles/models/surface.js
@@ -100,12 +100,28 @@
if (top_edge > 0) {
delta.b -= top_edge
}
+
+ return delta
}
Surface.prototype.translate = function (old_bounds, dimension, position, delta) {
+
this.clamp_delta( this.bounds, dimension, position, delta )
+
+ var new_delta = delta.clone()
+ if (this.clamp_delta(old_bounds, dimension, position, new_delta).eq(delta)) {
+ return old_bounds
+ }
+
+ var center_index = this.index_for_x( position.a + dimension.a/2 + delta.a, 0 )
+ var new_bounds = this.bounds_at_index_with_dimensions(center_index, dimension)
+
+ this.clamp_delta(new_bounds, dimension, position, delta)
- var left_side = this.index_for_x( position.a + delta.a, 0 )
+ return new_bounds
+
+/*
+ var left_side = this.index_for_x( position.a + delta.a, 0 )
var right_side = this.index_for_x( position.a + dimension.a + delta.a, left_side )
var bounds = this.sides[left_side].clone()
@@ -126,11 +142,12 @@
this.clamp_delta(bounds, dimension, position, delta)
return bounds
+*/
}
Surface.prototype.index_for_x = function(x, min_i){
min_i = min_i || 0
- if (x < 0 || x > width) {
+ if (x < 0 || x > this.width) {
return -1
}
for (var i = min_i; i < this.faces.length; i++) {
@@ -162,6 +179,8 @@
else if (bounds.width() < width) {
intersection = bounds.y.intersection(face.y)
if (intersection.length() < height) {
+ // not totally sure if we can clobber the bounds here since this would prevent
+ // us from looking right later
break
}
else {