var element = evt.target; var arc = element.shadowTree; var path = arc.getElementById("drawing_arc"); // get attributes from custom tag var cx = 0, cy = 0, r = 0, start = 0, sweep = 0, orientation = "default", units = "degrees"; nb_attributes = element.attributes.length for (i = 0; i < nb_attributes;i++) { attribute = element.attributes.item(i) switch(attribute.name) {case "cx" : cx = attribute.value - 0 ; break; case "cy" : cy = attribute.value - 0 ; break; case "r" : r = attribute.value - 0 ; break; case "start" : start = attribute.value - 0 ; break; case "sweep" : sweep = attribute.value - 0 ; break; case "orientation" : orientation = attribute.value ; break; case "units" : units = attribute.value ; break; } } if (orientation == "maths") { start = 0 - start sweep = 0 - sweep } if (units == "degrees") { start = start * Math.PI / 180; sweep = sweep * Math.PI / 180; } // calculate d attribute for path var x_begin = cx + r * Math.cos(start); var y_begin = cy + r * Math.sin(start); var x_end = cx + r * Math.cos(start + sweep); var y_end = cy + r * Math.sin(start + sweep); var rotate = 0; if (Math.abs(sweep) < Math.PI) large_flag = 0 else large_flag = 1 if (sweep > 0) sweep_flag = 1 else sweep_flag = 0 var d="M" + x_begin.toString() + " " + y_begin.toString() + "A" + r.toString() + " " + r.toString() + " " + rotate.toString() + " " + large_flag.toString() + " " + sweep_flag.toString() + " " + x_end.toString() + " " + y_end.toString() // apply attributes path.setAttributeNS(null, "d", d);