automatization of svg embedding

added shadows in SVG
This commit is contained in:
Youen Toupin 2021-10-03 23:01:38 +02:00
parent 20ab0175d3
commit 61f205d6de
6 changed files with 599 additions and 92 deletions

1
.gitignore vendored
View File

@ -183,3 +183,4 @@ local.properties
*.js.map *.js.map
/.local/ /.local/
/simulator/www/simulator.css /simulator/www/simulator.css
*.svg.ts

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 118 KiB

After

Width:  |  Height:  |  Size: 130 KiB

View File

@ -1,4 +1,6 @@
#!/bin/bash #!/bin/bash
cd src cd src
node embed.js
../node_modules/typescript/bin/tsc ../node_modules/typescript/bin/tsc
node purify.js node purify.js

View File

@ -37,8 +37,12 @@ input[type=number] {
cursor: pointer; cursor: pointer;
} }
svg g {
filter: drop-shadow( 4px 4px 3px rgba(0, 0, 0, .7));
}
.climate-zone:hover { .climate-zone:hover {
opacity: 0.5 !important; filter: brightness(1.2);
} }
svg text { svg text {

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 116 KiB

After

Width:  |  Height:  |  Size: 128 KiB

22
simulator/src/embed.js Normal file
View File

@ -0,0 +1,22 @@
let fs = require('fs')
function embedSvg(src, dst) {
fs.readFile(src, 'utf8', function(err, data) {
if(err) throw err;
data = data.replace(/<\?xml[^\?]*\?>[\r\n]*/g, '');
data = data.replace(/<svg[^>]*>[\r\n]*/g, '');
data = data.replace(/<\/svg>[\r\n]*/g, '');
data = data.replace(/>\s*<desc[^>]*>/g, ' ');
data = data.replace(/<\/desc>/g, '>');
data = data.replace(/&quot;/g, '"');
data = "(<any>window)['"+src+"'] = `" + data + "`;";
fs.writeFile(dst, data, function(err) {
if(err) throw err;
});
});
}
embedSvg('climate-zones-map.svg', 'climate-zones-map.svg.ts');