Sketch 2015-05-11
void ofApp::setupAnim() {
ofSetWindowShape(width, height);
masker.setup(width, height);
setupBackground();
setupMask();
setupForeground();
}
void ofApp::setupBackground(){
for(int i = 0; i < width; i+=40) {
for(int j = 0; j < height; j+=40) {
ofxShape shape;
shape.setupFilledSquare(26);
shape.positionX(i+10);
shape.positionY(j+10);
shape.setBlur(10);
backgroundShapes.push_back(shape);
}
}
push(&backgroundShapes, &backgroundSystems);
}
void ofApp::setupMask(){
for(int i = -width; i < width*2; i+=40) {
for(int j = -width; j < height*2; j+=40) {
ofxShape shape;
shape.setupFilledSquare(26);
shape.positionX(i+10);
shape.positionY(j+10);
shape.setBlur(10);
maskShapes.push_back(shape);
}
}
push(&maskShapes, &maskSystems);
}
void ofApp::setupForeground(){
for(int i = 0; i < width; i+=40) {
for(int j = 0; j < height; j+=40) {
ofxShape shape;
shape.setupFilledSquare(26);
shape.positionX(i+30);
shape.positionY(j+30);
shape.setBlur(10);
foregroundShapes.push_back(shape);
}
}
push(&foregroundShapes, &foregroundSystems);
}
void ofApp::updateAnim(){
float scale = ofMap(sin(ofGetFrameNum() * 0.08), -1, 1, -54, 54);
for(int i = 0; i < maskShapes.size(); i++){
maskShapes.at(i).positionZ(scale);
}
}
void ofApp::drawAnim() {
masker.beginBackground();
draw(&backgroundSystems);
masker.endBackground();
masker.beginMask();
draw(&maskSystems);
masker.endMask();
masker.beginForeground();
draw(&foregroundSystems);
masker.endForeground();
masker.draw();
if(ofGetFrameNum() == 78) {
renderGif();
}
}
void ofApp::push(vector<ofxShape> *shapes, vector<ofxShapeSystem> *systems) {
ofxShapeSystem system;
for(int i = 0; i < shapes->size(); i++) {
system.add(shapes->at(i));
}
systems->push_back(system);
}
void ofApp::draw(vector<ofxShapeSystem> *systems) {
ofClear(0, 0, 0, 255);
for(int i = 0; i < systems->size(); i++) {
systems->at(i).draw();
}
}
Sometimes it's all about grids of squares