Sketch 2015-05-14
void ofApp::setupAnim() {
ofEnableSmoothing();
masker.setup(width, height);
fadeIn = true;
fadeOut = false;
alpha = 255;
ofDisableArbTex();
setupImage("tissue.png", &img1, &tex1, &offset1);
setupImage("road.png", &img2, &tex2, &offset2);
plane.set(width, height);
plane.setPosition(width * 0.5, height * 0.5, 0);
plane.setResolution(2, 2);
}
void ofApp::setupImage(string file, ofImage *img, ofTexture *tex, float *offset) {
img->loadImage(file);
*tex = img->getTextureReference();
tex->setTextureWrap(GL_MIRRORED_REPEAT, GL_MIRRORED_REPEAT);
*offset = ofRandom(1);
}
void ofApp::updateAnim(){
masker.beginBackground();
ofBackground(0, 0, 0, 255);
ofSetColor(ofColor::red);
tx0 = -0.5;
ty0 = -ofGetFrameNum() * 0.003 + offset1;
tx1 = tx0 + 1;
ty1 = ty0 + 0.5;
drawLayer(&tex2);
masker.endBackground();
masker.beginMask();
ofEnableAlphaBlending();
ofBackground(0, 0, 0, 255);
ofSetColor(ofColor::white);
tx0 = -0.35;
ty0 = ofGetFrameNum() * 0.01 + offset1;
tx1 = tx0 + 0.7;
ty1 = ty0 + 0.25;
drawLayer(&tex1);
ty0 = -ofGetFrameNum() * 0.02 + offset1;
ty1 = ty0 + 0.25;
drawLayer(&tex1);
ty0 = ofGetFrameNum() * 0.01 + offset2;
ty1 = ty0 + 0.25;
drawLayer(&tex1);
ty0 = -ofGetFrameNum() * 0.02 + offset2;
ty1 = ty0 + 0.25;
drawLayer(&tex1);
ofRect(0, 0, 70, height);
ofRect(width - 70, 0, 70, height);
ofDisableAlphaBlending();
masker.endMask();
masker.beginForeground();
ofBackground(0, 0, 0, 255);
ofSetColor(ofColor::white);
tx0 = -0.5;
ty0 = -ofGetFrameNum() * 0.0012 + offset2;
tx1 = tx0 + 1;
ty1 = ty0 + 0.5;
drawLayer(&tex2);
masker.endForeground();
}
Blood pump.