SketchPad

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

Daily Sketches

Sketch 2015-04-29

        void ofApp::setupAnim() {
    ofEnableSmoothing();
    boundary = 25;
    increment = 8;
    for(int i = 0; i <= 20; i++) {
        line.addVertex(i * width * 0.05, ofRandom(-boundary, boundary));
    }
    lines.push_back(line);
}

void ofApp::updateAnim(){
    if(ofGetFrameNum() < 39) {
        for(int i = 0; i <= 20; i++) {
            line[i].y = drunkWalk(line[i].y);
        }
        lines.push_back(line);
    }
    
    if(ofGetFrameNum() >= 40) {
        if(lines.size() == 1) {
            renderGif();
        } else {
            lines.pop_back();
        }
    }
}

void ofApp::drawAnim() {
    ofBackground(0, 255, 255);
    alpha = 255;
    
    ofTranslate(0, boundary* 2);
    
    ofPushMatrix();
    for(int i = 0; i < lines.size() && alpha >= 0; i++) {
        ofSetColor(1, 131, 185, alpha);
        ofSetLineWidth(i * 0.8);
        
        ofTranslate(0, i);
        lines.at(lines.size() - 1 - i).draw();
        alpha -= 16;
    }
    ofPopMatrix();
    
    ofSetLineWidth(2);
    ofSetColor(255, 255, 255, 200);
    lines.at(lines.size() - 1).draw();
}

float ofApp::drunkWalk(float from) {
    if(from > boundary - increment) return from - increment;
    if(from < -boundary + increment) return from + increment;
    return ofRandom(1) > 0.5 ?
            from + increment :
            from - increment;
}
    

A polyline on a drunken walk

Daily sketch