diff --git a/lib/torque/renderer/ball.js b/lib/torque/renderer/ball.js index 8c6d739..a46846b 100644 --- a/lib/torque/renderer/ball.js +++ b/lib/torque/renderer/ball.js @@ -12,7 +12,7 @@ function BallRenderer(thecanvas){ this.size = this.width * this.height; this.pointLayer = new Uint8ClampedArray(this.size * 4); this.radius = 30; - this.drawnTemp = []; + this.drawnTemp = {}; this.prof = 0; this.gradient = {}; } @@ -51,19 +51,18 @@ BallRenderer.prototype = { return Math.sqrt( xs + ys ); } // Assumes xi is on the left and xf is on the right - var xPointer = xi; if(typeof this.drawnTemp[yi] === "undefined"){ - while (xPointer <= xf){ - var alpha = this.map_range(lineDistance(xPointer, yi), 0, this.radius, 30, 0); - this.addPoint(xPointer, yi, alpha); - xPointer ++; + while (xi <= xf){ + var alpha = this.map_range(lineDistance(xi, yi), 0, this.radius, 30, 0); + this.addPoint(xi, yi, alpha); + xi ++; } this.drawnTemp[yi]=true; } }, contour: function(granularity){ var step = 255/granularity; - var i = 0, a = new Uint8ClampedArray(granularity+1), c=0; + var i = 1, a = new Uint8ClampedArray(granularity+1), c=0; while (i<255){ a[c] = i; i += step;