Arduino lines CENTER mousebutton appear...

edited February 2017 in Arduino

Please help me!

I want to know how i can adjust the mouseButton == CENTER, when you press this button(CENTER MOUSE BUTTON), both lines need to appear, so the LEFT & RIGHT line need to appear together...??

Does anyone know how to do this? The code is below....

PVector curPoint ; PVector prevPoint ; float teller = 0;

void setup() { size(1920,1080); background(255); strokeWeight(1); curPoint = new PVector(int(random(width)), int(random(height))); prevPoint = curPoint; }

void draw() { if (mousePressed && (mouseButton == RIGHT)) { float x = lerp(prevPoint.x, curPoint.x, teller); float y = lerp(prevPoint.y, curPoint.y, teller); colorMode(HSB, 360,100,100); stroke(134, 100, map(teller, 0,1, 0,200)); line(prevPoint.x, prevPoint.y, x,y);

   if(teller < 1){
   teller = teller + .0075;
   }
   if(teller > .98){
   ellipse(curPoint.x, curPoint.y,10,10);
   }}

   if (mousePressed && (mouseButton == LEFT)) {
   float x = lerp(prevPoint.x, curPoint.x, teller);
   float y = lerp(prevPoint.y, curPoint.y, teller);
   colorMode(HSB, 360,100,100);
   stroke(0, 100, map(teller, 0,1, 0,200));
   line(prevPoint.x, prevPoint.y, x,y);

   if(teller < 1){
   teller = teller + .0075;
   }
   if(teller > .98){
   ellipse(curPoint.x, curPoint.y,10,10);
   }} 

       if (mousePressed && (mouseButton == CENTER)) {
       float x = lerp(prevPoint.x, curPoint.x, teller);
       float y = lerp(prevPoint.y, curPoint.y, teller);
       colorMode(HSB, 360,100,100);
       stroke(0, 100, map(teller, 0,1, 0,200));
       line(prevPoint.x, prevPoint.y, x,y);

       if(teller < 1){
       teller = teller + .0075;
       }
       if(teller > .98){
       ellipse(curPoint.x, curPoint.y,10,10);
       }} 

}

void mousePressed() { prevPoint = curPoint; curPoint = new PVector(int(random(width)), int(random(height))); teller = 0.0; }

Tagged:

Answers

  • Check the reference here :https://processing.org/reference/mouseButton.html

    Here is a sample code below.

    Kf

    // Click within the image and press
    // the left and right mouse buttons to 
    // change the value of the rectangle
    void draw() {
      rect(25, 25, 50, 50);
    }
    
    void mousePressed() {
      if (mouseButton == LEFT) {
        fill(0);
      } else if (mouseButton == CENTER) {
        fill(255);
      } else {
        fill(126);
      }
    }
    
Sign In or Register to comment.