Ejemplo n.º 1
0
void testApp::render(){
    canvas.begin();
    ofNoFill();
    ofSetLineWidth(lineWeight);
    ofEnableBlendMode(OF_BLENDMODE_ALPHA);
    for (int i = 0; i < lines.size(); i++) {
        lines[i].update();
        lines[i].render(&src, lineAlpha);
    }
    ofClearAlpha();
    canvas.end();
}
Ejemplo n.º 2
0
//--------------------------------------------------------------
void ofxMtlMapping2D::bind()
{
    _fbo.begin();
    ofClear(.0f, .0f, .0f, .0f);
    ofClearAlpha();
}
Ejemplo n.º 3
0
//--------------------------------------------------------------
void ofApp::draw(){
//-------------------------
    
    int  limit = contourFinder.nBlobs;
    int maxArea = 0;
    int elementNum = -1;
    ofColor yellow(255, 255, 171);
    ofColor white(255, 1);
    
//-------------------------
    
    // loop pages, back and forth
    if (_i < 0) {
        _i = 14;
    }
    if (_i > 14){
        _i = 0;
    }
    
    switch (_i) {
    
        case 0: // blink eyes - ellipse, fill black when clicked DONE
            img1.draw(30, 60);
            ofSetColor(255, 180, 0, alpha);
            ofDrawCircle(265, 225, 45);
            ofDrawCircle(440, 230, 45);
            if (ofGetMousePressed() == true){
                alpha = 0;
            } else {
                alpha = 255;
            }
            music1.setPaused(false);
            ofSetColor(255);
            font.drawString("Omphalotus wasnt like all the other mushrooms.", 40, 40);
            font.drawString("He had eyes. ...and could walk.", 40, 55);
            break;
            
        case 1: // cap sensor DONE
            img2.draw(30, 60);
            music2.setPaused(false);
            bSendSerialMessage = true;
            if (nBytesRead != 1){
                ofSetColor(220);
            } else {
                ofSetColor(0);
            }
            font.drawString("...and talk. He glowed in the dark too.", 40, 40);
            break;
            
        case 2: // earth video speed, mouse move DONE
            bSendSerialMessage = false;
            ofClearAlpha();
            img3.draw(30, 60);
            mov1.draw(215, 480);
            mov1.setSpeed(vidSpeed);
            music3.setPaused(false);
            font.drawString("He didnt know what to do with the days, he felt lost and lonely.", 40, 40);
            font.drawString("Like the world was too big, and he was too small.", 40, 55);
            break;
            
        case 3: // ketchup DONE
            ofEnableAlphaBlending();
            bSendSerialMessage = false;
            img4.draw(30, 60);
            music4.setPaused(false);
            font.drawString("He thought of turning himself in to the omelet factory,", 40, 40);
            font.drawString("but even then, theyd turn him away because he is too poisonous.", 40, 55);
            ofSetColor(250, 58, 20);
            line.draw();
            ofSetColor(255);
            break;
            
        case 4:
            bSendSerialMessage = false;
            ofClearAlpha();
            img5.draw(30, 60);
            music5.setPaused(false);
            font.drawString("It was late one evening he squished sadly past a slime mold on a rock.", 40, 40);
            break;
            
        case 5: // stars in eyes
            bSendSerialMessage = false;
            ofClearAlpha();
            img6.draw(30, 60);
            music6.setPaused(false);
            font.drawString("Hello, what a lovely evening!", 40, 40);
            font.drawString("...squeaked the slime mold.", 40, 55);
            break;
            
        case 6: // drops in eyes
            bSendSerialMessage = false;
            ofClearAlpha();
            img8.draw(30, 60);
            music7.setPaused(false);
            font.drawString("Hello.", 40, 40);
            font.drawString("...replied Omphalotus gloomily.", 40, 55);
            break;
            
        case 7: // more stars
            bSendSerialMessage = false;
            ofClearAlpha();
            img9.draw(30, 60);
            music8.setPaused(false);
            font.drawString("Come, sit upon this rock with me, the lunar eclipse is coming!", 40, 40);
            font.drawString("...the slime mold squeaked.", 40, 55);
            break;
            
        case 8:
            bSendSerialMessage = false;
            img7.draw(30, 60);
            ofClearAlpha();
            music9.setPaused(false);
            font.drawString("Omphalotus did not know what the slime mold was talking about ", 40, 40);
            font.drawString("but he slowly glided over to the rock and joined his new companion.", 40, 55);
            break;
            
        case 9: // throw sum leds DONE
                // touch cap sensor to alternate functions?
            bSendSerialMessage = true;
            ofClearAlpha();
            img10.draw(30, 60);
            music10.setPaused(false);
            font.drawString("They waited in silence, staring at the full moon glowing in the night sky.", 40, 40);
            font.drawString("A snake slithered past in the grass. Three crickets chirped an evening chorus, and a group of fireflies danced.", 40, 55);
            break;
            
        case 10: // moon ellipse, covered by black ellipse with openCV DONE
            bSendSerialMessage = false;
            img11.draw(30, 60);
            
            for (int i = 0; i < limit; i++) {
                if (contourFinder.blobs[i].area > maxArea){
                    maxArea = contourFinder.blobs[i].area;
                    elementNum = i;
                }
            }
            if (elementNum >= 0) {
                pointerX = ofMap(contourFinder.blobs[elementNum].boundingRect.x, vidX, 0, 0, ofGetWidth(), true);
                ofSetColor(255);
                ofDrawCircle(ofGetWidth()/2, 400, 160);
                ofSetColor(0);
                ofDrawCircle(pointerX/2 + 200, 400, 150);
            }
            ofSetColor(255, 255, 255, 150);
            music11.setPaused(false);
            font.drawString("Soon the world grew quiet all around and Omphalotus gazed into the sky.", 40, 40);
            font.drawString("He watched in wonder as the once luminous moon was covered in a veil of magic shadow.", 40, 55);
            break;
            
        case 11: // 'glowing' eclipse
            bSendSerialMessage = false;
            ofClearAlpha();
            img12.draw(30, 60);
            music12.setPaused(false);
            font.drawString("A small smile crept onto his cap, a satisfying chill rushed up his stalk.", 40, 40);
            font.drawString("He had never seen something so spectacular, so unequivocally beautiful.", 40, 55);
            ofSetColor(255);
            ofDrawCircle(300, 300, 110);
            ofSetColor(0);
            ofDrawCircle(300, 300, 100);
            ofSetColor(255, 150);
            break;
            
        case 12: // particle eyes
            bSendSerialMessage = false;
            img13.draw(30, 60);
            music13.setPaused(false);
            
            for(unsigned int i = 0; i < p.size(); i++){
                p[i].draw();
            }
            currentMode == PARTICLE_MODE_ATTRACT;
            
            ofSetColor(255);
            font.drawString("For the first time he was filled with wonder, and he no longer felt so small.", 40, 40);
            
            break;
            
        case 13: // radial gradient fills screen
            ofSetColor(255);
            ofBackgroundGradient(yellow, white, OF_GRADIENT_CIRCULAR);
            bSendSerialMessage = false;
            music14.setPaused(false);
            font.drawString("He started glowing brighter than the moon.", 250, ofGetHeight()/1.3);
            break;
            
        case 14:
            bSendSerialMessage = false;
            music15.setPaused(false);
            ofSetColor(255);
            font2.drawString("After the Eclipse", 40, 300);
            font.drawString("story by: Amber Glassman", 40, 80);
            font.drawString("illustrated by: Jessica Herzog", 40, 100);
            break;
    }
    
}
Ejemplo n.º 4
0
//--------------------------------------------------------------
void testApp::draw(){
    
    ofBackground(0);
    
    if (ofGetFrameNum() < 10) return;
    
    if (bDrawAudioManager) AM.draw();
    
    
    blah.begin();
    ofClear(0,0,0,255);
    
    ofPushMatrix();
    
    //ofTranslate(-mouseX, -mouseY);
    scenes[0]->draw(); 
    
    ofPopMatrix();
    
	ofClearAlpha();
    blah.end();
    
    ofSetColor(255,255,255);
    blah.draw(500, 800,300, -800);
    
    
    scenes[0]->drawGui();
    
    
    ///grabScreen.loadScreenData(300, 0, 768*(3.0/8.0), 768);
    
    //ofBackground(127,127,127);

    
    //cout << _mapping->_fbo.getWidth() << endl;
    // ----
    _mapping->bind();
    //_mapping->chessBoard(40);
    
    ofSetColor(255,255,255);
    ofRotate(-90, 0,0,1);
    ofTranslate(-768,0);
	
	
    blah.draw(0, 2048,768,-2048);
	
    _mapping->unbind();
    
       
    
   
    ofSetBackgroundAuto(false);
  
    //call blender.begin() to draw onto the blendable canvas
	blender.begin();
	ofClear(0,0,0,255);
	//light gray backaground
	ofSetColor(0, 0, 0);
	//ofRect(0, 0, blender.getCanvasWidth(), blender.getCanvasHeight());
	
	//thick grid lines for blending
	ofSetColor(255, 255, 255);
	ofSetLineWidth(3);
	
	//vertical line
	for(int i = 0; i <= blender.getCanvasWidth(); i+=30){
		ofLine(i, 0, i, blender.getCanvasHeight());
	}
	
	//horizontal lines
	for(int j = 0; j <= blender.getCanvasHeight(); j+= 30){
		ofLine(0, j, blender.getCanvasWidth(), j);		
	}
	
//	//instructions
//	ofSetColor(255, 255, 255);
//	ofRect(10, 10, 300, 100);
//	ofSetColor(0, 0, 0);
//	ofDrawBitmapString("SPACE - toggle show blend\n[g/G] - adjust gamma\n[p/P] - adjust blend power\n[l/L] adjust luminance", 15, 35);
    
    
    float scale = 2048.0f / 1024.0;
    ofPushMatrix();
    ofScale(scale, scale);
    _mapping->drawOutput();
    ofPopMatrix();

    ofSetColor(255,255,255);
    //_mapping->drawFbo();
	
	//call when you are finished drawing
	blender.end();
	
	//this draws to the main window
    
    ofPushMatrix();
    
    
    scale = 1024.0  / 2048.0f;
    
    ofScale(scale, scale);
	//blender.draw();
    ofPopMatrix();
    
    
    ofPushMatrix();
    ofTranslate(1024, 0);
    blender.draw();
    ofPopMatrix();
    
    
    
   
    
    if (ControlsMapping::controlsMapping()->mappingMode() == MAPPING_MODE_INPUT) {
        ofPushMatrix();
        ofScale(0.5, 0.5);
    }
    //-------- mapping of the towers/shapes
    _mapping->draw();
    //_mapping->drawFbo();
    
    if (ControlsMapping::controlsMapping()->mappingMode() == MAPPING_MODE_INPUT) {
        ofPopMatrix();
       
    }
    
    // Draw some instructions.
    ofSetColor(0);
    ofDrawBitmapString("'m' open the mapping controls.\n", 20, 20);
    
    ofDrawBitmapStringHighlight(ofToString(ofGetFrameRate()), ofGetWidth()-100, 100);
   

    ofDrawBitmapStringHighlight(ofToString(ofGetFrameRate()), ofGetWidth()-100, 100);

}
Ejemplo n.º 5
0
void BasicParticles::draw(){;
    float lineWidth = 5;
    
    //read syphon fbo
    syphonFbo.readToPixels(pixels);
    
    //Begin FBO
    toggleFbo ? pingPongFbo1.begin() : pingPongFbo2.begin();
    ofEnableAlphaBlending();
    
    ofClearAlpha();
    
    if (trace) {
        ofSetColor(255, 255, 255, 255);
        !toggleFbo ? pingPongFbo1.draw(0, 0) : pingPongFbo2.draw(0, 0);

        //Fade out the old stuff
        ofSetColor(0,0,0,fade);
        ofFill();
        ofRect(0,0,OUTWIDTH,OUTHEIGHT);
    } else {
        ofClear(0, 0, 0, 255);
    }

    //Draw particles
    for (int i=0; i<particles.size(); i++) {
        particles[i].draw();
    }
    
    //Create new particles
    while (particles.size()<totalCount) {
        createParticle();
    }
    
    //Give new settings to some of the particles
    for (int i=0; i<pkill; i++) {
        reassignParticle();
    }
    
    // Erase particles
    while (particles.size()>totalCount) {
       particles.pop_back();
        if (iterate >= particles.size())
            iterate = 0;
    }
    
    //FBO end
    toggleFbo ? pingPongFbo1.end() : pingPongFbo2.end();

    ofSetColor(255, 255, 255, 255);
    toggleFbo ? pingPongFbo1.draw(0, 0) : pingPongFbo2.draw(0, 0);
    
    ofDisableAlphaBlending();
    
    toggleFbo = !toggleFbo;
    
    //Syphon fbo
    syphonFbo.begin();
    ofClear(0);
    ofClearAlpha();
    ofSetColor(255, 255, 255, 255);
    syphonIn->draw(0, 0, OUTWIDTH/10,OUTHEIGHT/10);
    syphonFbo.end();
    
    //syphonFbo.draw(0,0);
}