Commit 54fd4251 authored by amandaghassaei's avatar amandaghassaei
Browse files

save svg

parent cd41ba82
...@@ -112,6 +112,10 @@ function initControls(globals){ ...@@ -112,6 +112,10 @@ function initControls(globals){
globals.threeView.saveSVG(); globals.threeView.saveSVG();
}); });
setLink("#saveSVG", function(){
globals.pattern.saveSVG();
});
setCheckbox("#ambientOcclusion", globals.ambientOcclusion, function(val){ setCheckbox("#ambientOcclusion", globals.ambientOcclusion, function(val){
globals.ambientOcclusion = val; globals.ambientOcclusion = val;
}); });
......
...@@ -638,8 +638,27 @@ function initPattern(globals){ ...@@ -638,8 +638,27 @@ function initPattern(globals){
}; };
} }
function saveSVG(){
if (globals.extension == "fold"){
//todo solve for crease pattern
globals.warn("No crease pattern available for FOLD format.");
return;
}
var serializer = new XMLSerializer();
var source = serializer.serializeToString(document.getElementById("mySVG"));
var svgBlob = new Blob([source], {type:"image/svg+xml;charset=utf-8"});
var svgUrl = URL.createObjectURL(svgBlob);
var downloadLink = document.createElement("a");
downloadLink.href = svgUrl;
downloadLink.download = globals.filename + ".svg";
document.body.appendChild(downloadLink);
downloadLink.click();
document.body.removeChild(downloadLink);
}
return { return {
loadSVG: loadSVG, loadSVG: loadSVG,
saveSVG: saveSVG,
getFacesAndVerticesForEdges: getFacesAndVerticesForEdges, getFacesAndVerticesForEdges: getFacesAndVerticesForEdges,
triangulatePolys: triangulatePolys triangulatePolys: triangulatePolys
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment