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

        void ofApp::setupAnim() {
    ofEnableSmoothing();
    ofSetLineWidth(4);
    masker.setup(width, height);
    
    img1.loadImage("boat-ride.png");
    img2.loadImage("maersk.png");
    
    for(int i = 0; i < 10; i++) {
        ofxAnimatableFloat animHeight;
        animHeight.reset(ofRandom(90));
        heights.push_back(animHeight);
        
        ofxAnimatableFloat opacity;
        opacity.reset(ofMap(i, 0, 300, 120, 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(4)) * 0.5);
        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::rotateScreen(float degrees) {
    ofTranslate(halfWidth, halfHeight, 0);
    ofRotate(degrees);
    ofTranslate(-halfWidth, -halfHeight, 0);
}

void ofApp::updateAnim(){
    ofEnableAlphaBlending();
    
    masker.beginBackground();
    img1.draw(0, 0);
    ofSetColor(ofColor(ofColor::black, 40));
    ofRect(0, 0, width, height);
    masker.endBackground();
    
    masker.beginMask();
    ofBackground(ofColor::black);
    for(int i = 0; i < 4; i++) {
        rotateScreen(90);
        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();
    img2.draw(0, 0);
    ofSetColor(ofColor(ofColor::black, 40));
    ofRect(0, 0, width, height);
    masker.endForeground();
    
    ofDisableAlphaBlending();
}

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

Vacation Day 2

Daily sketch