-
-
Save round/76d2fa9839f7fca5ecdf87452600d0b2 to your computer and use it in GitHub Desktop.
Revisions
-
Gustavo Henke created this gist
Feb 18, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ 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() { ctx.drawImage( img, 0, 0 ); // Now is done console.log( canvas.toDataURL( "image/png" ) ); };