1var pt = svg.createSVGPoint(); // Created once for document
2
3function alert_coords(evt) {
4 pt.x = evt.clientX;
5 pt.y = evt.clientY;
6
7 // The cursor point, translated into svg coordinates
8 var cursorpt = pt.matrixTransform(svg.getScreenCTM().inverse());
9 console.log("(" + cursorpt.x + ", " + cursorpt.y + ")");
10}
1function clicked(evt){
2 var e = evt.target;
3 var dim = e.getBoundingClientRect();
4 var x = evt.clientX - dim.left;
5 var y = evt.clientY - dim.top;
6 alert("x: "+x+" y:"+y);
7}