From 17f2644e3d885c8aef170023c84933e5bd888402 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Tue, 10 May 2016 15:58:52 -0400 Subject: more convenient canvas.get syntax.. --- js/matrix.js | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'js/matrix.js') diff --git a/js/matrix.js b/js/matrix.js index 275e6b6..de59e17 100644 --- a/js/matrix.js +++ b/js/matrix.js @@ -151,6 +151,13 @@ Matrix.prototype.getCell = function(x,y){ if (this.aa[y] && this.aa[y][x]) return this.aa[y][x] else return null } +Matrix.prototype.get = function(x,y){ + y = floor(mod(y || 0, this.h)) + x = floor(mod(x || 0, this.w)) + if (this.aa[y] && this.aa[y][x]) return this.aa[y][x] + else return null +} + Matrix.prototype.resize = function(w,h){ w = w || canvas.w h = h || canvas.h -- cgit v1.2.3-70-g09d2