I am trying to create a website where you can draw an image on top of another image using Raphael.js. The drawing details are finished and I can export the lines as png. I embed images in SVG raphael by generating the paper.image() function; Unfortunately, my export function does not include the imported image.
These are scripts that I use, but I don’t think I use all of them.
<script src="../jquery-2.0.1.min.js"></script> <script src="raphael-min.js"></script> <script src="rgbcolor.js"></script> <script src="canvg.js"></script> <script src="StackBlur.js"></script> <script src="svg.min.js"></script>
Here's the export function $ ('# save'). onmousedown ...
var canvas = document.getElementById('canvas2'); var svg = document.getElementById('canvas'); svg = svg.innerHTML; canvg(canvas, svg); var img_url = canvas.toDataURL('image/png'); $('#converted_image').attr('src', img_url); var img = canvas.toDataURL("image/png"); document.write('<img src="'+img+'"/>');
Here's how I import images with a button that represents the image $('#img1').onmousedown ...
paper.clear(); var c = paper.image("images/img1.png", 10, 10, 200, 200);
Here's what the output in the dom-tree looks like with an image and a white line as an example.
<div id="canvas"> <svg height="300" version="1.1" width="300" xmlns="http://www.w3.org/2000/svg" style="overflow: hidden; position: relative; " id="canvassvg"> <desc>Created with Raphaël 2.1.0</desc> <defs></defs> <image x="10" y="10" width="200" height="200" preserveAspectRatio="none" href="images/img1.png"> </image> <path style="stroke-linecap: round; stroke-linejoin: round; " fill="none" stroke="#ffffff" d="M383,201L383,201L383,202L383,203" stroke-linecap="round" stroke-linejoin="round" stroke-width="4"> </path> </svg> </div>
Thanks so much for any answer, and please excuse my English.