Sketch 2015-06-05
void ofApp::setupAnim() {
masker.setup(width, height);
layerId = masker.newLayer();
ofDisableArbTex();
offset.x = ofRandom(30);
offset.y = ofRandom(30);
movingLeft = true;
setupImage("surface.png", &img, &tex);
plane.set(width, height);
plane.setPosition(halfWidth, halfHeight, 0);
plane.setResolution(2, 2);
}
void ofApp::setupImage(string file, ofImage *img, ofTexture *tex) {
img->loadImage(file);
*tex = img->getTextureReference();
tex->setTextureWrap(GL_MIRRORED_REPEAT, GL_MIRRORED_REPEAT);
}
void ofApp::drawLayer(ofTexture *tex) {
plane.mapTexCoords(tx0, ty0, tx1, ty1);
plane.mapTexCoords(tx1, ty1, tx0, ty0);
tex->bind();
plane.draw();
tex->unbind();
}
void ofApp::updateAnim(){
masker.beginLayer(layerId);
ofBackground(ofColor::black);
ofSetColor(ofColor::red);
tx0 = offset.x + (movingLeft ? ofGetFrameNum() : -ofGetFrameNum()) * 0.0005;
ty0 = offset.y;
tx1 = tx0 - 0.16666667;
ty1 = ty0 - 1;
drawLayer(&tex);
masker.endLayer(layerId);
masker.beginMask(layerId);
ofBackground(ofColor::black);
for(int i = 0; i < 8; i++) {
ofSetColor(ofColor::white, ofRandom(32));
ofRotateZ(ofRandom(360));
ofRect(-width*2, ofRandom(height), width*4, ofRandom(halfHeight, height));
}
masker.endMask(layerId);
if(ofRandom(1) > 0.5) {
offset.x = ofRandom(30);
offset.y = ofRandom(30);
movingLeft = !movingLeft;
}
}
void ofApp::drawAnim() {
if(ofGetFrameNum() == 0) ofBackground(ofColor::black);
ofSetColor(ofColor::white, 40);
drawLayer(&tex);
masker.draw();
if(ofGetFrameNum() == 72) {
renderGif();
}
}
It's dark and murky