adds colorization for whole canvas

This commit is contained in:
Francisco Dans 2015-01-20 18:22:58 +01:00
parent 38f0e3d814
commit 24413a706f

View File

@ -2,6 +2,7 @@ var torque = require('../');
var cartocss = require('./cartocss_render');
var Profiler = require('../profiler');
var carto = global.carto || require('carto');
var filters = require('./simpleheat');
var TAU = Math.PI * 2;
var DEFAULT_CARTOCSS = [
@ -50,10 +51,32 @@ var carto = global.carto || require('carto');
this._sprites = []; // sprites per layer
this._shader = null;
this._icons = {};
this._filters = filters(this._canvas);
this.setCartoCSS(this.options.cartocss || DEFAULT_CARTOCSS);
this.TILE_SIZE = 256;
this._style = null;
this._forcePoints = false;
this.on("allTilesRendered", function(tile){
if(this._style){
if(this._style['image-filters']){
var colorize = this._style['image-filters']
.replace("colorize-alpha(", "")
.slice(0, -1)
.replace(/ /g,'')
.split(",");
var gradient = {};
var increment = 1/colorize.length;
for (var i = 0; i < colorize.length; i++){
var key = increment * i + increment;
gradient[key] = colorize[i];
}
this._filters.gradient(gradient);
this._filters.draw(0.3);
}
}
});
}
torque.extend(PointRenderer.prototype, torque.Event, {
@ -110,6 +133,9 @@ var carto = global.carto || require('carto');
var st = shader.getStyle({
value: value
}, shaderVars);
if(this._style === null){
this._style = st;
}
var pointSize = st['marker-width'];
if (!pointSize) {
@ -169,6 +195,7 @@ var carto = global.carto || require('carto');
}
}
}
prof.end(true);
},
@ -221,6 +248,8 @@ var carto = global.carto || require('carto');
}
}
}
prof.end(true);
},