Last active
January 27, 2019 11:43
-
-
Save wonderburg7/cfb4fb113d0bd9a7052861305d0651d9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PImage img1, img2, img3; | |
int rotationCount = 0; | |
int picSize; | |
static final color BG = -4; | |
void setup() { | |
size(500, 500, P3D); | |
// noSmooth(); | |
// ((PGraphicsOpenGL)g).textureSampling(2); | |
img1 = loadImage("https://i.imgur.com/qNr33dN.png"); | |
imageMode(CENTER); | |
picSize = height; | |
// img1.resize(picSize, picSize); | |
// img2.resize(picSize, picSize); | |
} | |
void draw() { | |
background(BG); | |
//background(0, 0); | |
picSize = height; | |
translate(width/2, height/2); | |
pushMatrix(); | |
rotate(radians(rotationCount)); | |
rotateY(radians(180)); | |
image(img1,0,0, picSize, picSize); | |
popMatrix(); | |
rotationCount++; | |
saveTransparentCanvas(BG, "img"); | |
if (rotationCount == 360){ | |
rotationCount = 0; | |
print("reached 360"); | |
} | |
} | |
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