Quantcast
Channel: Library Questions - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 2896

Filter() and button

$
0
0

Hello everyone, In this code, I wish that by pressing a button the webcam had a permanent filter:

import processing.video.*; import g4p_controls.*;

Capture cam;
GButton btnFilterG;


void setup() {
  size(1024,768);


  btnFilterG = new GButton(this, 160, 20, 140, 20);
  btnFilterG.setText("Filter B&W");


    cam = new Capture(this,640,480);
    cam.start();
  }
}

void draw() {
  if (cam.available() == true) {
    cam.read();
  }
  image(cam,0,0,width,height);

}

public void handleButtonEvents(GButton button, GEvent event) {
   if (button == btnFilterG) {
    filter(GRAY);
  }
}

I put in the button but it works only for the time of the click. where I have to add the button? and which code must have the button to remove the filter?

thank you


Viewing all articles
Browse latest Browse all 2896

Trending Articles