= createSVGElement("stop");
stop1.setAttribute("offset", "0");
stop1.setAttribute("stop-color", "green");
gradient.appendChild(stop1);

var stop2 = createSVGElement("stop");
stop2.setAttribute("offset", "1");
stop2.setAttribute("stop-color", "red");
gradient.appendChild(stop2);

var defsElement = createSVGElement("defs");
defsElement.appendChild(gradient);
rootSVGElement.appendChild(defsElement);

var rect = createSVGElement("rect");
rect.setAttribute("id", "rect");
rect.setAttribute("x", "0");
rect.setAttr