why does my program return the error, RuntimeException: Too many popStyle() without enough pushStyle()?
i have the same amount of pop as i do push
(I want to have the screen be inverted, and go back to normal every five minutes)
//visual
PImage shrek;
//timer
//moving
float charx=0;
float chary=0;
boolean invert= false;
void setup() {
size(1000, 563);
shrek= loadImage("shrek.jpg");
chary= height/2;
}
void draw() {
//visual
background(shrek);
color(255);
ellipse(charx, chary, 50, 50);
//timer
println(millis()/1000);
if (millis()/1000%300==0&&millis()/1000>10&& invert==false) {
invert=true;
}
if (millis()/1000%300==0&&millis()/1000>10&& invert==true) {
invert=false;
}
while (invert==true){
push();
filter(INVERT);}
while(invert==false){
pop();
}
//moving
if (keyPressed) {
//move left with a
if (key == 'a'&&invert==false) {
charx=charx-10;
}
//move right with d
if (key == 'd'&&invert==false) {
charx=charx+10;
}
//move right with a
if (key == 'a'&&invert==true) {
charx=charx+10;
}
//move left with d
if (key == 'd'&&invert==true) {
charx=charx-10;
}
}
}