Hi,
Literally Canvas is amazing! Thank you!
I am trying to take a canvas and export it as a png file as a variable as an ajax post. I am able to export the JSON data, but I haven't figured out how to send an image.
I'm not sure if it matters, but the Ajax program is written in perl.
Below is my script so far. What do I need to do to get the png data exported? Also, if someone knows Perl, can an example be provided? Otherwise, php? In perl, I usually do:
open (OUTFILE,">file.png");
while ($bytesread=read($image,$buffer,1024))
{
print OUTFILE $buffer;
}
close (OUTFILE);
Thanks
<html>
<head>
<!-- stylesheet -->
<link href="css/literallycanvas.css" rel="stylesheet">
<!-- dependency: React.js -->
<!-- Literally Canvas -->
<script src="js/literallycanvas.js"></script>
</head>
<body>
<a class="save"><button>SAVE</button></a>
<div class="my-drawing"></div>
<script>
$(document).ready(function() {
var lc = LC.init(
document.getElementsByClassName('my-drawing')[0]);
$('.save').on('click', () => {
json_data=JSON.stringify(lc.getSnapshot());
$.post( 'ajax.cgi', {"jsondata":json_data}, function(data) { alert(data);} );
});
});
</script>
</body>
</html>