From eda12d207bad89f57a9eefa37e5564b8c2ed715d Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Sun, 31 Mar 2019 17:44:08 +0100 Subject: [PATCH] Make greyscale wms slightly lighter (more suitable for backgrounds) --- worldmap.js | 2 +- worldmap/leaflet/TileLayer.GrayscaleWMS.js | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/worldmap.js b/worldmap.js index cb15b19..3f3b2d9 100644 --- a/worldmap.js +++ b/worldmap.js @@ -142,7 +142,7 @@ module.exports = function(RED) { client.on('close', function() { delete clients[client.id]; node.status({fill:"green",shape:"ring",text:"connected "+Object.keys(clients).length,_sessionid:client.id}); - node.send({payload:{action:"disconnect", clients:Object.keys(clients).length}, topic:"worldmap", _sessionid:client.id}); + node.send({payload:{action:"disconnect", clients:Object.keys(clients).length}, topic:node.path.substr(1), _sessionid:client.id}); }); } diff --git a/worldmap/leaflet/TileLayer.GrayscaleWMS.js b/worldmap/leaflet/TileLayer.GrayscaleWMS.js index d6c42bc..ed0583d 100644 --- a/worldmap/leaflet/TileLayer.GrayscaleWMS.js +++ b/worldmap/leaflet/TileLayer.GrayscaleWMS.js @@ -35,8 +35,9 @@ L.TileLayer.GrayWMS = L.TileLayer.WMS.extend({ var imgd = ctx.getImageData(0, 0, this._layer.options.tileSize, this._layer.options.tileSize); var pix = imgd.data; for (var i = 0, n = pix.length; i < n; i += 4) { - pix[i] = pix[i + 1] = pix[i + 2] = (3 * pix[i] + 4 * pix[i + 1] + pix[i + 2]) / 8; - //pix[i] = pix[i + 1] = pix[i + 2] = (2 * pix[i] + 3 * pix[i + 1] + 3 * pix[i + 2]) / 6; + //pix[i] = pix[i + 1] = pix[i + 2] = (3 * pix[i] + 4 * pix[i + 1] + pix[i + 2]) / 8; + // Lighten the scale slightly to make markers more obvious + pix[i] = pix[i + 1] = pix[i + 2] = (3 * pix[i] + 4 * pix[i + 1] + pix[i + 2]) / 8 * 3 / 4 + 64; } ctx.putImageData(imgd, 0, 0); this.removeAttribute("crossorigin");