SketchPad

Some web space to sketch, doodle and make notes. Made using these tools. See more of my work here.

Daily Sketches

Sketch 2015-05-07

        //This is all about shapes and shader-alpha masking
ofFbo bottomLayer, maskLayer, topLayer;

void ofApp::setupBottomLayer(){
    for(int i = -width; i < width*2; i += width * 0.01) {
        ofxShape shape;
        shape.setupFilledSquare(width - (width * 0.01));
        shape.scaleX(0.001);
        shape.setBlur(3);
        shape.setColor(ofColor::red);
        shape.positionX(ofMap(i, 0, width, width * 0.05, width * 0.99));
        shape.positionY(height * 0.5);
        bottomLayerShapes.push_back(shape);
    }
    
    ofxShapeSystem system1;
    for(int i = 0; i < bottomLayerShapes.size(); i++) {
        system1.add(bottomLayerShapes.at(i));
    }
    bottomLayerSystems.push_back(system1);
}

void ofApp::setupMaskLayer(){
    ofxShape shape;
    shape.setupFilledRing(60, width * 0.45);
    shape.positionX(width * 0.5);
    shape.positionY(height * 0.5);
    maskLayerShapes.push_back(shape);
    
    ofxShapeSystem system1;
    for(int i = 0; i < maskLayerShapes.size(); i++) {
        system1.add(maskLayerShapes.at(i));
    }
    maskLayerSystems.push_back(system1);
}

void ofApp::setupTopLayer(){
    for(int i = 0; i < height; i += height * 0.08) {
        ofxShape shape;
        shape.setupFilledSquare(height - (height * 0.05));
        shape.scaleY(0.03);
        shape.setBlur(3);
        shape.positionX(width * 0.5);
        shape.positionY(ofMap(i, 0, height, height * 0.05, height * 0.99));
        topLayerShapes.push_back(shape);
    }
    
    ofxShapeSystem system1;
    for(int i = 0; i < topLayerShapes.size(); i++) {
        system1.add(topLayerShapes.at(i));
    }
    topLayerSystems.push_back(system1);
}

void ofApp::updateAnim(){
    float faster = sin(ofGetFrameNum() * 0.1);
    float slower = sin(ofGetFrameNum() * 0.025);
    maskLayerShapes.at(0).setBlur(ofMap(faster, -1, 1, 3, 300));
    maskLayerShapes.at(0).rotateZ(ofMap(slower, -1, 1, 0, 90));
    
    bottomLayer.begin();
    ofClear(0, 0, 0, 255);
    ofPushMatrix();
    ofTranslate(width * 0.5, height * 0.5);
    ofRotateZ(ofMap(faster, -1, 1, 45, 135));
    ofTranslate(-width * 0.5, -height * 0.5);
    for(int i = 0; i < bottomLayerSystems.size(); i++) {
        bottomLayerSystems.at(i).update();
        bottomLayerSystems.at(i).draw();
    }
    ofPopMatrix();
    bottomLayer.end();
    
    maskLayer.begin();
    ofClear(0, 0, 0, 255);
    for(int i = 0; i < maskLayerSystems.size(); i++) {
        maskLayerSystems.at(i).update();
        maskLayerSystems.at(i).draw();
    }
    maskLayer.end();
    
    topLayer.begin();
    ofClear(0, 0, 0, 255);
    ofPushMatrix();
    ofTranslate(width * 0.5, height * 0.5);
    ofRotateZ(ofMap(faster, -1, 1, 135, 45));
    ofTranslate(-width * 0.5, -height * 0.5);
    for(int i = 0; i < topLayerSystems.size(); i++) {
        topLayerSystems.at(i).update();
        topLayerSystems.at(i).draw();
    }
    ofPopMatrix();
    topLayer.end();
}
    

It's been a very, very long day...

Daily sketch