Previous Projects/Goal-Bilby-master/SourceCode&WARfile/WebContent/scripts/main.js
// converting the paper to SVG format and export to PNG
converting the paper to SVG format and export to PNG
converting the paper to SVG format and export to PNG
function exportPNG(filename) {
	$(".connection").css("fill", "none");
	$(".link-tools").css("display", "none");
	$(".link-tools").css("fill", "none");
	var svgDoc = paper.svg;
	var serializer = new XMLSerializer();
	var svgString = serializer.serializeToString(svgDoc);
	var canvas = document.getElementById("canvas");
	var context = canvas.getContext('2d');
	canvg(canvas, svgString);
	destinationCanvas = document.createElement("canvas");
	destinationCanvas.width = canvas.width;
	destinationCanvas.height = canvas.height;
	destCtx = destinationCanvas.getContext('2d');
	destCtx.fillStyle = "#FFFFFF";
	destCtx.fillRect(0, 0, canvas.width, canvas.height);
	destCtx.drawImage(canvas, 0, 0);
	var img = destinationCanvas.toDataURL("image/png");
	var downloadLink = document.createElement("a");
	downloadLink.href = img;
	downloadLink.download = filename + ".png";
	document.body.appendChild(downloadLink);
	downloadLink.click();
	document.body.removeChild(downloadLink);
}
function exportPNG ( filename ) { $ ( ".connection" ) . css ( "fill" , "none" ) ; $ ( ".link-tools" ) . css ( "display" , "none" ) ; $ ( ".link-tools" ) . css ( "fill" , "none" ) ; var svgDoc = paper . svg ; var serializer = new XMLSerializer ( ) ; var svgString = serializer . serializeToString ( svgDoc ) ; var canvas = document . getElementById ( "canvas" ) ; var context = canvas . getContext ( '2d' ) ; canvg ( canvas , svgString ) ; destinationCanvas = document . createElement ( "canvas" ) ; destinationCanvas . width = canvas . width ; destinationCanvas . height = canvas . height ; destCtx = destinationCanvas . getContext ( '2d' ) ; destCtx . fillStyle = "#FFFFFF" ; destCtx . fillRect ( 0 , 0 , canvas . width , canvas . height ) ; destCtx . drawImage ( canvas , 0 , 0 ) ; var img = destinationCanvas . toDataURL ( "image/png" ) ; var downloadLink = document . createElement ( "a" ) ; downloadLink . href = img ; downloadLink . download = filename + ".png" ; document . body . appendChild ( downloadLink ) ; downloadLink . click ( ) ; document . body . removeChild ( downloadLink ) ; }
converting the paper to SVG format and export to PNG
converting the paper to SVG format and export to PNG