svg-centre

Resize and centre an svg element to its contents. Eliminates whitespace, and enables correct rescaling regarding width and height (provided ratio is constant)

Usage no npm install needed!

<script type="module">
  import svgCentre from 'https://cdn.skypack.dev/svg-centre';
</script>

README

svg-centre

Lets shrink our svg just to the elements being shown within it.

centre = require('svg-centre')


// shrink a single svg
centre.shrink(document.getElementById('svg1'))

// or

// shrink all svgs
centre.shrinkall()


//create a montage of equally sized normalised svgs
centre.shrinkall(square='30vw')


alt text