Return to Snippet

Revision: 55539
at February 10, 2012 19:06 by cgiles


Initial Code
//////////////////////////////////////////////////////////
//Code By cgiles
//Description : how to add mouse wheel interactivy
//////////////////////////////////////////////////////////
// default size of my ellipse
int tailleEllipse=100;
void setup(){
  size(640,480);
  frameRate(30);
  // this will add a new event listener to your sketch
  // for listen how the mouse scroll is used
   addMouseWheelListener(new java.awt.event.MouseWheelListener() { 
    public void mouseWheelMoved(java.awt.event.MouseWheelEvent evt) { 
      mouseWheel(evt.getWheelRotation());
  }}); 
}
void draw(){
  background(255);
ellipse(width/2,height/2,tailleEllipse,tailleEllipse);
}
// this is the event listener of mouse wheel
void mouseWheel(int delta) {
  // add the value of wheel's scolling to my ellipse's size
  // for a better effiency i multiply the scrolling value by 5
  tailleEllipse+=delta*5;
}

Initial URL

                                

Initial Description
This is the way for listen the mouse wheel and interact from it in processing, enjoy

Initial Title
how to listen the mouse wheel in processing

Initial Tags

                                

Initial Language
Processing