Andrew on Nostr: Had a simple icon SVG the other day that was in a 32px canvas and we needed it in a ...
Had a simple icon SVG the other day that was in a 32px canvas and we needed it in a 20px canvas, so rather than piss about with Inkscape or whatever, I pasted the path data into Node and wrote this deeply cursed one-liner:
x.replaceAll(/[\d.]+/g, a => (parseFloat(a)*(20/32)).toFixed(2).replace(/\.?0+$/,''))
AND IT WORKED FIRST TIME
there is no way that should have worked, but it did, the icon is now exactly the right size and the file is smaller to boot
x.replaceAll(/[\d.]+/g, a => (parseFloat(a)*(20/32)).toFixed(2).replace(/\.?0+$/,''))
AND IT WORKED FIRST TIME
there is no way that should have worked, but it did, the icon is now exactly the right size and the file is smaller to boot