wobbleFrames.pde

Very rough processing.org script. Presented as-is.
context: https://oioiiooixiii.blogspot.com/2013/09/wibblywobbly-opera-processing.html

PImage img, img2;
int red, green, blue, x, y, frame;
boolean thumbnails;
int MODE;
//PImage[] frameArray;
ArrayList frameArray;


void setup() 
{
  //what type of output
  MODE = 2;
  
  frame = 0;
  img = loadImage("input//"+frame+".png");
  img2 = createImage(img.width, img.height,RGB);
  size(img.width, img.height);
  
  x = 0;
  y = 0;
  noLoop();
}

//************************************************



void draw()
{
  // Start timing
  long start = System.currentTimeMillis();
  
  //----------------------------
  
  arrayBasedFrames(10042);
  //sequentialBasedFrames();
  
  //img2.save("output//"+x+".png");
  
  //----------------------------
  
  // End timing and output results
  long end = System.currentTimeMillis(); 
  println("Start time: "+start);
  println("End time: "+end);
  println("Run time = "+(end-start));

}

void arrayBasedFrames(int limit)
{
  // Create the frame array
  frameArray = new ArrayList(img.height);
  
  // load original frames into array
  for(int i = 0; i < img.height; i++)
  {
    PImage temp = loadImage("input//"+i+".png");
    frameArray.add(i, temp);
    frame++;
  }
  
  //Main loop for total frames
  while(frame < limit)
  {
  
    // Building new frame line-by-line
    for(int j = 0; j < img.height; j++)
    {
        PImage temp = (PImage)frameArray.get(j);
        for(int i = 0; i < img.width; i++) 
        {
          img2.pixels[i+y] = temp.pixels[i+y];
        }
        y += img.width;
        //println(frame);
     }
     
     // Update frame array
     frameArray.remove(0);
     //x = frame+img.height;
     frameArray.add(loadImage("input//"+frame+".png"));
     
     // Resets line place marker (y) for each new frame
     y=0;
     img2.save("output//"+x+".png");
     frame++;
     x++;
   }
}

void sequentialBasedFrames()
{
  
  //LOOP ONLY FOR TESTING
  for(int xxx = 0; xxx < 5; xxx++){
  
  // Load a frame for each line
  for(int j = 0; j < img.height; j++)
  {
    img = loadImage("input//"+frame+".png");
    
    // Write line to new frame
    for(int i = 0; i < img.width; i++) 
    {
      img2.pixels[i+y] = img.pixels[i+y];
    }
    frame++;
    y += img.width;
    //println(frame);
  }
  
  // FOR TESTING ONLY
  frame=0;
  y=0;
  img2.save("output//"+xxx+".png");
  }
}

void imageOutput()
{
}


//*******************************************************************




void draw2() 
{
  
  frame += x;
  for(int j = 0; j < img.height; j++)
  {
    PImage temp = (PImage)frameArray.get(j);
    for(int i = 0; i < img.width; i++) 
    {
      img2.pixels[i+y] = temp.pixels[i+y];
    }
    frameArray.remove(j);
    frameArray.add(loadImage("h//"+frame+".png"));
    frame++;
    y += img.width;
    //println(frame);
  }
  


  

  
 //image(img2, 0, 0); 
 img2.save("output//"+x+".png");
 //println(x);
 x++;
 //frame = 0;
 y=0;
 //save("pk_brightness.png");
}


void draw1() 
{
  
  frame += x;
  for(int j = 0; j < img.height; j++)
  {
    img = loadImage("h//"+frame+".png");
    
    
    
    for(int i = 0; i < img.width; i++) 
    {
      img2.pixels[i+y] = img.pixels[i+y];
    }
    frame++;
    y += img.width;
    //println(frame);
  }
  
  //quicksort(0,img.pixels.length-1);

  

  
 //image(img2, 0, 0); 
 img2.save("output//"+x+".png");
 //println(x);
 x++;
 frame = 0;
 y=0;
 //save("pk_brightness.png");
}




/*void quicksort(int low, int high) 
{

    int i = low, j = high;
    // Get the pivot element from the middle of the list
    float pivot = brightness(img.pixels[low + (high-low)/2]);

    // Divide into two lists
    while (i <= j) {
      // If the current value from the left list is smaller then the pivot
      // element then get the next element from the left list
      while (brightness(img.pixels[i]) < pivot) {
        i++;
      }
      // If the current value from the right list is larger then the pivot
      // element then get the next element from the right list
      while (brightness(img.pixels[j]) > pivot) {
        j--;
      }

      // If we have found a values in the left list which is larger then
      // the pivot element and if we have found a value in the right list
      // which is smaller then the pivot element then we exchange the
      // values.
      // As we are done we can increase i and j
      if (i <= j) {
        exchange(i, j);
        i++;
        j--;
      }
    }
    // Recursion
    if (low < j) quicksort(low, j);
    if (i < high) quicksort(i, high);
}

void exchange(int i, int j) 
{
    int temp = img.pixels[i];
    img.pixels[i] = img.pixels[j];
    img.pixels[j] = temp;
    
    
    //y++;
    if(MODE == 1 && y % 2000 <= 0)
    {
      img.save("frames//"+x+".png");
      x++;
    }
    //else if(MODE == 2 && y == frame) img.save("frames//"+frame+".png");

}
*/