SketchPad

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

Sketch 2015-07-14

        void ofApp::setup(){
    increment = 0.001;
    ofSetWindowShape(500, 500);
    gif.setup(ofGetTimestampString("out/%Y-%m-%d"), 56);
    masker.setup(2);
    face.setup("face.png", 2.0, TEXTURE_OFFSET_MIDDLE_CENTER);
    glass1.setup("glass1.png", 3.0, TEXTURE_OFFSET_MIDDLE_CENTER);
    cardTransparency1.setup("card-transp-bg.png", 1.9, TEXTURE_OFFSET_MIDDLE_LEFT);
    cardTransparency2.setup("card-transp-bg.png", 2.6, TEXTURE_OFFSET_BOTTOM_RIGHT);
    cardTransparency3.setup("card-transp-bg.png", 3.3, TEXTURE_OFFSET_TOP_CENTER);
    cardTransparency4.setup("card-transp-bg.png", 3.9, TEXTURE_OFFSET_MIDDLE_LEFT);
    cardTransparency5.setup("card-transp-bg.png", 4.9, TEXTURE_OFFSET_BOTTOM_RIGHT);
    cardTransparency6.setup("card-transp-bg.png", 5.6, TEXTURE_OFFSET_TOP_CENTER);
    initTransparencies();
    initImagePositions();
}

void ofApp::initTransparencies() {
    drawTransparency1 = ofRandom(1) > 0.5;
    drawTransparency2 = ofRandom(1) > 0.5;
    drawTransparency3 = ofRandom(1) > 0.5;
    drawTransparency4 = ofRandom(1) > 0.5;
    drawTransparency5 = ofRandom(1) > 0.5;
    drawTransparency6 = ofRandom(1) > 0.5;
}

void ofApp::initImagePositions() {
    imagePositions.push_back(TEXTURE_OFFSET_TOP_LEFT);
    imagePositions.push_back(TEXTURE_OFFSET_TOP_CENTER);
    imagePositions.push_back(TEXTURE_OFFSET_TOP_RIGHT);
    imagePositions.push_back(TEXTURE_OFFSET_MIDDLE_LEFT);
    imagePositions.push_back(TEXTURE_OFFSET_MIDDLE_CENTER);
    imagePositions.push_back(TEXTURE_OFFSET_MIDDLE_RIGHT);
    imagePositions.push_back(TEXTURE_OFFSET_BOTTOM_LEFT);
    imagePositions.push_back(TEXTURE_OFFSET_BOTTOM_CENTER);
    imagePositions.push_back(TEXTURE_OFFSET_BOTTOM_RIGHT);
}

void ofApp::update(){
    updateTransparencies();
    repositionFace();
    masker.beginLayer(0);
    {
        ofSetColor(ofColor(ofColor::black, ofRandom(1) > 0.9 ? 255 : 32));
        ofRect(0, 0, gif.width, gif.height);
        ofSetColor(ofColor(ofColor::white, 120));
        face.incrementTextureOffsetY(0.001);
        face.draw();
        ofSetColor(ofColor(ofColor::white, 234));
        glass1.incrementTextureOffsetY(0.125);
        glass1.draw();
    }
    masker.endLayer(0);
    
    masker.beginMask(0);
    {
        ofBackground(ofColor::white);
        cardTransparency1.incrementTextureOffsetX(-0.01);
        cardTransparency2.incrementTextureOffsetX(0.1);
        cardTransparency3.incrementTextureOffsetX(-0.01);
        cardTransparency4.incrementTextureOffsetX(-0.02);
        cardTransparency5.incrementTextureOffsetX(0.02);
        cardTransparency6.incrementTextureOffsetX(-0.2);
        drawTransparency(drawTransparency1, cardTransparency1);
        drawTransparency(drawTransparency2, cardTransparency2);
        drawTransparency(drawTransparency3, cardTransparency3);
        drawTransparency(drawTransparency4, cardTransparency4);
        drawTransparency(drawTransparency5, cardTransparency5);
        drawTransparency(drawTransparency6, cardTransparency6);
    }
    masker.endMask(0);

    masker.beginLayer(1);
    {
        masker.drawLayer(0);
    }
    masker.endLayer(1);
    
    masker.beginMask(1);
    {
        masker.drawLayer(0);
    }
    masker.endMask(1);
}

void ofApp::updateTransparencies() {
    updateTransparency(drawTransparency1);
    updateTransparency(drawTransparency2);
    updateTransparency(drawTransparency3);
    updateTransparency(drawTransparency4);
    updateTransparency(drawTransparency5);
    updateTransparency(drawTransparency6);
}

void ofApp::updateTransparency(bool &draw) {
    if(draw) {
        if(ofRandom(1) > 0.7) draw = false;
    } else {
        if(ofRandom(1) > 0.5) draw = true;
    }
}

