I want to implement a functionality in my app wherein the user can take snapshot of the current screen and can annotate it (modify/scribble/etc) and after that, can send it in an email. My app uses phonegap for ios as well as android support. But mainly it consist of javascript/jquery.
So far I am able to achieve:
- Saving current html to canvas (with the help of html2canvas library)
- Enable user to interact with that canvas using freehand tool provided by sketch.js
- Add text notes to user defined location anywhere on canvas
- Open a new email popup using phonegap's email Composer Plugin
In order to provide interactivity feel to user, I implemented layers of canvas :
1: First layer will be showing actual snapshot captured through html2canvas. To show my snapshot on this canvas (capturedCanvas), I am setting the background-image of the canvas to image obtained through the library. code is as follows:
$('.myClass').html2canvas({
onrendered: function( canvas ) {
var capturedCanvas = document.getElementById('capturedImageView');
capturedCanvas.style.backgroundImage = 'url('+canvas.toDataURL();+')';
}
});
2 and 3: The layers above it will toggle depending on whether the user selected freehand tool or text tool.
Everything works fine but when the user is finished interacting with the seperate canvases, I need to bring the 3 canvases into one image so that it can be attached to email.
I am able to connect layers 2 and 3 using context.drawImage
but somehow my actual snapshot that I got from html2canvas does not accompany my final image.
My final snapshot looks like this :
Please provide insight on this issue.