/ Published in: Processing

This is the way for listen the mouse wheel and interact from it in processing, enjoy
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
////////////////////////////////////////////////////////// //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; }
Comments
