我有以下代码:
http://jsfiddle.net/JQPurfect/mkz4s9j3/29/
$("#editor_save").click(function() {
var paper = new Raphael(document.getElementById('raphaelDiv'), 200, 200);
// circle is for testing but I need svg_paper as the canvas object
var circle = paper.circle(50, 40, 10);
circle.attr("fill", "#f00");
circle.attr("stroke", "#fff");
var circle2 = paper.circle(70, 60, 50);
//Use raphael.export to fetch the SVG from the paper
var svg = paper.toSVG();
//Use canvg to draw the SVG onto the empty canvas
canvg(document.getElementById('myCanvas'), svg);
setTimeout(function() {
//fetch the dataURL from the canvas and set it as src on the image
var dataURL = document.getElementById('myCanvas').toDataURL("image/png");
document.getElementById('myImg').src = dataURL;
}, 100);
});
但是我需要将 svg_paper 保存到png,但无法搞清楚。我的想法是在 svg_paper 上徒手画画,并将其保存为图像,一旦点击"保存"按钮。
你可以用它来更新小提琴吗?
感谢。