Skip to content

Instantly share code, notes, and snippets.

@wonderburg7
Created January 24, 2019 23:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wonderburg7/06a7eb7cb1230cce933ae1b4199752c3 to your computer and use it in GitHub Desktop.
Save wonderburg7/06a7eb7cb1230cce933ae1b4199752c3 to your computer and use it in GitHub Desktop.
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");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment