From 6232e16002115b60b46297020dd8397e0ce1f382 Mon Sep 17 00:00:00 2001 From: Francisco Dans Date: Wed, 11 Mar 2015 18:01:38 +0100 Subject: [PATCH 1/5] replaces falsy check with greater or equal --- lib/torque/renderer/cartocss_render.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/torque/renderer/cartocss_render.js b/lib/torque/renderer/cartocss_render.js index 45c58ea..1e06259 100644 --- a/lib/torque/renderer/cartocss_render.js +++ b/lib/torque/renderer/cartocss_render.js @@ -17,7 +17,7 @@ ctx.closePath(); if (st['marker-fill']) { if (st['marker-fill-opacity'] !== undefined || st['marker-opacity'] !== undefined) { - ctx.globalAlpha = st['marker-fill-opacity'] || st['marker-opacity']; + ctx.globalAlpha = st['marker-fill-opacity'] >=0 ? st['marker-fill-opacity']: st['marker-opacity']; } ctx.fill(); } From f63b037d0edfcd72858f9363f50b3fd0cd28a8b5 Mon Sep 17 00:00:00 2001 From: Francisco Dans Date: Mon, 16 Mar 2015 17:29:48 +0100 Subject: [PATCH 2/5] sets marker-opacity as preliminary global opacity value --- lib/torque/renderer/cartocss_render.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/torque/renderer/cartocss_render.js b/lib/torque/renderer/cartocss_render.js index 1e06259..9e5e2a5 100644 --- a/lib/torque/renderer/cartocss_render.js +++ b/lib/torque/renderer/cartocss_render.js @@ -23,7 +23,7 @@ } // stroke - ctx.globalAlpha = 1.0; + ctx.globalAlpha = st['marker-opacity'] >=0 ? st['marker-opacity']: 1; if (st['marker-line-color'] && st['marker-line-width'] && st['marker-line-width'] > LINEWIDTH_MIN_VALUE) { if (st['marker-line-opacity'] !== undefined) { ctx.globalAlpha = st['marker-line-opacity']; From 131f116487c553bc2312983521618ffad66610a2 Mon Sep 17 00:00:00 2001 From: Francisco Dans Date: Tue, 17 Mar 2015 11:30:08 +0100 Subject: [PATCH 3/5] prioritizes marker-opacity --- lib/torque/renderer/cartocss_render.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/torque/renderer/cartocss_render.js b/lib/torque/renderer/cartocss_render.js index 9e5e2a5..5d8440b 100644 --- a/lib/torque/renderer/cartocss_render.js +++ b/lib/torque/renderer/cartocss_render.js @@ -15,18 +15,22 @@ ctx.beginPath(); ctx.arc(0, 0, pixel_size, 0, TAU, true, true); ctx.closePath(); + if (st['marker-fill']) { - if (st['marker-fill-opacity'] !== undefined || st['marker-opacity'] !== undefined) { - ctx.globalAlpha = st['marker-fill-opacity'] >=0 ? st['marker-fill-opacity']: st['marker-opacity']; + if (st['marker-opacity'] !== undefined || st['marker-fill-opacity'] !== undefined ) { + ctx.globalAlpha = st['marker-opacity'] >=0 ? st['marker-opacity']: st['marker-fill-opacity']; + } + + if (ctx.globalAlpha > 0) { + ctx.fill(); } - ctx.fill(); } // stroke ctx.globalAlpha = st['marker-opacity'] >=0 ? st['marker-opacity']: 1; if (st['marker-line-color'] && st['marker-line-width'] && st['marker-line-width'] > LINEWIDTH_MIN_VALUE) { - if (st['marker-line-opacity'] !== undefined) { - ctx.globalAlpha = st['marker-line-opacity']; + if (st['marker-opacity'] !== undefined || st['marker-line-opacity'] !== undefined) { + ctx.globalAlpha = st['marker-opacity'] >=0 ? st['marker-opacity']: st['marker-line-opacity']; } if (st['marker-line-width'] !== undefined) { ctx.lineWidth = st['marker-line-width']; From a244fa183cd6f78f0cd8dcc518a37ab9abde4ad9 Mon Sep 17 00:00:00 2001 From: Francisco Dans Date: Tue, 17 Mar 2015 11:44:44 +0100 Subject: [PATCH 4/5] passes logic upstairs --- lib/torque/renderer/cartocss_render.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/torque/renderer/cartocss_render.js b/lib/torque/renderer/cartocss_render.js index 5d8440b..3994b0c 100644 --- a/lib/torque/renderer/cartocss_render.js +++ b/lib/torque/renderer/cartocss_render.js @@ -16,11 +16,11 @@ ctx.arc(0, 0, pixel_size, 0, TAU, true, true); ctx.closePath(); + if (st['marker-opacity'] !== undefined ) st['marker-fill-opacity'] = st['marker-line-opacity'] = st['marker-opacity']; + if (st['marker-fill']) { - if (st['marker-opacity'] !== undefined || st['marker-fill-opacity'] !== undefined ) { - ctx.globalAlpha = st['marker-opacity'] >=0 ? st['marker-opacity']: st['marker-fill-opacity']; - } - + ctx.globalAlpha = st['marker-fill-opacity'] >= 0? st['marker-fill-opacity']: 1; + if (ctx.globalAlpha > 0) { ctx.fill(); } @@ -29,9 +29,7 @@ // stroke ctx.globalAlpha = st['marker-opacity'] >=0 ? st['marker-opacity']: 1; if (st['marker-line-color'] && st['marker-line-width'] && st['marker-line-width'] > LINEWIDTH_MIN_VALUE) { - if (st['marker-opacity'] !== undefined || st['marker-line-opacity'] !== undefined) { - ctx.globalAlpha = st['marker-opacity'] >=0 ? st['marker-opacity']: st['marker-line-opacity']; - } + ctx.globalAlpha = st['marker-line-opacity'] >= 0? st['marker-line-opacity']: 1; if (st['marker-line-width'] !== undefined) { ctx.lineWidth = st['marker-line-width']; } From 219a3f588896fbc9d019fd7ed5536d93aaa5fd5d Mon Sep 17 00:00:00 2001 From: Francisco Dans Date: Tue, 17 Mar 2015 11:48:19 +0100 Subject: [PATCH 5/5] removes unnecessary globalalpha set --- lib/torque/renderer/cartocss_render.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/torque/renderer/cartocss_render.js b/lib/torque/renderer/cartocss_render.js index 3994b0c..a6acad1 100644 --- a/lib/torque/renderer/cartocss_render.js +++ b/lib/torque/renderer/cartocss_render.js @@ -27,7 +27,6 @@ } // stroke - ctx.globalAlpha = st['marker-opacity'] >=0 ? st['marker-opacity']: 1; if (st['marker-line-color'] && st['marker-line-width'] && st['marker-line-width'] > LINEWIDTH_MIN_VALUE) { ctx.globalAlpha = st['marker-line-opacity'] >= 0? st['marker-line-opacity']: 1; if (st['marker-line-width'] !== undefined) {