topical media & game development

talk show tell print

sample-js-asscisvg-d.svg / svg



  <?xml version="1.0" standalone="no"?>
  <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN" 
    "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
  <svg id="root" xml:space="preserve" width="100%" height="100%" 
    preserveAspectRatio="xMidYMid meet"
    xmlns="http://www.w3.org/2000/svg"
    onmousemove="storeCoords(evt)">
  <script><![CDATA[
  function storeCoords(evt) {
    svgdoc=evt.getTarget().getOwnerDocument();
    root=svgdoc.getElementById("root");
    x=(evt.getClientX()-root.currentTranslate.x)/root.currentScale;
    y=(evt.getClientY()-root.currentTranslate.y)/root.currentScale;
    pointerpos=svgdoc.getElementById("pointerpos");
    pointerpos.setAttribute("cx",x);
    pointerpos.setAttribute("cy",y);
  }
  ]]></script>
  <circle id="pointerpos" cx="0" cy="0" r=".5" fill="red"/>
  </svg>
  


(C) Æliens 04/09/2009

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.