Skip to content

Commit

Permalink
Add save option
Browse files Browse the repository at this point in the history
Save our drawing canvas
  • Loading branch information
DipanshKhandelwal committed Dec 19, 2017
1 parent 90431a9 commit 9745a25
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
Binary file added images/save.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
<button class="toolbutton" id="activity-button" title="My Activity"></button>
<button class="toolbutton" id="new-button" title="New"></button>
<button class="toolbutton pull-right" id="stop-button" title="Stop"></button>
<button class="toolbutton pull-right" id="save-button" title="Save">
<img src="images/save.png"/>
</button>
</div>

<div id="loader"></div>
Expand Down
16 changes: 16 additions & 0 deletions js/activity.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,5 +263,21 @@ define(function (require) {
update = true;
shape = shape + 1;
}

function downloadCanvas(link, canvasId, filename) {
link.href = document.getElementById(canvasId).toDataURL();
link.download = filename;
print_voucher();
}
function print_voucher(){
var win=window.open();
win.document.write("<br><img src='"+canvas.toDataURL()+"'/>");
win.print();
win.location.reload();
}
document.getElementById('save-button').addEventListener('click', function() {
downloadCanvas(this, 'myCanvas', 'My_Drawing.png');
}, false);

});
});

0 comments on commit 9745a25

Please sign in to comment.