Vertical Pixel Sorting on image

But, I have also this code:

PImage img;

int minThreshold = 110;
int maxThreshold = 350;

float Time;
int restart = 0;

void setup() {
  
  size(1200, 675);
  
  frameRate(60);
  
  img = loadImage("Tree.jpg");
  
  
}

void draw() {
  //background(255);
  
  image(img, 0, 0);
  
  img.loadPixels();
  
  float sec = map(frameCount, 0, 60*60, 0,  TWO_PI);
  println(sec);
  
  pushMatrix();
  
  if (sec >= (0.03)){
    
  for (int y = 0; y < height; y++) {
    for (int x = 0; x < width; x++) {

      if (brightness(img.pixels[y*width+x]) > minThreshold && brightness(img.pixels[y*width+x]) < maxThreshold) {
        color c = get(x, y);
        stroke(c,40);
        line(x, y, x, y+50);
        
      }
    }}
  }
  
  
  
  popMatrix();
  
}

And the is the result:

But he doesn’t follow the time indications I give him, because I would like to tell him that every few seconds he has to re-sort, but how?
So to increase the value that I have already given him?

2 Likes