Sketch 2015-05-22
void ofApp::setupAnim() {
ofEnableSmoothing();
ofSetLineWidth(4);
masker.setup(width, height);
paused = true;
img1.loadImage("chihuly-1.png");
img2.loadImage("chihuly-2.png");
numBoxSets = 200;
}
void ofApp::rotateScreen(float degrees) {
ofTranslate(halfWidth, halfHeight, 0);
ofRotate(degrees);
ofTranslate(-halfWidth, -halfHeight, 0);
}
void ofApp::updateAnim(){
ofEnableAlphaBlending();
ofEnableBlendMode(OF_BLENDMODE_ADD);
masker.beginBackground();
img1.draw(0, 0);
ofSetColor(ofColor(ofColor::black, 40));
ofRect(0, 0, width, height);
masker.endBackground();
masker.beginMask();
ofBackground(ofColor::black);
for(int i = 0; i < numBoxSets; i++) {
for(int j = 0; j < width; j+=20) {
ofSetColor(ofColor::white, ofRandom(10, 35));
ofRect(
ofRandom(j - 10, j + 10),
ofMap(i, 0, numBoxSets, width * 0.5, width),
ofRandom(2, 20),
ofRandom(20, 50));
}
rotateScreen(10);
}
masker.endMask();
masker.beginForeground();
img2.draw(0, 0);
ofSetColor(ofColor(ofColor::black, 40));
ofRect(0, 0, width, height);
masker.endForeground();
ofDisableBlendMode();
ofDisableAlphaBlending();
}
void ofApp::drawAnim() {
masker.draw();
ofEnableAlphaBlending();
for(int i = 0; i < numBoxSets; i++) {
for(int j = 0; j < width; j+=20) {
if(j % 40 == 0) ofSetColor(ofColor::white, ofRandom(1, 7));
else ofSetColor(ofColor::black, ofRandom(1, 7));
ofRect(
ofRandom(j - 10, j + 10),
ofMap(i, 0, numBoxSets, 30, -30),
ofRandom(2, 20),
ofRandom(20, 50));
}
rotateScreen(10);
}
ofDisableAlphaBlending();
if(ofGetFrameNum() == 50) paused = false;
if(ofGetFrameNum() == 80) renderGif();
}
Vacation Day 3 - Dale Chihuly at Fairchild Botanical Garden