Reputation: 3985
i want to create SVG in JavaScript. I have SVG element (JS type SVGSVGElement), this type have methods as createSvgRect, createSvgTransfrom, ... but haven´t createSvgPath. How i can in SVG create a path?
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
Upvotes: 2
Views: 2447
Reputation: 124049
A <path>
is an element so you just call createElementNS to get one e.g.
var path = document.createElementNS("http://www.w3.org/2000/svg", "path");
You seem confused about createSVGRect. That doesn't create a <rect>
element, it creates a rectangle object which is used to model things like the viewBox attribute.
Upvotes: 3