Sketch 2015-08-07
void ofApp::setup(){
ofSetWindowShape(500, 500);
gif.setup(ofGetTimestampString("out/%Y-%m-%d"), 47);
gif.fadeInOut(3, 6, ofColor::white);
gif.enableTextOverlay();
numRoads = 2;
masker.setup(numRoads);
road.setup("road.png", 1.0, TEXTURE_OFFSET__MIDDLE__RIGHT_TO_CENTER);
for(int i = 0; i < numRoads; i++) {
scale = ofMap(i, 0, numRoads-1, 1, 6);
road.setTextureScale(scale);
road.setTextureOffsetY(ofRandom(2));
road1s.push_back(road);
}
road.setup("road.png", 1.0, TEXTURE_OFFSET__MIDDLE__RIGHT_TO_CENTER);
for(int i = 0; i < numRoads; i++) {
scale = ofMap(i, 0, numRoads-1, 6, 1);
road.setTextureScale(scale);
road.setTextureOffsetY(ofRandom(2));
road2s.push_back(road);
}
}
void ofApp::update(){
for(int i = 0; i < numRoads; i++) {
masker.beginLayer(i);
{
road1s.at(i).incrementTextureOffsetY(ofMap(i, 0, numRoads-1, -0.002, 0.002));
road1s.at(i).draw();
}
masker.endLayer(i);
masker.beginMask(i);
{
road2s.at(i).incrementTextureOffsetY(ofMap(i, 0, numRoads-1, -0.002, 0.002));
road2s.at(i).draw();
}
masker.endMask(i);
}
}
void ofApp::draw(){
gif.begin();
{
masker.draw();
}
gif.endCaptureDraw();
masker.drawOverlay();
}
Both directions at once.