SketchPad

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

Daily Sketches

Sketch 2015-06-20

        void ofApp::setupAnim() {
    leafVertical.setup("leaf-vertical.png", width, height, 1, TEXTURE_OFFSET_MIDDLE_CENTER);
    leafDiagonal.setup("leaf-diagonal.png", width, height, 4, TEXTURE_OFFSET_MIDDLE_CENTER);
    leafStar.setup("leaf-star.png", width, height, 2, TEXTURE_OFFSET_MIDDLE_CENTER);
    planes.push_back(&leafVertical);
    planes.push_back(&leafDiagonal);
    planes.push_back(&leafStar);

    mask1.setup("mask-texture-1.png", width, height, 8, TEXTURE_OFFSET_MIDDLE_CENTER);
    masks.push_back(&mask1);
    mask2.setup("mask-texture-2.png", width, height, 10, TEXTURE_OFFSET_MIDDLE_CENTER);
    masks.push_back(&mask2);

    numLayers = 2;
    layerIds = masker.setup(width, height, numLayers);
    increment = 0.02;
}

void ofApp::updateAnim(){
    leafStar.incrementTextureOffsetY(increment);

    for(int i = 0; i < numLayers; i++) {
        masker.beginLayer(layerIds.at(i));
        {
            scale1 = ofMap(sin(ofGetFrameNum() * increment), -1, 1, 0.7, 5);
            scale2 = ofMap(cos(ofGetFrameNum() * increment), -1, 1, 2.5, 4);
            ofSetColor(ofColor::red, alpha);
            planes.at(i)->incrementTextureOffsetY(i % 2 == 0 ? increment : -increment);
            planes.at(i)->setTextureScale(i % 2 == 0 ? scale1 : scale2);
            planes.at(i)->draw();
        }
        masker.endLayer(layerIds.at(i));

        masker.beginMask(layerIds.at(i));
        {
            maskIncrement = ofGetFrameNum() * ((i % 2) - 0.5) * 0.125;
            maskIncrement = ofMap(sin(maskIncrement), 1, -1, 0.001, -0.001);
            if(i % 2 == 1) maskIncrement *= 5;
            
            scale1 = ofMap(sin(ofGetFrameNum() * increment), -1, 1, 3, 9);
            scale2 = ofMap(cos(ofGetFrameNum() * increment), -1, 1, 6, 12);

            ofBackground(ofColor::black);
            ofSetColor(ofColor::white);
            masks.at(i)->incrementTextureOffsetY(maskIncrement);
            masks.at(i)->setTextureScale(i % 2 == 0 ? scale1 : scale2);
            masks.at(i)->draw();
        }
        masker.endMask(layerIds.at(i));
    }
}

void ofApp::drawAnim() {
    alpha = ofGetFrameNum() == 0 || ofRandom(1) > 0.5 ? 255 : 128;
    ofSetColor(ofColor::red, alpha);
    leafStar.draw();

    ofSetColor(ofColor::white);
    masker.draw();
    if(ofGetFrameNum() == numFrames) {
        renderGif();
    }
}
    

Leaves

Daily sketch