void ofApp::drawTransparency(bool &draw, ofxTexturePlane &image) {
    if(draw) {
        image.draw();
    }
}

void ofApp::repositionFace() {
    if(ofRandom(1) > 0.6) {
        face.setTextureScale(ofRandom(1.5, 4.5));
        face.setTextureOffset(imagePositions[floor(ofRandom(9))]);
        glass1.setTextureOffsetY(ofRandom(2));
    }
}

void ofApp::draw(){
    gif.begin();
    {
        face.draw();
        masker.draw();
    }
    gif.endAndCaptureFrame();
    gif.draw();
    masker.drawOverlay();
}
    

Breaking it up

Daily sketch

Sketch 2015-07-13

        void ofApp::setup(){
    increment = 0.01;
    ofSetWindowShape(500, 500);
    gif.setupPaused(ofGetTimestampString("out/%Y-%m-%d"), 230, 279);
    gif.fadeInOut(8, 2, ofColor::white, 1);
    masker.setup(3);
    transp1.setup("road-transp.png");
    transp1.setTexturePositionY(0.5);
    transp2.setup("road-transp.png");
    transp2.setTexturePositionY(0.5);
    transp3.setup("road-transp.png");
    transp3.setTexturePositionY(0.5);
    transp4.setup("road-transp.png");
    transp4.setTexturePositionY(0.5);
    transp5.setup("road-transp.png");
    transp5.setTexturePositionY(0.5);
    transp6.setup("road-transp.png");
    transp6.setTexturePositionY(0.5);
}

void ofApp::update(){
    masker.beginLayer(0);
    {
        transp1.incrementTextureOffsetY(-increment);
        transp1.incrementTextureScale(-increment);
        transp1.draw();
    }
    masker.endLayer(0);

    masker.beginMask(0);
    {
        transp2.incrementTextureOffsetY(-increment);
        transp2.incrementTextureScale(-increment*0.5);
        ofBackground(ofColor::white);
        ofSetColor(ofColor::white);
        transp2.draw();
    }
    masker.endMask(0);
    
    masker.beginLayer(1);
    {
        transp3.incrementTextureOffsetY(increment);
        transp3.incrementTextureScale(increment);
        transp3.draw();
    }
    masker.endLayer(1);
    
    masker.beginMask(1);
    {
        transp4.incrementTextureOffsetY(increment);
        transp4.incrementTextureScale(increment*0.5);
        ofBackground(ofColor::white);
        ofSetColor(ofColor::white);
        transp4.draw();
    }
    masker.endMask(1);
    
    masker.beginLayer(2);
    {
        transp5.incrementTextureOffsetX(increment);
        transp5.incrementTextureScale(-increment);
        transp5.draw();
    }
    masker.endLayer(2);
    
    masker.beginMask(2);
    {
        transp6.incrementTextureOffsetX(-increment);
        transp6.incrementTextureScale(increment*0.5);
        ofBackground(ofColor::white);
        ofSetColor(ofColor::white);
        transp6.draw();
    }
    masker.endMask(2);
}

void ofApp::draw(){
    gif.begin();
    {
        ofBackground(ofColor::white);
        masker.draw();
    }
    gif.endAndCaptureFrame();
    gif.draw();
    masker.drawOverlay();
}
    

Textures set loose to emerge

Daily sketch

Sketch 2015-07-12

        void ofApp::setup(){
    increment = 0.02;
    ofSetWindowShape(500, 500);
    gif.setupPaused(ofGetTimestampString("out/%Y-%m-%d"), 105, 140);
    gif.fadeInOut(17, 4, ofColor::red, 1);
    masker.setup(1);
    transp1.setup("road-transp.png");
    transp1.setTexturePositionY(0.5);
    transp2.setup("road-transp.png");
    transp2.setTexturePositionY(0.5);
}

void ofApp::update(){
    masker.beginLayer(0);
    {
        transp1.incrementTextureScale(-increment);
        transp1.draw();
    }
    masker.endLayer(0);

    masker.beginMask(0);
    {
        transp2.incrementTextureScale(-increment*0.5);
        ofBackground(ofColor::white);
        ofSetColor(ofColor::white);
        transp2.draw();
    }
    masker.endMask(0);
}

void ofApp::draw(){
    gif.begin();
    {
        ofBackground(ofColor::red);
        masker.draw();
    }
    gif.endAndCaptureFrame();
    gif.draw();
    masker.drawOverlay();
}
    

Transparencies masking transparencies (against a red background)

Daily sketch

Sketch 2015-07-11

        void ofApp::setup(){
    beginRecordingOnFrame = 20;
    endRecordingAfterFrame = 40;
    increment = 0.01;
    ofSetWindowShape(500, 500);
    gif.setupPaused(ofGetTimestampString("out/%Y-%m-%d"), beginRecordingOnFrame);
    masker.setup(1);
    image.setup("road.png");
    image.setTexturePositionY(0.5);
    transp.setup("road-transp.png");
    goingUp = true;
    position = 0.5;
}

