Merge pull request #254 from CartoDB/comp-ops

Allows all possible Canvas composite operations
This commit is contained in:
Francisco Dans 2016-02-17 20:03:44 +01:00
commit 30bd226d71

View File

@ -20,18 +20,34 @@ var Filters = require('./torque_filters');
].join('\n');
var COMP_OP_TO_CANVAS = {
"difference": "difference",
"src": 'source-over',
"exclusion": "exclusion",
"dst": "destination-in",
"multiply": "multiply",
"contrast": "contrast",
"src-over": 'source-over',
"screen": "screen",
"invert": "invert",
"dst-over": 'destination-over',
"overlay": "overlay",
"invert-rgb": "invert",
"src-in": 'source-in',
"dst-in": 'destination-in',
"src-out": 'source-out',
"dst-out": 'destination-out',
"src-atop": 'source-atop',
"dst-atop": 'destination-atop',
"xor": 'xor',
"darken": 'darken',
"lighten": 'lighten'
"dst-in": 'destination-in',
"lighten": 'lighten',
"src-out": 'source-out',
"color-dodge": "color-dodge",
"hue":"hue",
"dst-out": 'destination-out',
"color-burn":"color-burn",
"saturation":"saturation",
"src-atop": 'source-atop',
"hard-light":"hard-light",
"color":"color",
"dst-atop": 'destination-atop',
"soft-light":"soft-light",
"xor": 'xor'
}
function compop2canvas(compop) {
@ -73,7 +89,7 @@ var Filters = require('./torque_filters');
var ctx = this._ctx;
ctx.setTransform(1, 0, 0, 1, 0, 0);
var compop = this._Map['comp-op']
ctx.globalCompositeOperation = compop2canvas(compop);
ctx.globalCompositeOperation = compop2canvas(compop) || compop;
ctx.fillStyle = color;
ctx.fillRect(0, 0, canvas.width, canvas.height);
}