2014-06-12 1 views
0

JavaScript로 SVG를 만들고 싶습니다. SVG 요소 (JS 형식 SVGSVGElement)가 있지만이 형식에는 createSvgRect, createSvgTransfrom 등과 같은 메서드가 있지만 createSvgPath는 없습니다. SVG에서 어떻게 경로를 만들 수 있습니까?SVGSVGElement에서 SVGPathElement를 만드는 방법

var svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); 
svg.setAttribute("width", (200).toString()); 
svg.setAttribute("height", (200).toString()); 
// there i need to create path from svg object 
+0

코드를 보여주세요! – helderdarocha

+0

여기에서 토론 확인 http://stackoverflow.com/questions/7547117/add-a-new-line-in-svg-bug-cannot-see-the-line – Danyu

답변

1

<path>은 요소이므로 createElementNS를 호출하여 예를 들어 하나를 가져옵니다.

var path = document.createElementNS("http://www.w3.org/2000/svg", "path"); 

createSVGRect에 대해 혼란스러워합니다. 이 요소는 <rect> 요소를 만들지 않으며, viewBox 특성과 같은 것을 모델링하는 데 사용되는 사각형 개체를 만듭니다.