front_processing/src/Interaction_examples/Hands_1D/Hands_1D.pde
changeset 8 e4e7db2435f8
child 9 0f44b7360c8d
equal deleted inserted replaced
7:8a21bec5d45f 8:e4e7db2435f8
       
     1 /*
       
     2 * This file is part of the TraKERS\Front Processing package.
       
     3 *
       
     4 * (c) IRI <http://www.iri.centrepompidou.fr/>
       
     5 *
       
     6 * For the full copyright and license information, please view the LICENSE_FRONT
       
     7 * file that was distributed with this source code.
       
     8 */
       
     9 
       
    10 /*Exemple tiré de processing.org*/
       
    11 
       
    12 import TUIO.*;
       
    13 TuioProcessing tuioClient;
       
    14 int port = 80;
       
    15 //Taille de la fenĂȘtre
       
    16 int WIDTH = 640, HEIGHT = 480;
       
    17 
       
    18 int gx = 15;
       
    19 int gy = 35;
       
    20 float leftColor = 0.0;
       
    21 float rightColor = 0.0;
       
    22 
       
    23 void setup()
       
    24 {
       
    25   size(WIDTH, HEIGHT);
       
    26   tuioClient = new TuioProcessing(this, port);
       
    27   colorMode(RGB, 1.0);
       
    28   noStroke();
       
    29 }
       
    30 
       
    31 void draw()
       
    32 {
       
    33   background(0.0);
       
    34   tuioInput();
       
    35   fill(0.0, leftColor + 0.4, leftColor + 0.6); 
       
    36   rect(width/4-gx, height/2-gx, gx*2, gx*2); 
       
    37   fill(0.0, rightColor + 0.2, rightColor + 0.4); 
       
    38   rect(width/1.33-gy, height/2-gy, gy*2, gy*2);
       
    39 }
       
    40 
       
    41 void update(int x)
       
    42 {
       
    43   leftColor = -0.002 * x/2 + 0.06;
       
    44   rightColor =  0.002 * x/2 + 0.06;
       
    45 	
       
    46   gx = x/2;
       
    47   gy = 100-x/2;
       
    48 
       
    49   if (gx < 10) {
       
    50     gx = 10;
       
    51   } else if (gx > 90) {
       
    52     gx = 90;
       
    53   }
       
    54 
       
    55   if (gy > 90) {
       
    56     gy = 90;
       
    57   } else if (gy < 10) {
       
    58     gy = 10;
       
    59   }
       
    60 }