optimizes drawnTemp a bit more
This commit is contained in:
parent
9479b214fa
commit
d048652ba9
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user