summaryrefslogtreecommitdiff
path: root/public
diff options
context:
space:
mode:
authorJulie Lala <jules@okfoc.us>2014-06-20 01:40:43 -0400
committerJulie Lala <jules@okfoc.us>2014-06-20 01:40:43 -0400
commit1a1009d5cbfb1deb7cc110bacf3fd76236cf25a9 (patch)
tree5ee025477a0ccc54e2ec11c71bdac47d2092ad1e /public
parentbefeb2ed9b7f7086ec0861cbfe4ab6450e1987af (diff)
resize based on magnitude..
Diffstat (limited to 'public')
-rw-r--r--public/assets/javascripts/rectangles/engine/scenery/resize.js14
-rw-r--r--public/assets/javascripts/rectangles/models/rect.js3
-rw-r--r--public/assets/javascripts/rectangles/models/vec2.js3
3 files changed, 14 insertions, 6 deletions
diff --git a/public/assets/javascripts/rectangles/engine/scenery/resize.js b/public/assets/javascripts/rectangles/engine/scenery/resize.js
index 33efd05..50c97bd 100644
--- a/public/assets/javascripts/rectangles/engine/scenery/resize.js
+++ b/public/assets/javascripts/rectangles/engine/scenery/resize.js
@@ -161,19 +161,21 @@ Scenery.resize = new function(){
var x_sign = selected_dot.side & LEFT ? -1 : selected_dot.side & RIGHT ? 1 : 0
var y_sign = selected_dot.side & TOP ? -1 : selected_dot.side & BOTTOM ? 1 : 0
-
- var translation = new vec2( x_sign * cursor.x.magnitude() * cursor_amp, y_sign * cursor.y.magnitude() * cursor_amp )
- // resize using scale here instead of width and height
+ var mag = cursor.magnitude()
+
+ // fix resizing here
+// obj.mx.scale = obj.media.scale
+// var translation = new vec2( x_sign * cursor.x.magnitude() * cursor_amp, y_sign * cursor.y.magnitude() * cursor_amp )
if (selected_dot.side & LEFT_RIGHT) {
// obj.mx.width = dimensions.a + translation.a
- obj.mx.x = position.a + x_sign * cos(rotationY) * translation.a/2 * obj.mx.scale
- obj.mx.z = position.c + x_sign * sin(rotationY) * translation.a/2 * obj.mx.scale
+ obj.mx.x = position.a + x_sign * cos(rotationY) * mag/2 * obj.mx.scale
+ obj.mx.z = position.c + x_sign * sin(rotationY) * mag/2 * obj.mx.scale
}
if (selected_dot.side & TOP_BOTTOM) {
// obj.mx.height = dimensions.b + translation.b
- obj.mx.y = position.b - y_sign * translation.b/2 * obj.mx.scale
+ obj.mx.y = position.b - y_sign * mag/2 * obj.mx.scale
}
// bounds = obj.wall.bounds_for(dimensions)
diff --git a/public/assets/javascripts/rectangles/models/rect.js b/public/assets/javascripts/rectangles/models/rect.js
index cb14e66..0bab0e4 100644
--- a/public/assets/javascripts/rectangles/models/rect.js
+++ b/public/assets/javascripts/rectangles/models/rect.js
@@ -25,6 +25,9 @@ window.Rect = (function(){
Rect.prototype.area = function(){
return this.x.length() * this.y.length()
}
+ Rect.prototype.magnitude = function(){
+ return dist(this.x.a, this.y.a, this.x.b, this.y.b)
+ }
Rect.prototype.mul = function(n){
this.x.mul(n)
diff --git a/public/assets/javascripts/rectangles/models/vec2.js b/public/assets/javascripts/rectangles/models/vec2.js
index e56a010..5cdd54c 100644
--- a/public/assets/javascripts/rectangles/models/vec2.js
+++ b/public/assets/javascripts/rectangles/models/vec2.js
@@ -8,6 +8,9 @@ vec2.prototype.magnitude = function(){
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)
}