function createSVG(element){ return document.createElementNS('http://www.w3.org/2000/svg', element); } function addLine(line, svg_parent){ var svgline = createSVG('line'); svgline.setAttribute('x1', line.starting_point.x); svgline.setAttribute('y1', line.starting_point.y); svgline.setAttribute('x2', line.end_point.x); svgline.setAttribute('y2', line.end_point.y); svg_parent.appendChild(svgline); return svgline; } function updateLine(svgline, abstractline){ svgline.setAttribute('x1', abstractline.starting_point.x); svgline.setAttribute('y1', abstractline.starting_point.y); svgline.setAttribute('x2', abstractline.end_point.x); svgline.setAttribute('y2', abstractline.end_point.y); return svgline; }