Need to convert an HTML5 canvas to SVG for editing ? Pointer will be appreciated
I think the canvas must already be drawing an svg for this method, but I found it in the course of trying to create a download svg button myself, also ran into this stack overflow question in the same search figured it may be relevant.
from https://bramp.github.io/js-sequence-diagrams/
around line 200ish, but who knows he may edit site in the future
editor is just a div element, and for the purpose of this noise, he's just packing the stuff the svg was generated off of into the downloaded svg.
diagram_div is the canvas the actual svg is sitting in.
function(ev) {
var svg = diagram_div.find('svg')[0];
var width = parseInt(svg.width.baseVal.value);
var height = parseInt(svg.height.baseVal.value);
var data = editor.getValue();
var xml = '';
var a = $(this);
a.attr("download", "diagram.svg"); // TODO I could put title here
a.attr("href", "data:image/svg+xml," + encodeURIComponent(xml));
}