Sketch 2015-06-23
void ofApp::setupAnim() {
paused = true;
numLayers = 9;
topLayer = numLayers - 1;
spacing = 100;
thickness = 50;
offset = 0;
increment = 2;
masker.setup(numLayers);
//masker.toggleOverlay();
image.setup("surface.png", width, height, 1, TEXTURE_OFFSET_BOTTOM_LEFT);
image.incrementTextureOffsetY(0.5);
}
void ofApp::updateAnim(){
incrementOffset();
for(int i = 0; i < numLayers - 1; i++) {
masker.beginLayer(i);
ofBackground(ofColor(0, 0, 0, 0));
hue = ofMap(i, 0, numLayers, 20, 140);
ofSetColor(ofColor::fromHsb(hue, 255, 255, 240));
rotateScreen(i * 45);
drawLines();
masker.endLayer(i);
masker.beginMask(i);
ofBackground(ofColor::black);
ofSetColor(ofColor::white);
rotateScreen(i * 45);
rotateScreen(90);
drawLines();
rotateScreen(-90);
masker.endMask(i);
}
masker.beginLayer(topLayer);
masker.draw();
masker.endLayer(topLayer);
masker.beginMask(topLayer);
ofSetColor(ofColor::white);
image.incrementTextureOffsetX(0.02857142857);
image.draw();
rotateScreen(180);
image.draw();
rotateScreen(90);
image.draw();
rotateScreen(180);
image.draw();
masker.endMask(topLayer);
}
void ofApp::drawAnim() {
if(ofGetFrameNum() == spacing) {
paused = false;
}
ofBackground(ofColor::black);
masker.drawLayer(topLayer);
masker.drawOverlay();
if(ofGetFrameNum() == spacing + (spacing / increment)) {
renderGif();
}
}
void ofApp::incrementOffset() {
offset+=increment;
if(offset >= spacing) {
offset = 0;
}
}
void ofApp::drawLines() {
for(int y = -height; y < doubleHeight; y += spacing) {
ofRect(-width, y + offset, tripleWidth, thickness);
}
}
void ofApp::rotateScreen(float degrees) {
ofTranslate(halfWidth, halfHeight);
ofRotateZ(degrees);
ofTranslate(-halfWidth, -halfHeight);
}
Textures and computer graphics