wonderburg7
1/24/2019 - 11:07 PM

Square curves flip.pde

PImage img1, img2, img3, img4, img5, img6, img7, img8, img;
float i = 0;
static final color BG = -4;
    
void setup()
{
    size(1000,1000,P3D);
    img1 = loadImage("https://i.imgur.com/H9FOC2R.png?1");
    img2 = loadImage("https://i.imgur.com/2FGaeRo.png?2");

                            
//    int picheight = 300,picwidth = 300;
    
    img1.resize(int(width*.95), int(height*.95));
    img2.resize(int(width*.95), int(height*.95));
    
    hint(DISABLE_DEPTH_TEST);


}

void draw(){
    background(BG);

img = img1;

    pushMatrix();
    // Move the coordinate system to the center of the screen
    translate(width/2.0, height/2.0);
        image(img2,-img2.width/2.0, -img2.height/2.0);

    // Rotate the coordinate system a bit more each frame   
 
if (frameCount >= 400){
frameCount = 0;
i = 0;
} else if (frameCount > 64+64+2 && frameCount < 400){
 //delay(500);
} else if (frameCount >= 64+2){
 rotateX(i);
} else if (frameCount == 64+2){
 //delay(500); 
} else if (frameCount > 2) {
    rotateY(i);
} 
 

    // Draw the image in the center
    image(img1,-img1.width/2.0, -img1.height/2.0);
    popMatrix();
 //   saveFrame("frame####");
  //  saveTransparentCanvas(BG, "img");
    i = i+(PI/64);
}

void saveTransparentCanvas(final color bg, final String name) {
  final PImage canvas = get(0,0,height,width);
  canvas.format = ARGB;
 
  final color p[] = canvas.pixels, bgt = bg & ~#000000;
  for (int i = 0; i != p.length; ++i)  if (p[i] == bg)  p[i] = bgt;
 
  canvas.updatePixels();
  canvas.save("Frame####"+frameCount+".png");
}