shrinks isopleth function
This commit is contained in:
parent
5cdda8d8c7
commit
ea4445ab8d
@ -175,12 +175,6 @@ BallRenderer.prototype = {
|
||||
var y = (index - 4 * x) / (4 * this.width);
|
||||
return [x,y];
|
||||
},
|
||||
// Clockwise. Again, there definitely is a better way.
|
||||
getNeighbors: function(index){
|
||||
var n = index - this.chWidth;
|
||||
var s = index + this.chWidth;
|
||||
return [n, n + 4, index + 4, s + 4, s, s - 4, index - 4, n -4];
|
||||
},
|
||||
isEmpty: function(layer) {
|
||||
for (var i = 0; i<layer.length; i+=4){
|
||||
if(layer[i+3] > 0) return false;
|
||||
@ -230,37 +224,21 @@ BallRenderer.prototype = {
|
||||
}
|
||||
},
|
||||
isopleth: function(){
|
||||
var iso = this.createArray();
|
||||
var contour = this.contourLayer;
|
||||
var eq = false;
|
||||
for (var i = 0, len = contour.length; i<len; i+=4){
|
||||
if(!eq){
|
||||
var alpha = contour[i + 3];
|
||||
if (alpha > 20 && alpha < 255){
|
||||
var neighbors = this.getNeighbors(i);
|
||||
var refCol = contour[neighbors[0]+3];
|
||||
for (var n = 1, ln = neighbors.length; n<ln; ++n){
|
||||
if (contour[neighbors[n]+3] !== refCol) break;
|
||||
if (n === ln-1) eq = true;
|
||||
}
|
||||
if(!eq){
|
||||
for (var n = 0, ln = neighbors.length; n<ln; ++n){
|
||||
var index = neighbors[n];
|
||||
if(index>0 && (contour[index+3] === 0 || contour[index+3] !== contour[i+3])){
|
||||
iso[index + 3] = contour[i+3];
|
||||
iso[index] = 153;
|
||||
iso[index + 1] = 60;
|
||||
iso[index + 2] = 243;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
eq = false;
|
||||
if(typeof this.isoplethLayer === 'undefined') this.isoplethLayer = new Uint8Array(this.size * 4);
|
||||
for (var i = 0, len = this.contourLayer.length; i<len; i+=4){
|
||||
var alpha = this.contourLayer[i + 3];
|
||||
if (alpha > 20 && alpha < 255){
|
||||
var n = i - this.chWidth,
|
||||
s = i + this.chWidth,
|
||||
neighbors = [n, n + 4, i + 4, s + 4, s, s - 4, i - 4, n -4];
|
||||
for (var n = 0, ln = neighbors.length; n<ln; ++n){
|
||||
var index = neighbors[n];
|
||||
if(index>0 && (this.contourLayer[index+3] === 0 || this.contourLayer[index+3] !== this.contourLayer[i+3])){
|
||||
this.isoplethLayer[index + 3] = Math.min(this.contourLayer[i+3],255);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
this.isoplethLayer = iso;
|
||||
},
|
||||
|
||||
heatmap: function (gradient){
|
||||
|
Loading…
Reference in New Issue
Block a user