D3-Celestial 라이브러리 (https://github.com/ofrohn/d3-celestial)를 사용하고 있으며 캔버스 이미지를 SVG로 변환하려고합니다. (이것을 벡터 이미지로 사용하여 GCode로 변환 할 수 있습니다. 레이저 절단기). Fabric JS 라이브러리와 Canvas-GetSVG를 사용해 보았습니다. 성공하지 못했습니다.
누구나 시작할 수있는 좋은 장소가 있거나 쉬운 방법이 있습니까? d3-celestial 라이브러리를 SVG로 내보내기
<div style="overflow:hidden;"><div id="celestial-map"></div></div>
<div id="celestial-form"></div>
<script type="text/javascript">
var canvas;
Celestial.display({
form: true,
location: true,
datapath: "../data/",
stars: {proper: true}
});
document.getElementById("celestial-map").firstChild.setAttribute("id", "findthisstring");
function myFunction(){
var canvas = new fabric.Canvas('findthisstring', { isDrawingMode: true });
canvas.isDrawingMode = false;
canvas.toSVG();
}
function do_save() {
var canvas = new fabric.Canvas('findthisstring', { isDrawingMode: true });
canvas.isDrawingMode = false;
var filedata=canvas.toSVG(); // the SVG file is now in filedata
var locfile = new Blob([filedata], {type: "image/svg+xml;charset=utf-8"});
var locfilesrc = URL.createObjectURL(locfile);//mylocfile);
var dwn = document.getElementById('dwn');
dwn.innerHTML = "<a href=" + locfilesrc + "
download='mysvg.svg'>Download</a>";
}
</script>
<button onclick="myFunction()">Click me</button>
<input type="button" id="saveBtn" value="save" onclick="do_save()"></input>
<div id='dwn'></div>
<div id="imgOut"></div>
은 내가 SVG로 캔버스 객체에서 데이터를 내보낼 몇 가지 다른 라이브러리를 사용하려고하지만 빈 SVGs를 얻을 수 있었다.
도움을 받으려면 코드를 확인해야합니다. 코드의 관련 스 니펫과 시도한 내용에 대한 설명 및 기대되는 결과를 포함하여 질문을 편집하십시오. –
JS 및 관련 HTML을 추가했는데,이 작업이 내가 원하는 것을 설명하는 데 도움이됩니까? –