Re: lines to vectors, vectors to GIF, [was RE: Back

"Joe Doll [email protected] [svg-developers]" <[email protected]> Tue, 11 Nov 2014 10:28:40 -0700
Newsgroups gmane.text.xml.svg.devel
Message-ID <[email protected]>
Hi David,

To convert SVG to canvas you need to btoa() with some like,

    // This is the viewport
    svg_data = 
srl.serializeToString(SVGDocImgs.getElementById("defs_grp").parentNode);

    // Create the the source
    tn_img.src = "data:image/svg+xml;base64," + btoa(svg_data);

    // Load it
    tn_img.onload = function() {

        // Create a canvas and set the HW
        var tn_elm = document.createElement('canvas');
        tn_elm.setAttribute("width", 228);
        tn_elm.setAttribute("height", 200);

        // Get the context
        var tn_ctx = tn_elm.getContext('2d');

        // Draw the image
        tn_ctx.drawImage(tn_img, 0, 0, 228, 200);

        // After you have the image you would usually use something like
        // tn_elm.toDataURL('image/jpeg', .6) to manipulate the image

    };

I hope some of the formatting still exists by the time you get it.

Joe



------------------------------------
Posted by: Joe Doll <[email protected]>
------------------------------------

-----
To unsubscribe send a message to: [email protected]
-or-
visit http://groups.yahoo.com/group/svg-developers and click "edit my membership"
----