Sketch 2015-06-21
void ofApp::setupAnim() {
velocities[TEXTURE_OFFSET_TOP_RIGHT] = -0.004;
velocities[TEXTURE_OFFSET_MIDDLE_RIGHT] = 0.004;
velocities[TEXTURE_OFFSET_BOTTOM_RIGHT] = 0.004;
image1.setup("cardboard.png", halfWidth, height, 1);
image2.setup("cardboard.png", -halfWidth, height, 1);
image2.setPlanePosition(width, 0);
}
void ofApp::updateAnim(){
if(ofGetFrameNum() % 10 == 0) {
lastOffset1 = getRandomOffset();
image1.setTextureOffset(lastOffset1);
lastOffset2 = getRandomOffset();
image2.setTextureOffset(lastOffset2);
}
image1.incrementTextureOffsetY(velocities[lastOffset1]);
image2.incrementTextureOffsetY(velocities[lastOffset2]);
}
void ofApp::drawAnim() {
ofBackground(ofColor::black);
image1.draw();
image2.draw();
if(ofGetFrameNum() == 70) {
renderGif();
}
}
ofxTexturePlaneOffset ofApp::getRandomOffset() {
switch((int)floor(ofRandom(3))) {
case 0:
return TEXTURE_OFFSET_TOP_RIGHT;
case 1:
return TEXTURE_OFFSET_MIDDLE_RIGHT;
case 2:
return TEXTURE_OFFSET_BOTTOM_RIGHT;
}
}
Just moving textures around.