Loading...
Logo
Processing Forum
I'm using filter() on my sketch but I want the user to be able to change the filter by clicking buttons.

So I have something that looks like:

PShader myFilter;

then in my draw,
filter(myFilter);

- how do I change the value of myFilter? I tried myFilter = THRESHOLD and myFilter = "THRESHOLD" but obviously that won't work as they need a PShader. I don't know what to do. Is there a string to PShader conversion method?

Replies(2)

Figured out I could just set myFilter to a String and do an if(myFilter == "THRESHOLD"){filter(THRESHOLD);} - works too.

Thank you.
http://processing.org/reference/filter_.html
" kind int: Either THRESHOLD, GRAY, OPAQUE, INVERT, POSTERIZE, BLUR, ERODE, or DILATE"
Copy code
  1. int myFilter = THRESHOLD;
  2. filter(myFilter);