Skip to content

Instantly share code, notes, and snippets.

@wonderburg7
Last active December 31, 2018 12:48
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/e4f5b951d553a042ef9859f4b94fbc18 to your computer and use it in GitHub Desktop.
Save wonderburg7/e4f5b951d553a042ef9859f4b94fbc18 to your computer and use it in GitHub Desktop.
Letter letterg, lettere;
PImage img1, img2, img3;
float i = 0;
float j = 0;
float count = 0;
float rotationValue = 40;
float rotationCount = 0;
float rotationTest = 0;
int delay = 10;
int f;
static final color BG = -4;
void setup()
{
size(1000,1000,P3D);
imageMode(CENTER);
translate(width/2.0, height/2.0);
int picheight = height, picwidth = width;
img1 = loadImage("hexagon 2.png");
img2 = loadImage("ge g.png");
img3 = loadImage("ge e.png");
img1.resize(picheight, picwidth);
img2.resize(picheight, picwidth);
img3.resize(picheight, picwidth);
letterg = new Letter(img2, i);
lettere = new Letter(img3, j);
hint(DISABLE_DEPTH_TEST);
}
void draw(){
background(BG);
image(img1 ,width/2, height/2);
rotationTest = rotationCount;
if (rotationCount > (rotationValue*2)-delay){
letterg.display();
} else if (count > delay ) {
f = 1;
letterg.rotateOnceandDisplay();
rotationCount += 1;
} else {
letterg.display();
}
if (rotationCount > rotationValue*2-delay+10) {
lettere.display();
} else if (count > delay) {
f = 2;
lettere.rotateOnceandDisplay();
j = j+(PI/rotationValue);
if (rotationTest == rotationCount){
rotationCount += 1;
}
} else {
lettere.display();
}
i = i+(PI/rotationValue);
count++;
if (rotationCount > 100) {
rotationCount = 0;
}
saveTransparentCanvas(BG, "img");
}
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("GE"+frameCount+".png");
}
class Letter {
PImage img;
float tempj;
Letter(PImage tempi, float tempj) {
img = tempi;
i = tempj;
}
void rotateOnceandDisplay() {
pushMatrix();
translate(width/2.0, height/2.0);
if (f == 1) {
rotateY(i);
} else if (f == 2) {
rotateY(i-1);
}
image(img, 0, 0);
popMatrix();
}
void display() {
image(img, width/2, height/2);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment