topical media & game development

talk show tell print

graphic-javascript-vector-rotation.js / js



  window.onload = (function () {
      var src = $("#image img")[0].src;
      $("#image").html("");
      var R = Raphael("image", 600, 600),
          img = R.image(src, 140, 140, 320, 320),
          mouse;
      document.mousemove(function (e) {
          if (mouse) {
              img.rotate(e.pageX - mouse);
          }
          mouse = e.pageX;
      });
      if ("orientation" in window) {
          var a = 0;
          document.ongesturechange = function (e) {
              var r = e.rotation % 360 - a;
              a += r;
              img.rotate(r);
          };
  
          document.ongestureend = function () {
              a = 0;
          };
      }
  });


(C) Æliens 20/2/2008

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.