Merge pull request #9 from CartoDB/image-filters-fixes
Image filters fixes
This commit is contained in:
commit
885849fe82
@ -25,7 +25,10 @@ var _mapnik_reference_latest = {
|
||||
["x-gradient", 0],
|
||||
["y-gradient", 0],
|
||||
["invert", 0],
|
||||
["sharpen", 0]
|
||||
["sharpen", 0],
|
||||
["colorize-alpha", -1],
|
||||
["color-to-alpha", 1],
|
||||
["scale-hsla", 8]
|
||||
],
|
||||
"doc": "A list of image filters."
|
||||
},
|
||||
@ -160,7 +163,10 @@ var _mapnik_reference_latest = {
|
||||
["x-gradient", 0],
|
||||
["y-gradient", 0],
|
||||
["invert", 0],
|
||||
["sharpen", 0]
|
||||
["sharpen", 0],
|
||||
["colorize-alpha", -1],
|
||||
["color-to-alpha", 1],
|
||||
["scale-hsla", 8]
|
||||
],
|
||||
"doc": "A list of image filters."
|
||||
},
|
||||
|
@ -37,6 +37,11 @@ tree.Value.prototype = {
|
||||
} else if (val.is === 'field') {
|
||||
// replace [variable] by ctx['variable']
|
||||
v = v.replace(/\[(.*)\]/g, "data['$1']");
|
||||
}else if (val.is === 'call') {
|
||||
v = JSON.stringify({
|
||||
name: val.name,
|
||||
args: val.args
|
||||
})
|
||||
}
|
||||
return "_value = " + v + ";";
|
||||
}
|
||||
|
@ -74,6 +74,17 @@ describe('RenderingJS', function() {
|
||||
assert(layer0.getSymbolizers()[1] === 'line');
|
||||
});
|
||||
|
||||
it ("colorize should return a list of colours in same order", function() {
|
||||
var style = '#test { image-filters: colorize-alpha(blue, cyan, green, yellow, orange, red); }';
|
||||
var shader = (new carto.RendererJS({ debug: true })).render(style);
|
||||
var layer0 = shader.getLayers()[0];
|
||||
var st = layer0.getStyle({ value: 1 }, {"frame-offset": 0, "zoom": 3});
|
||||
var expectedColours = [[0, 0, 255], [0, 255, 255], [0, 128, 0], [255, 255, 0], [255, 165, 0], [255, 0, 0]];
|
||||
for (var i = 0; i < st["image-filters"].args; i++){
|
||||
assert (st["image-filters"].args[i].rgb === expectedColours[i]);
|
||||
}
|
||||
});
|
||||
|
||||
it ("should return list of marker-files", function(){
|
||||
var css = [
|
||||
'Map {',
|
||||
|
Loading…
Reference in New Issue
Block a user