void ofApp::update(){
    masker.beginMask(0);
    {
        alpha = 32;
        if(ofRandom(1) > 0.6) {
            goingUp = !goingUp;
            alpha = 255;
        }

        position += goingUp ? increment : -increment;
        transp.setTexturePositionY(position);
        
        ofSetColor(ofColor::white, alpha);
        if(ofGetFrameNum() == 0) {
            ofSetColor(ofColor::black);
        }
        ofRect(0, 0, gif.width, gif.height);
        ofSetColor(ofColor::white);
        transp.draw();
    }
    masker.endMask(0);

    masker.beginLayer(0);
    {
        image.setTexturePositionY(1-position);
        image.draw();
    }
    masker.endLayer(0);
}

void ofApp::draw(){
    gif.begin();
    {
        masker.draw();
    }
    gif.endAndCaptureFrame();
    gif.draw();
    masker.drawOverlay();

    if(ofGetFrameNum() == beginRecordingOnFrame) {
        positionOnRecord = position;
    }

    if(ofGetFrameNum() > endRecordingAfterFrame &&
       (position == positionOnRecord - increment ||
        position == positionOnRecord + increment)) {
        gif.renderGif();
    }
}
    

I'm pretty sure this is what I was trying to do yesterday

Daily sketch

Sketch 2015-07-10

        void ofApp::setup(){
    ofSetWindowShape(500, 500);
    gif.setupPaused(ofGetTimestampString("out/%Y-%m-%d"), 40, 80);
    masker.setup(1);
    image.setup("road.png");
    image.setTexturePositionY(0.5);
    transp.setup("road-transp.png");
    goingUp = true;
    directionChanged = true;
    position = 0.5;
}

void ofApp::update(){
    masker.beginLayer(0);
    {
        image.incrementTextureOffsetY(0.05);
        image.draw();
    }
    masker.endLayer(0);
    
    masker.beginMask(0);
    {
        if(ofRandom(1) > 0.6) {
            goingUp = !goingUp;
            directionChanged = true;
        }
        
        if(directionChanged) {
            alpha = 255;
            directionChanged = false;
        } else {
            alpha = 32;
        }
        position += goingUp ? 0.01 : -0.01;
        transp.setTexturePositionY(position);
        
        ofSetColor(ofColor::white, alpha);
        if(ofGetFrameNum() == 0) {
            ofSetColor(ofColor::black);
        }
        ofRect(0, 0, gif.width, gif.height);
        ofSetColor(ofColor::white);
        transp.draw();
    }
    masker.endMask(0);
}

void ofApp::draw(){
    gif.begin();
    {
        masker.draw();
    }
    gif.endAndCaptureFrame();
    gif.draw();
    masker.drawOverlay();
}
    

Bringing the texture to the front

Daily sketch

Sketch 2015-07-09

        void ofApp::setup(){
    ofSetWindowShape(1000, 900);
    bpm = 90;
    playing = false;

    utils.setup();
    manager.setup();
    manager.toggleDebugUI();
    setupAudioUnits();
    setupTimeline();
}

void ofApp::setupAudioUnits() {
    noiseMaker1.setup('aumu', 'ncut', 'TOGU', AU_TYPE_SYNTH, "TALNoiseMaker");
    manager.add(&chain1, "tal-one", ofColor::blue);
    chain1.link(&noiseMaker1).toMixer();
    manager.loadPresets(&chain1);
}

void ofApp::setupTimeline() {
    timeline.setup();
    timeline.setLoopType(OF_LOOP_NORMAL);
    timeline.setShowBPMGrid(true);
    timeline.enableSnapToBPM(true);
    timeline.setBPM(bpm);
    timeline.setDurationInSeconds(36);
    timeline.setOffset(ofVec2f(10, 480));
    timeline.setWidth(ofGetWidth() - 400);
    timeline.addCurves("filter cutoff");
    timeline.addSwitches("midi events");
    ofAddListener(timeline.events().switched, this, &ofApp::switchFired);
}

void ofApp::update(){
    noiseMaker1.set(TALNoiseMaker_cutoff, timeline.getValue("filter cutoff"));
}

void ofApp::switchFired(ofxTLSwitchEventArgs &args) {
    string command = args.switchName + (args.on ? " ON" : " OFF");
    cout << endl << ofGetTimestampString() << endl;
    cout << "switch fired: " << command << endl;
    utils.executeMidiCommand(command, chain1.midi());
}
    

Weird tubular sound

Sketch 2015-07-09

Sketch 2015-07-08

A physical sketch with Kinect at Hardware Hack Lab