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-18

        ofxLayerMask masker;
    vector<ofxAnimatableFloat> positions, targets, heights, opacities;

    void ofApp::setupAnim() {
    ofEnableSmoothing();
    ofSetLineWidth(4);
    masker.setup(width, height);
    
    for(int i = 0; i < 70; i++) {
        ofxAnimatableFloat animHeight;
        animHeight.reset(ofRandom(40));
        heights.push_back(animHeight);
        
        ofxAnimatableFloat opacity;
        opacity.reset(ofMap(i, 0, 300, 100, 255));
        opacities.push_back(opacity);
        
        ofxAnimatableFloat target;
        target.reset(ceil(ofRandom(-height, height * 2)));
        targets.push_back(target);
        
        ofxAnimatableFloat position;
        position.reset(createDistinct(target.val()));
        position.setCurve(SWIFT_GOOGLE);
        position.setRepeatType(LOOP_BACK_AND_FORTH);
        position.setDuration(ceil(ofRandom(2)) * 2);
        position.animateTo(targets.at(i).val());
        positions.push_back(position);
    }
}

float ofApp::createDistinct(float from) {
    float candidate;
    do candidate = ceil(ofRandom(-height, height * 2));
    while(abs(candidate - from) < 150);
    return candidate;
}

void ofApp::updateAnim(){
    ofEnableAlphaBlending();
    
    masker.beginBackground();
    ofBackground(ofColor::black);
    ofSetColor(ofColor::white, 200);
    for(int i = -width; i < width*2; i+=30) {
        ofLine(i, height, i + width*0.5, 0);
    };
    masker.endBackground();
    
    masker.beginMask();
    ofBackground(ofColor::black);
    for(int i = 0; i < positions.size(); i++) {
        positions.at(i).update(0.05);
        ofSetColor(ofColor::white, opacities.at(i).val());
        ofRect(0, positions.at(i).val(), width, heights.at(i).val());
    }
    masker.endMask();
    
    masker.beginForeground();
    ofBackground(ofColor::black);
    ofSetColor(ofColor::white, 100);
    for(int i = -width; i < width*2; i+=15) {
        ofLine(i + width*0.5, height, i, 0);
    };
    masker.endForeground();
    
    ofDisableAlphaBlending();
}

void ofApp::drawAnim() {
    masker.draw();
    bool allFinished = true;
    for(int i = 0; i < positions.size(); i++) {
        if(positions.at(i).getPlayCount() < 2) {
            allFinished = false;
        }
    }
    if(allFinished) renderGif();
}
    

Transmission static.

Daily sketch