Skip to content

Instantly share code, notes, and snippets.

@wonderburg7
Last active January 26, 2019 12:41
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/259fb71eaf550082542774775a6b747e to your computer and use it in GitHub Desktop.
Save wonderburg7/259fb71eaf550082542774775a6b747e to your computer and use it in GitHub Desktop.
//global variables
PImage img1, img2;
float x1, x2, y1, y2;
float angle1 = 0, angle2 = 25;
float scalar = 10;
float locationSave = height/2 + (scalar * sin(radians(angle1)));
static final color BG = -4;
void setup() {
size(550, 550);
imageMode(CENTER);
img1 = loadImage("Mobius Track.png");
img2 = loadImage("Dice (1).png");
img1.resize(int(width*.95), int(height*.95));
img2.resize(int(width*.95), int(height*.95));
}
void draw() {
float ang1 = radians(angle1);
float ang2 = radians(angle2);
y1 = height/2 + (scalar * sin(ang1));
y2 = height/2 + (scalar * sin(ang2));
// background(255, 0);
background(BG);
pushMatrix();
translate(width/2, y2-(height/2));
image(img1, 0, y2);
popMatrix();
pushMatrix();
translate(width/2, y2-(height/2)-(height*0.03));
image(img2, 0, y1);
popMatrix();
angle1 += 2;
angle2 += 2;
saveTransparentCanvas(BG, "img");
if (y1 == height/2 + (scalar * sin(radians(0)))){
print(frameCount);
}
}
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