From 01b30d18cae38d144537a71f1447635baa1da767 Mon Sep 17 00:00:00 2001 From: Francisco Dans Date: Mon, 18 Jan 2016 10:29:15 +0100 Subject: [PATCH 1/6] adds pos to parameters --- lib/torque/leaflet/torque.js | 2 +- lib/torque/renderer/point.js | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/torque/leaflet/torque.js b/lib/torque/leaflet/torque.js index e6828c4..25215d5 100644 --- a/lib/torque/leaflet/torque.js +++ b/lib/torque/leaflet/torque.js @@ -244,7 +244,7 @@ L.TorqueLayer = L.CanvasLayer.extend({ // all the points this.renderer._ctx.drawImage(tile._tileCache, 0, 0); } else { - this.renderer.renderTile(tile, this.keys); + this.renderer.renderTile(tile, this.keys, pos); } } } diff --git a/lib/torque/renderer/point.js b/lib/torque/renderer/point.js index 53ed888..25cbe55 100644 --- a/lib/torque/renderer/point.js +++ b/lib/torque/renderer/point.js @@ -172,7 +172,7 @@ var Filters = require('./torque_filters'); // // renders all the layers (and frames for each layer) from cartocss // - renderTile: function(tile, keys, callback) { + renderTile: function(tile, keys, pos) { if (this._iconsToLoad > 0) { this.on('allIconsLoaded', function() { this.renderTile.apply(this, [tile, keys, callback]); @@ -196,15 +196,13 @@ var Filters = require('./torque_filters'); var frame = layer.frames()[fr]; var fr_sprites = sprites[frame] || (sprites[frame] = []); for (var k = 0, len = keys.length; k < len; k++) { - this._renderTile(tile, keys[k] - frame, frame, fr_sprites, layer); + this._renderTile(tile, keys[k] - frame, frame, fr_sprites, layer, undefined, pos); } } } } prof.end(true); - - return callback && callback(null); }, _createCanvas: function() { @@ -248,7 +246,7 @@ var Filters = require('./torque_filters'); // renders a tile in the canvas for key defined in // the torque tile // - _renderTile: function(tile, key, frame_offset, sprites, shader, shaderVars) { + _renderTile: function(tile, key, frame_offset, sprites, shader, shaderVars, pos) { if (!this._canvas) return; var prof = Profiler.metric('torque.renderer.point.renderTile').start(); From 40044e5448d81b414496d235b4f96e10280bfacc Mon Sep 17 00:00:00 2001 From: Francisco Dans Date: Mon, 18 Jan 2016 10:29:44 +0100 Subject: [PATCH 2/6] fires event when point added --- lib/torque/renderer/point.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/torque/renderer/point.js b/lib/torque/renderer/point.js index 25cbe55..bc339a3 100644 --- a/lib/torque/renderer/point.js +++ b/lib/torque/renderer/point.js @@ -276,6 +276,7 @@ var Filters = require('./torque_filters'); var x = tile.x[posIdx]- (sp.width >> 1) + anchor; var y = tileMax - tile.y[posIdx] + anchor; // flip mercator ctx.drawImage(sp, x, y - (sp.height >> 1)); + this.fire("pointAdded", {x: pos.x + x, y: pos.y + y, value: c}); } } } From 3e93e8f7530c8041507bbbf5d2f977905d4773cf Mon Sep 17 00:00:00 2001 From: Francisco Dans Date: Tue, 9 Feb 2016 12:20:11 +0100 Subject: [PATCH 3/6] uses specified compop if it isn't in carto mapping --- lib/torque/renderer/point.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/torque/renderer/point.js b/lib/torque/renderer/point.js index bc339a3..ee5d1fb 100644 --- a/lib/torque/renderer/point.js +++ b/lib/torque/renderer/point.js @@ -73,7 +73,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); } From 1defdcba34936ae178cadf58ea11bdc60d4af653 Mon Sep 17 00:00:00 2001 From: Francisco Dans Date: Tue, 9 Feb 2016 12:56:01 +0100 Subject: [PATCH 4/6] adds more comprehensive compop mappings --- lib/torque/renderer/point.js | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/lib/torque/renderer/point.js b/lib/torque/renderer/point.js index ee5d1fb..b5cfa60 100644 --- a/lib/torque/renderer/point.js +++ b/lib/torque/renderer/point.js @@ -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) { From 12816745b50ca6016ce4f61122e5a85b85bdeda7 Mon Sep 17 00:00:00 2001 From: Francisco Dans Date: Thu, 11 Feb 2016 17:44:54 +0100 Subject: [PATCH 5/6] reverts mix from another branch --- lib/torque/renderer/point.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/torque/renderer/point.js b/lib/torque/renderer/point.js index b5cfa60..2a5fad1 100644 --- a/lib/torque/renderer/point.js +++ b/lib/torque/renderer/point.js @@ -188,7 +188,7 @@ var Filters = require('./torque_filters'); // // renders all the layers (and frames for each layer) from cartocss // - renderTile: function(tile, keys, pos) { + renderTile: function(tile, keys, callback) { if (this._iconsToLoad > 0) { this.on('allIconsLoaded', function() { this.renderTile.apply(this, [tile, keys, callback]); @@ -212,13 +212,15 @@ var Filters = require('./torque_filters'); var frame = layer.frames()[fr]; var fr_sprites = sprites[frame] || (sprites[frame] = []); for (var k = 0, len = keys.length; k < len; k++) { - this._renderTile(tile, keys[k] - frame, frame, fr_sprites, layer, undefined, pos); + this._renderTile(tile, keys[k] - frame, frame, fr_sprites, layer); } } } } prof.end(true); + + return callback && callback(null); }, _createCanvas: function() { @@ -262,7 +264,7 @@ var Filters = require('./torque_filters'); // renders a tile in the canvas for key defined in // the torque tile // - _renderTile: function(tile, key, frame_offset, sprites, shader, shaderVars, pos) { + _renderTile: function(tile, key, frame_offset, sprites, shader, shaderVars) { if (!this._canvas) return; var prof = Profiler.metric('torque.renderer.point.renderTile').start(); @@ -292,7 +294,6 @@ var Filters = require('./torque_filters'); var x = tile.x[posIdx]- (sp.width >> 1) + anchor; var y = tileMax - tile.y[posIdx] + anchor; // flip mercator ctx.drawImage(sp, x, y - (sp.height >> 1)); - this.fire("pointAdded", {x: pos.x + x, y: pos.y + y, value: c}); } } } From 2fe9c737cdfe12f01562bfc5d5dd2f256c369184 Mon Sep 17 00:00:00 2001 From: Francisco Dans Date: Wed, 17 Feb 2016 19:57:56 +0100 Subject: [PATCH 6/6] removes pos from rendertile args --- lib/torque/leaflet/torque.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/torque/leaflet/torque.js b/lib/torque/leaflet/torque.js index 25215d5..e6828c4 100644 --- a/lib/torque/leaflet/torque.js +++ b/lib/torque/leaflet/torque.js @@ -244,7 +244,7 @@ L.TorqueLayer = L.CanvasLayer.extend({ // all the points this.renderer._ctx.drawImage(tile._tileCache, 0, 0); } else { - this.renderer.renderTile(tile, this.keys, pos); + this.renderer.renderTile(tile, this.keys); } } }