From f6424c4756de2045648de0980de14a32b0126df7 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Thu, 17 Apr 2014 12:27:51 -0400 Subject: scale map --- assets/javascripts/rectangles/models/vec2.js | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'assets/javascripts/rectangles/models/vec2.js') diff --git a/assets/javascripts/rectangles/models/vec2.js b/assets/javascripts/rectangles/models/vec2.js index 4e2ad36..3105fec 100644 --- a/assets/javascripts/rectangles/models/vec2.js +++ b/assets/javascripts/rectangles/models/vec2.js @@ -28,23 +28,28 @@ vec2.prototype.eq = function(v){ 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.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 -- cgit v1.2.3-70-g09d2