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

        void ofApp::updateAnim(){
    for(int i = 0; i < 12; i++) {
        createMover();
    }
    
    if(ofGetFrameNum() == 40) {
        trails = true;
    }
    
    if(ofGetFrameNum() == 80) {
        running = false;
        stopping = true;
    }
    
    if(ofGetFrameNum() == 94) {
        stopping = false;
        trails = false;
    }
    
    if(ofGetFrameNum() == 98 || ofGetFrameNum() == 108) {
        resetting = !resetting;
    }
    
    if(ofGetFrameNum() == 110) {
        save = true;
    }
    
    for(int i = 0; i < movers.size(); i++) {
        movers.at(i).applyForce(gravity);
        movers.at(i).update();
    }
}

void ofApp::drawAnim() {
    if(!trails) {
        ofSetHexColor(0x100643);
        ofRect(0, 0, width, height);
    }
    
    if(running) {
        for(int i = 0; i < movers.size(); i++) {
            movers.at(i).draw();
        }
    }
    
    if(stopping) {
        ofSetColor(ofColor::white);
        font.drawString("STOP", 70, 120);
    }
    
    if(resetting) {
        ofSetColor(ofColor::white);
        font.drawString("RESET", 64, 120);
    }
    
    if(save) {
        renderGif();
        movers.clear();
        save = !save;
    }
}

void ofApp::createMover() {
    minX = width * 0.4;
    maxX = width * 0.6;
    x = ofRandom(minX, maxX);
    
    minY = height * 0.1;
    maxY = height * 0.7;
    y = ofRandom(minY, maxY);
    
    color.setHsb(ofMap(y, minY, maxY, 0, 50), 255, 128);
    initial = ofVec2f(ofMap(x, minX, maxX, -3, 3), 0);
    
    PatternMover mover;
    mover.setup();
    mover.setColor(color);
    mover.setSize(3);
    mover.applyForce(initial);
    mover.setLocation(x, y);
    movers.push_back(mover);
}
    

Toying with simple forces

Daily sketch