Merge branch 'iso' of github.com:CartoDB/torque into iso

This commit is contained in:
Francisco Dans 2015-08-20 12:39:42 +02:00
commit c47c24dbd3

View File

@ -374,55 +374,6 @@ var cSpline = require('cardinal-spline');
}
},
drawIsolines: function(){
if (this.globalGrid.length > 0) {
var style = this._shader.getLayers()[1].getStyle({}, {zoom: 2});
var cellsY = this.globalGrid.length-1;
var contourValues = [0, 4, 8, 16, 32, 64, 128];
var ctx = this._ctx;
var res = this.options.resolution;
var startPos = this.firstTileCoords.pos;
ctx.strokeStyle = style["-isoline-line-color"] || "black";
ctx.lineWidth = style["-isoline-line-width"] || 2;
ctx.globalAlpha = style["-isoline-line-opacity"] || 0.8;
var grad = style["-isoline-line-ramp"] && this._generateGradient(style["-isoline-line-ramp"].args);
for (var c = 0; c < contourValues.length; c++) {
if(style["-isoline-line-decay"]){
var max = contourValues[contourValues.length - 1];
ctx.globalAlpha = (contourValues[c]/max)*(style["-isoline-line-opacity"] || 0.8);
}
if(grad){
ctx.strokeStyle = "rgb("+grad[4*contourValues[c]+1]+","+grad[4*contourValues[c]+2]+","+grad[4*contourValues[c]+3]+")";
}
for (var y = 0; y < cellsY; y++) {
for (var x = 0; x < this.globalGrid[y].length-1; x++){
var currentCell = [
this.globalGrid[y][x],
this.globalGrid[y][x+1],
this.globalGrid[y+1][x+1],
this.globalGrid[y+1][x]
];
var pipe = this._getPipe(currentCell, contourValues[c]);
if (pipe){
ctx.beginPath();
ctx.moveTo(res * (x + 0.5 + pipe[0][0]), res * (y + 0.5 + pipe[0][1]));
ctx.lineTo(res * (x + 0.5 + pipe[1][0]), res * (y + 0.5 + pipe[1][1]));
ctx.stroke();
if (pipe.length === 4){
ctx.beginPath();
ctx.moveTo(res * (x + 0.5 + pipe[2][0]), res * (y + 0.5 + pipe[2][1]));
ctx.lineTo(res * (x + 0.5 + pipe[3][0]), res * (y + 0.5 + pipe[3][1]));
ctx.stroke();
}
}
}
}
}
ctx.globalAlpha = 0;
}
},
_generateGradient: function(ramp){
var gradientCanvas = this._createCanvas(),
gctx = gradientCanvas.getContext('2d'),