Cedric is right.
filter(XXX) is a function call, not an object. It acts immediately on the sketch's display, you cannot store it. So you have to apply it in draw(), depending on current choice.
Otherwise, the overall logic is correct, with some little logic fixes:
Code:void keyPressed(){
if(key == 32){
count++;
[color=#ff0000]// Moved check inside test[/color]
if (count==3){
count=0;
}
}
else if(key == 65 || key == 97){
x+=3;
}
}
Note that you can write simpler (but slightly less readable, at least when you are not used to the idiom):
count = ++count % 3;So you get rid of the filter array, and in draw you do:
Code:void draw(){
background(255);
image(pix[count],x,y,550,550);
switch (count) {
// No case 0, I think it can be nice to see unfiltered image in this case
case 1: filter(GRAY); break;
case 2: filter(INVERT); break;
case 3: filter(THRESHOLD); break;
// and so on
default:
}
}
Note the usage of break, to avoid applying the filters in cascade...