From ccdbdc82512fa0f5dcbc64cd048d9384fe3bf72b Mon Sep 17 00:00:00 2001 From: Matthias Wirth Date: Wed, 15 Feb 2023 09:38:53 +0100 Subject: [PATCH] put out svgs for /?iconTest (as json object on js console) --- html/markers.js | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/html/markers.js b/html/markers.js index ec29126..054b8f0 100644 --- a/html/markers.js +++ b/html/markers.js @@ -1310,7 +1310,7 @@ function getBaseMarker(category, typeDesignator, typeDescription, wtc, addrtype, return ['unknown', 1]; } -function svgShapeToURI(shape, fillColor, strokeColor, strokeWidth, scale){ +function svgShapeToSVG(shape, fillColor, strokeColor, strokeWidth, scale) { scale = scale ? scale : 1; strokeWidth *= (shape.strokeScale ? shape.strokeScale : 1); @@ -1320,7 +1320,7 @@ function svgShapeToURI(shape, fillColor, strokeColor, strokeWidth, scale){ if (!shape.path) { let svg = shape.svg.replace('fillColor', fillColor).replace('strokeColor', strokeColor).replace('strokeWidth', strokeWidth); svg = svg.replace('SIZE', 'width="' + wi + 'px" height="' + he + 'px"'); - return "data:image/svg+xml;base64," + btoa(svg); + return svg; } @@ -1348,6 +1348,11 @@ function svgShapeToURI(shape, fillColor, strokeColor, strokeWidth, scale){ svg += ''; + return svg; +} + +function svgShapeToURI(shape, fillColor, strokeColor, strokeWidth, scale){ + let svg = svgShapeToSVG(shape, fillColor, strokeColor, strokeWidth, scale); return "data:image/svg+xml;base64," + btoa(svg); } @@ -1387,8 +1392,11 @@ function iconTest() { mapdiv.innerHTML = '
'; let can = document.getElementById('can'); let con = can.getContext('2d'); - for (let i in shapes) { - let shape = shapes[i]; + + let svgJson = {}; + + for (let shapeName in shapes) { + let shape = shapes[shapeName]; if (getSpriteY(shape) / iconSize >= height) { console.log("make the canvas BIGGER!"); mapdiv.innerHTML = ''; @@ -1404,20 +1412,25 @@ function iconTest() { else offX = diff / 2; - let svg = svgShapeToURI(shape, '#FFFFFF', '#000000', 0.75, scale); let img = document.createElement('img'); img.onload = function () { con.drawImage(this, getSpriteX(shape) * glIconSize + offX, getSpriteY(shape) * glIconSize + offY); }; - img.src = svg; + let svgURI = svgShapeToURI(shape, '#FFFFFF', '#000000', 0.75, scale); + img.src = svgURI; + + let svg = svgShapeToSVG(shape, '#FFFFFF', '#000000', 0.75, 1.4); + svgJson[shapeName] = svg; if (usp.has('grid')) { - let svg = svgShapeToURI(refCross, '#FFFFFF', '#000000', 0.75, 1); let img = document.createElement('img'); img.onload = function () { con.drawImage(this, getSpriteX(shape) * glIconSize, getSpriteY(shape) * glIconSize); }; - img.src = svg; + let svgURI = svgShapeToURI(refCross, '#FFFFFF', '#000000', 0.75, 1); + img.src = svgURI; } } + + console.log(svgJson); }