javascript generate svg code code example
Example 1: javascript create svg
const svg1 = document. createElementNS("http://www.w3.org/2000/svg", "svg");
svg1. setAttribute ("width", "100" );
svg1. setAttribute ("height", "100" );
const cir1 = document. createElementNS("http://www.w3.org/2000/svg", "circle");
cir1.setAttribute("cx", 0 );
cir1.setAttribute("cy", 0 );
cir1.setAttribute("r", 50);
svg1 . appendChild ( cir1 );
document. getElementById ('x77738'). appendChild ( svg1 );
Example 2: generate svg from javascript
var draw = SVG().addTo('#drawing')
, rect = draw.rect(100, 100).fill('#f06')