Skip to content

Instantly share code, notes, and snippets.

View round's full-sized avatar
🎯
Focusing

Maxim Leyzerovich round

🎯
Focusing
View GitHub Profile
@round
round / svg2png.js
Created January 15, 2019 05:41 — forked from gustavohenke/svg2png.js
SVG to PNG
var svg = document.querySelector( "svg" );
var svgData = new XMLSerializer().serializeToString( svg );
var canvas = document.createElement( "canvas" );
var ctx = canvas.getContext( "2d" );
var img = document.createElement( "img" );
img.setAttribute( "src", "data:image/svg+xml;base64," + btoa( svgData ) );
img.onload = function() {