Пример #1
0
void musicEffect::renderVariables(){
	if( isType("musicEffect") ) ofClear( ofColor(0, 128) );
	
	int height = 20;
	int posY = 0;
	ofFill();
	
	// draw mono volume
	posY += height;
	ofSetColor(255);
	ofDrawRectangle(0, posY, karmaSoundAnalyser::getInstance().getVolumeMono(true)*ofGetWidth(), height);
	ofSetColor(255, 100);
	ofDrawRectangle(0, posY, karmaSoundAnalyser::getInstance().getVolumeMono(false)*ofGetWidth(), height);
	ofDrawBitmapStringHighlight("volumeMono", 0, posY+15);
	
	// draw left volume
	posY += height;
	ofSetColor(255);
	ofDrawRectangle(0, posY, karmaSoundAnalyser::getInstance().getVolumeLeft(true)*ofGetWidth(), height);
	ofSetColor(255, 100);
	ofDrawBitmapStringHighlight("volumeLeft", 0, posY+15);
	ofDrawRectangle(0, posY, karmaSoundAnalyser::getInstance().getVolumeLeft(false)*ofGetWidth(), height);
	
	// draw right volume
	posY += height;
	ofSetColor(255);
	ofDrawRectangle(0, posY, karmaSoundAnalyser::getInstance().getVolumeRight(true)*ofGetWidth(), height);
	ofSetColor(255, 100);
	ofDrawBitmapStringHighlight("volumeRight", 0, posY+15);
	ofDrawRectangle(0, posY, karmaSoundAnalyser::getInstance().getVolumeRight(false)*ofGetWidth(), height);
	
	
	// draw balance
	posY += height;
	ofSetColor(255);
	ofDrawRectangle( ofGetWidth()/2, posY, (karmaSoundAnalyser::getInstance().getBalance(false)*ofGetWidth()-1)/2, height);
	ofSetColor(255, 100);
	ofDrawBitmapStringHighlight("balance", 0, posY+15);
	ofDrawRectangle( ofGetWidth()/2, posY, (karmaSoundAnalyser::getInstance().getBalance(true)*ofGetWidth()-1)/2, height);

	// draw buffers
	posY += height;
	int bufferSize = karmaSoundAnalyser::getInstance().getBufferSize();
	float bufferWidth = (float) ofGetWidth() / bufferSize;
	for(int i=0; i<bufferSize; i++ ){
		
		ofDrawRectangle( bufferWidth*i, posY+height, bufferWidth, karmaSoundAnalyser::getInstance().getBufferLeft()[i]*height*10);
	}
	ofDrawLine( 0, posY+height, ofGetWidth(), posY+height);
	posY += height;
	
	// show zeroCrossings
	posY += height;
	ofSetColor(255);
	ofDrawRectangle( 0, posY, karmaSoundAnalyser::getInstance().getZeroCrossings()/100.f, height);
	
	// show spectrum variation
	posY += height;
	ofSetColor(255);
	ofDrawRectangle( 0, posY, karmaSoundAnalyser::getInstance().getSpectrumVariation()/100.f, height);
	
}
Пример #2
0
//--------------------------------------------------------------
void ofApp::draw(){
    ofRectangle previewWindow(20, 20, 640, 480);
    ofRectangle playbackWindow(20+640, 20, 640, 480);

    // draw the background boxes
    ofPushStyle();
    ofSetColor(0);
    ofFill();
    ofDrawRectangle(previewWindow);
    ofDrawRectangle(playbackWindow);
    ofPopStyle();
    
    // draw the preview if available
	if(vidRecorder->hasPreview()){
        ofPushStyle();
        ofFill();
        ofSetColor(255);
        // fit it into the preview window, but use the correct aspect ratio
        ofRectangle videoGrabberRect(0,0,vidGrabber.getWidth(),vidGrabber.getHeight());
        videoGrabberRect.scaleTo(previewWindow);
        vidGrabber.draw(videoGrabberRect);
        ofPopStyle();
    } else{
		ofPushStyle();
		// x out to show there is no video preview
        ofSetColor(255);
		ofSetLineWidth(3);
		ofDrawLine(20, 20, 640+20, 480+20);
		ofDrawLine(20+640, 20, 20, 480+20);
		ofPopStyle();
	}
    
    // draw the playback video
    if(recordedVideoPlayback.isLoaded()){
        ofPushStyle();
        ofFill();
        ofSetColor(255);
        // fit it into the preview window, but use the correct aspect ratio
        ofRectangle recordedRect(ofRectangle(0,0,recordedVideoPlayback.getWidth(),recordedVideoPlayback.getHeight()));
        recordedRect.scaleTo(playbackWindow);
        recordedVideoPlayback.draw(recordedRect);
        ofPopStyle();
    }

    ofPushStyle();
    ofNoFill();
    ofSetLineWidth(3);
    if(vidRecorder->isRecording()){
        //make a nice flashy red record color
        int flashRed = powf(1 - (sin(ofGetElapsedTimef()*10)*.5+.5),2)*255;
		ofSetColor(255, 255-flashRed, 255-flashRed);
    }
    else{
    	ofSetColor(255,80);
    }
    ofDrawRectangle(previewWindow);
    ofPopStyle();
    
    
    //draw instructions
    ofPushStyle();
    ofSetColor(255);
    ofDrawBitmapString("' ' space bar to toggle recording", 680, 540);
    ofDrawBitmapString("'v' switches video device", 680, 560);
    ofDrawBitmapString("'a' switches audio device", 680, 580);
    
    //draw video device selection
    ofDrawBitmapString("VIDEO DEVICE", 20, 540);
    for(int i = 0; i < videoDevices.size(); i++){
        if(i == vidRecorder->getVideoDeviceID()){
			ofSetColor(255, 100, 100);
        }
        else{
            ofSetColor(255);
        }
        ofDrawBitmapString(videoDevices[i], 20, 560+i*20);
    }
    
    //draw audio device;
    int startY = 580+20*videoDevices.size();
    ofDrawBitmapString("AUDIO DEVICE", 20, startY);
    startY += 20;
    for(int i = 0; i < audioDevices.size(); i++){
        if(i == vidRecorder->getAudioDeviceID()){
			ofSetColor(255, 100, 100);
        }
        else{
            ofSetColor(255);
        }
        ofDrawBitmapString(audioDevices[i], 20, startY+i*20);
    }
    ofPopStyle();
}
Пример #3
0
void walker::draw() {
    ofSetColor(0,20);
    ofDrawRectangle(x, y, 1, 1);
}
Пример #4
0
//! Draw the slider
void ofSlider::draw() {
    ofSetHexColor(color);
    ofDrawRectangle(x, y, width, height);
    setPosition(buttonX);
}
Пример #5
0
void ofApp::draw()
{
    ofBackground(0,0,0);

    ofSetHexColor(0xffffff);
    
    int row = 0;
    int col = 0;
    
    int x = 0;
    int y = 0;
    
    int w = ofGetWidth() / NUM_COLS;
    int h = ofGetHeight() / NUM_ROWS;
    
    float totalKbps = 0;
    float totalFPS = 0;
    
    for (std::size_t i = 0; i < grabbers.size(); ++i)
    {
        x = col * w;
        y = row * h;

        // draw in a grid
        row = (row + 1) % NUM_ROWS;

        if (row == 0)
        {
            col = (col + 1) % NUM_COLS;
        }

        
        ofPushMatrix();
        ofTranslate(x,y);
        ofSetColor(255,255,255,255);
        grabbers[i]->draw(0,0,w,h); // draw the camera
        
        ofEnableAlphaBlending();
        
        // draw the info box
        ofSetColor(0,80);
        ofDrawRectangle(5,5,w-10,h-10);
        
        float kbps = grabbers[i]->getBitRate() / 1000.0f; // kilobits / second, not kibibits / second
        totalKbps+=kbps;
        
        float fps = grabbers[i]->getFrameRate();
        totalFPS+=fps;
        
        std::stringstream ss;
        
        // ofToString formatting available in 0072+
        ss << "          NAME: " << grabbers[i]->getCameraName() << endl;
        ss << "          HOST: " << grabbers[i]->getHost() << endl;
        ss << "           FPS: " << ofToString(fps,  2/*,13,' '*/) << endl;
        ss << "          Kb/S: " << ofToString(kbps, 2/*,13,' '*/) << endl;
        ss << " #Bytes Recv'd: " << ofToString(grabbers[i]->getNumBytesReceived(),  0/*,10,' '*/) << endl;
        ss << "#Frames Recv'd: " << ofToString(grabbers[i]->getNumFramesReceived(), 0/*,10,' '*/) << endl;
        ss << "Auto Reconnect: " << (grabbers[i]->getAutoReconnect() ? "YES" : "NO") << endl;
        ss << " Needs Connect: " << (grabbers[i]->getNeedsReconnect() ? "YES" : "NO") << endl;
        ss << "Time Till Next: " << grabbers[i]->getTimeTillNextAutoRetry() << " ms" << endl;
        ss << "Num Reconnects: " << ofToString(grabbers[i]->getReconnectCount()) << endl;
        ss << "Max Reconnects: " << ofToString(grabbers[i]->getMaxReconnects()) << endl;
        ss << "  Connect Fail: " << (grabbers[i]->hasConnectionFailed() ? "YES" : "NO") << endl;
        // display neuraltalk's caption
        ss << "       Caption: " << description << endl;

        ofSetColor(255);
        ofDrawBitmapString(ss.str(), 10, 10+12);
        
        ofDisableAlphaBlending();
        
        ofPopMatrix();
    }
    
    // keep track of some totals
    float avgFPS = totalFPS / NUM_CAMERAS;
    float avgKbps = totalKbps / NUM_CAMERAS;

    ofEnableAlphaBlending();
    ofSetColor(0,80);
    ofDrawRectangle(5,5, 150, 40);
    
    ofSetColor(255);
    // ofToString formatting available in 0072+
    ofDrawBitmapString(" AVG FPS: " + ofToString(avgFPS,2/*,7,' '*/), 10,17);
    ofDrawBitmapString("AVG Kb/S: " + ofToString(avgKbps,2/*,7,' '*/), 10,29);
    ofDrawBitmapString("TOT Kb/S: " + ofToString(totalKbps,2/*,7,' '*/), 10,41);
    ofDisableAlphaBlending();

}
Пример #6
0
void Square::draw(){
    ofSetColor(color);
    ofDrawRectangle(_x, _y, w, h);
}
Пример #7
0
//--------------------------------------------------------------
void ofApp::draw(){
    
    switch (mode){
            
        case CALIBRATEDEPTH: // depth threshold calibration mode (with gui)
        {
            float w = width*0.5; float h = height*0.5;
            
            layers[0].draw(0,0,w,h);
            layers[1].draw(w,0,w,h);
            layers[2].draw(0,h,w,h);
            layers[3].draw(w,h,w,h);
            
            // draw gui to adjust depth of each layer threshold
            depthGui.draw();
            
            // draw percentage shown of each layer
            ofSetColor(0);
            ofDrawRectangle(0,height-100,width*0.5,100);
            ofSetColor(255);
            ofPushMatrix();
            ofTranslate(10,height-90);
            for (int l=0; l<4; l++){
                ofTranslate(0,20);
                string pct = "% of layer " + ofToString(l) + ": " + ofToString(layers[l].pctShown);
                ofDrawBitmapString(pct, 0,0);
            }
            ofPopMatrix();
            break;
        }
            
        case KINECT: // manual kinect warping mode - shows original kinect depth img and warp result
        {
            kinect.drawDepth(0,0,640,480);
            kinectWarp.draw(650,0,width-660,(width-660)/640*480);
            for (int i=0; i<4; i++){
                if (cornerSelect == i) ofSetColor(0,255,0);
                ofDrawCircle(kinectCorners[i], 5);
                ofSetColor(255);
            }
            break;
        }
            
        case AUTOKINECT: // auto kinect warping mode - shows warped kinect img and CV estimation results
        {
            ofPushMatrix();
            ofScale(width/640,height/480);
            
            kinectRaw.draw(0,0);
            contourFinder.draw();
            
            ofSetColor(0,255,0);
            for (int p=0; p<4; p++){
                ofDrawCircle(kinectCorners[p].x,kinectCorners[p].y,5);
            }
            ofSetColor(255);
            
            ofPopMatrix();
            break;
        }
            
            
        // normal play mode!
    
        default:
        {
            for (int l=layers.size()-1; l>=0; l--){ // draw layers bottom to top
                layers[l].draw(0,0,width,height);
            }
            break;
        }
    }
}
Пример #8
0
float ofxFontStash2::drawLines(const vector<StyledLine> &lines, float x, float y, bool debug){

	// if possible get rid of this translate:
	#ifndef GL_VERSION_3
	ofPushMatrix();
	ofTranslate(x, y);
	#endif

	ofVec2f offset;
	#ifdef GL_VERSION_3
	offset.x = x * pixelDensity;
	offset.y = y * pixelDensity;
	#endif

//	TS_START("count words");
//	int nDrawnWords;
//	for(int i = 0; i < lines.size(); i++){
//		for(int j = 0; j < lines[i].elements.size(); j++){
//			nDrawnWords ++;
//		}
//	}
//	TS_STOP("count words");

	//debug line heights!
	if(debug){
		TS_START("draw line Heights");
		ofSetColor(0,255,0,32);
		float yy = 0;
		for( const StyledLine &line : lines ){
			ofDrawLine(offset.x + 0.5f, offset.y + yy + 0.5f, offset.x + line.lineW + 0.5f, offset.y + yy + 0.5f);
			yy += line.lineH;
		}
		TS_STOP("draw line Heights");
	}

	ofxFontStashStyle drawStyle;
	drawStyle.fontSize = -1;

	float offY = 0.0f; // only track for return value
	TS_START("draw all lines");

	FONT_STASH_PRE_DRAW;

	#ifndef GL_VERSION_3
	if (pixelDensity != 1.0f){ //hmmmm
		ofScale(1.0f/pixelDensity, 1.0f/pixelDensity);
	}
	#endif


	for(int i = 0; i < lines.size(); i++){
		y += lines[i].lineH;
		
		for(int j = 0; j < lines[i].elements.size(); j++){

			if(lines[i].elements[j].content.type != SEPARATOR_INVISIBLE ){ //no need to draw the invisible chars

				const StyledLine &l = lines[i];
				const LineElement &el = l.elements[j];
				const string & texttt = el.content.styledText.text;

				if (el.content.styledText.style.valid &&
					drawStyle != el.content.styledText.style ){

					drawStyle = el.content.styledText.style;
					TS_START_ACC("applyStyle");
					applyStyle(drawStyle);
					TS_STOP_ACC("applyStyle");
				}
				//lines[i].elements[j].area.y += lines[i].lineH -lines[0].lineH;

				//TS_START_ACC("fonsDrawText");
				fonsDrawText(fs,
							 el.x * pixelDensity + offset.x,
							 (el.baseLineY + l.lineH - lines[0].lineH) * pixelDensity + offset.y,
							 texttt.c_str(),
							 NULL);
				//TS_STOP_ACC("fonsDrawText");

				//debug rects
				if(debug){
					//TS_START_ACC("debug rects");
					if(el.content.type == BLOCK_WORD) ofSetColor(70 * i, 255 - 70 * i, 0, 200);
					else ofSetColor(50 * i,255 - 50 * i, 0, 100);
					const ofRectangle &r = el.area;
					ofDrawRectangle(pixelDensity * r.x, pixelDensity * r.y, pixelDensity * r.width, pixelDensity * r.height);
					ofFill();
				}
			}
		}
	}
	TS_STOP("draw all lines");

	#ifndef GL_VERSION_3
	ofPopMatrix();
	#endif
	FONT_STASH_POST_DRAW;

	if(debug){
		ofSetColor(255);
	}
	return offY;
}
Пример #9
0
//--------------------------------------------------------------
void ofApp::draw(){

    ofBackground(0);

    //----------------------------- 3d
    cam.begin();
    ofSetColor(255);
    
    //----------------------------- copy data into array
    ofPoint data3d[24];
    
    currFrame = (int)(ofGetFrameNum()*0.5) % 30;
    
    for (int i = 0; i < 24; i++){
        data3d[i] = frames[currFrame][i];
    }
    
    ofDrawLine(data3d[10]-ofPoint(10,0,0), data3d[10]+ofPoint(10,0,0));
    ofDrawLine(data3d[18], data3d[19]);
    ofDrawLine(data3d[22], data3d[23]);
    
    ofDrawLine(data3d[6], data3d[7]); // right hand
    ofDrawLine(data3d[14], data3d[15]); // left hand
    
//    for (int i = 0; i < 24; i++){
//        ofDrawCircle(data3d[i], 5);
//        ofDrawBitmapString(i, data3d[i]);
//    }
    
    if(currFrame != prevFrame) {
        if(currFrame == 22) { // foot 1
            currWalks.push_back(getWalkVect(currFrame, 22, 23, 3)); // left foot
            // need rotation based on angle
    //        currWalks.push_back(getWalkVect(currFrame, 6, 7, 3)); // right hand
    //        currWalks.push_back(getWalkVect(currFrame, 14, 15, 3)); // left hand
        } else if (currFrame == 29) { // foot 2
            currWalks.push_back(getWalkVect(currFrame, 18, 19, 3)); // right foot
        }
    }
    vector<int> removeEls;
    int index = 0;
    for(auto& walk : currWalks) {
        if(walk.flag) {
            if(walk.size < walk.maxSize) {
                ofNoFill();
                if(walk.flag & CIRCLE) {
                    ofDrawCircle(walk.intersectionPt, walk.size);
                } else if(walk.flag & RECT) {
                    ofDrawRectangle(walk.intersectionPt, walk.size, walk.size);
                }
                walk.size++;
            } else {
                int removeIndex = index;
                removeEls.push_back(removeIndex);
                index++;
            }
        } else {
            IsLine line = walk.line;
            ofPoint p0 = line.getP0() + (walk.dir * walk.spd);
            ofPoint p1 = line.getP1() + (walk.dir * walk.spd);
            walk.dir.x += 0.1 * ofSignedNoise(walk.line.p0.x/10.0, walk.line.p0.y/10.0, ofGetElapsedTimef()*0.1, 0);
            walk.dir.y += 0.1 * ofSignedNoise(walk.line.p0.x/10.0, walk.line.p0.y/10.0, ofGetElapsedTimef()*0.1, 100);
            walk.line.set(p0 , p1);
            IntersectionData inter1 = is.LinePlaneIntersection(walk.line, plane3);
            IntersectionData inter2 = is.LinePlaneIntersection(walk.line, plane1);
            IntersectionData inter3 = is.LinePlaneIntersection(walk.line, plane2);
            if(inter1.isIntersection){
                walk.intersectionPt = inter1.pos;
                walk.flag = CIRCLE;
            } else if(inter2.isIntersection){
                walk.intersectionPt = inter2.pos;
                walk.flag = RECT;
            } else if(inter3.isIntersection){  // Unused plane right now
                walk.intersectionPt = inter3.pos;
                walk.flag = RECT;
            } else {
                walk.line.draw();
            }
//             walk.line.draw();
//            ofFill();
//            plane1.draw();
//            plane2.draw();
//            plane3.draw();
        }
    }
    for(auto& el : removeEls) {
        currWalks.erase(currWalks.begin()+el);
    }
    
    prevFrame = currFrame;
}
void ofxDatGuiComponent::drawBackground()
{
    ofFill();
    ofSetColor(mStyle.color.background, mStyle.opacity);
    ofDrawRectangle(x, y, mStyle.width, mStyle.height);
}
void ofxDatGuiComponent::drawStripe()
{
    ofSetColor(mStyle.stripe.color);
    ofDrawRectangle(x, y, mStyle.stripe.width, mStyle.height);
}
void TownDashboardRenderer::draw()
{
    ofEnableBlendMode(OF_BLENDMODE_ALPHA);
    //type
    _typeLayerFbo.begin();
    
    ofClear(0, 0, 0, 0);
    ofBackground(0, 0, 0, 0);
    
    searchingStringImage.draw(0, 0);
    ofPushMatrix();

    ofSetColor(0,255,255);
    int maxVisibleCharacters = 14;
    string subString = _townName.length() > maxVisibleCharacters ? _townName.substr(0, maxVisibleCharacters) : _townName;
    if (_townName.length() <= (maxVisibleCharacters))
    {
        int insertWs = maxVisibleCharacters - _townName.length() - 1;
        for(int i = 0; i<insertWs; i++)
        {
            subString.push_back('p');
        }
    }
    else{
        subString += "...";
        _townName = subString;// + "...";
    }
    ofRectangle fullRect = font.getStringBoundingBox(subString, 0, 0);
    int p = 0;//running count
    ofRectangle runningStringDimensions;
    
    float debugXPos = 2600.0f;
    
    for(char &c : _townName)
    {
        int nVal = min(p + 1, (int)subString.length());
        
        string runningString = subString.substr(0, nVal);
        runningStringDimensions = font.getStringBoundingBox(runningString, 0, 0);
        string thisCharString = ofToString(c);
        ofRectangle thisCharDimensions = font.getStringBoundingBox(thisCharString, 0, 0);
        
        float diff = runningStringDimensions.width - thisCharDimensions.width;
        float debugWidth = fullRect.width;
        float dPos = diff / fullRect.width;
        ofVec2f positionOnCurve = spline2D.sampleAt(dPos);
        ofVec2f tangent = getTangent(dPos, spline2D);
        float rot = atan2(tangent.y, tangent.x) * RAD_TO_DEG;
        
        ofPushMatrix();
        
        ofTranslate(positionOnCurve.x, positionOnCurve.y);
        ofRotate(rot, 0, 0, 1);
        font.drawString(thisCharString, 0, 0);
        
        ofPopMatrix();
        
        if(_debugMode)
        {
            //debug stuff off screen
            ofSetColor(255, 0, 255);
            ofDrawRectangle(debugXPos, p * 100, runningStringDimensions.width, runningStringDimensions.height);
            ofSetColor(0, 255, 0);
            ofDrawRectangle(debugXPos + diff, runningStringDimensions.height + (p * 100), thisCharDimensions.width, 3000);
            ofSetColor(0, 0, 0);
            font.drawString(runningString, debugXPos, 50 + (p * 100));
        }
        
        ofPopMatrix();
        ++p;
        
    }
    ofSetColor(255);
    searchingStringImage.draw(0, 0);
    _typeLayerFbo.end();
    
    //drawn the type
    //black pass
    _blackPassFbo.begin();
    ofClear(0, 0, 0, 255);
    ofBackground(0, 0, 0, 255);
    
    _typeLayerFbo.draw(0, 0);
    
    _blackPassFbo.end();
    
    //glow
    glow.clear();
    glow << _blackPassFbo;
    
    
    
    _glowPassFbo.begin();
    ofClear(0, 0, 0);
    ofBackground(0, 0, 0);
    ofRectangle r = ofRectangle(0, 0, PRINT_DIMENSIONS_WIDTH, PRINT_DIMENSIONS_HEIGHT);
    glow.ofxFXObject::draw(r);
    _glowPassFbo.end();
    
    //final render
    _exportFbo.begin();
    
    ofClear(0, 0, 0);
    ofBackground(0, 0, 0);
//    backgroundImage.draw(0, 0);
    blendImage.draw(0, 0);
    _typeLayerFbo.draw(0, 0);

    ofEnableBlendMode(OF_BLENDMODE_ADD);

    _glowPassFbo.draw(0, 0);
    ofEnableBlendMode(OF_BLENDMODE_ALPHA);
    
    _exportFbo.end();
    
}
Пример #13
0
//--------------------------------------------------------------
void ofApp::draw(){

  ofBackground(0);
  ofEnableAlphaBlending();

  // ofFill();

	// draw the debugging X
  if(debug) {
  	areaX[0] = (ofGetWidth() / 2) - (ofGetHeight() / 2);
  	areaX[1] = (ofGetWidth() / 2) + (ofGetHeight() / 2);

	  ofDrawLine(areaX[0], 0, areaX[1], ofGetHeight());
    ofDrawLine(areaX[0], ofGetHeight(), areaX[1], 0);
  }

  // draw to the fbo
  fbo.begin();

    ofClear(0);

    ofPushMatrix();
  	myBicho[bichoActive].draw();

    if(debug) {
      ofSetColor(100);
      ofNoFill();
      // add a frame around the fbo to check boundries
      ofDrawRectangle(1,1,fbo.getWidth()-1,fbo.getHeight()-1);
    }

    ofPopMatrix();

  fbo.end();

  // we don't touch this anymore...
  fbo.setAnchorPercent(.5,.5);

  ofPushMatrix();
    ofTranslate(ofGetWidth() / 2, ofGetHeight() / 2 - safezone);
    ofScale(-1,1,1);
    ofRotate(0);
    fbo.draw(myBicho[bichoActive].bichoX,myBicho[bichoActive].bichoY);
  ofPopMatrix();

  ofPushMatrix();
    ofTranslate(ofGetWidth() / 2 + safezone, ofGetHeight() / 2);
    ofScale(-1,1,1);
    ofRotate(270);
    fbo.draw(myBicho[bichoActive].bichoX,myBicho[bichoActive].bichoY);
  ofPopMatrix();

  ofPushMatrix();
    ofTranslate(ofGetWidth() / 2, ofGetHeight() / 2 + safezone);
    ofScale(-1,1,1);
    ofRotate(180);
    fbo.draw(myBicho[bichoActive].bichoX,myBicho[bichoActive].bichoY);
  ofPopMatrix();

  ofPushMatrix();
    ofTranslate(ofGetWidth() / 2 - safezone, ofGetHeight() / 2);
    ofScale(-1,1,1);
    ofRotate(90);
    fbo.draw(myBicho[bichoActive].bichoX,myBicho[bichoActive].bichoY);
  ofPopMatrix();

  ofDisableAlphaBlending();

  // raw outputs
  if(debug) {
    gui.draw();

    ofDrawBitmapString("bicho: " + ofToString(bichoActive), 30, ofGetHeight() - 120);
    ofDrawBitmapString("total: " + ofToString(bichosTotal), 30, ofGetHeight() - 100);
    ofDrawBitmapString("opacity: " + ofToString(myBicho[bichoActive].bichoOpacity), 30, ofGetHeight() - 80);
    ofDrawBitmapString("x: " + ofToString(myBicho[bichoActive].bichoX), 30, ofGetHeight() - 60);
    ofDrawBitmapString("y: " + ofToString(myBicho[bichoActive].bichoY), 30, ofGetHeight() - 40);
  }

}
Пример #14
0
void Ball::Draw(float sizem){
    int size = sizem+_size;
    
    ofSetColor(_color);
    
    if(_point == 2){
    ofDrawCircle(_x, _y, size);
    } else if(_point == 3){
        ofDrawTriangle(_x+size, _y+size, _x-size, _y+size, _x, _y-size);
        
    }else if(_point==4){
        ofDrawRectangle(_x-(size/2), _y-(size/2), size, size);
    }else if(_point==5){
    
        ofSetPolyMode(OF_POLY_WINDING_NONZERO);
        ofBeginShape();
        
        ofVertex((_x + size * cos(1 * 2 * PI / 5)), (_y + size * sin(1 * 2 * PI / 5)));
        ofVertex((_x + size * cos(2 * 2 * PI / 5)), (_y + size * sin(2 * 2 * PI / 5)));
        ofVertex((_x + size * cos(3 * 2 * PI / 5)), (_y + size * sin(3 * 2 * PI / 5)));
        ofVertex((_x + size * cos(4 * 2 * PI / 5)), (_y + size * sin(4 * 2 * PI / 5)));
        ofVertex((_x + size * cos(5 * 2 * PI / 5)), (_y + size * sin(5 * 2 * PI / 5)));
      
        ofEndShape();
        
    }else if(_point==6){
        
        ofSetPolyMode(OF_POLY_WINDING_NONZERO);
        ofBeginShape();
        ofVertex((_x + size * cos(1 * 2 * PI / 6)), (_y + size * sin(1 * 2 * PI / 6)));
        ofVertex((_x + size * cos(2 * 2 * PI / 6)), (_y + size * sin(2 * 2 * PI / 6)));
        ofVertex((_x + size * cos(3 * 2 * PI / 6)), (_y + size * sin(3 * 2 * PI / 6)));
        ofVertex((_x + size * cos(4 * 2 * PI / 6)), (_y + size * sin(4 * 2 * PI / 6)));
        ofVertex((_x + size * cos(5 * 2 * PI / 6)), (_y + size * sin(5 * 2 * PI / 6)));
        ofVertex((_x + size * cos(6 * 2 * PI / 6)), (_y + size * sin(6 * 2 * PI / 6)));
        ofEndShape();
        
    }else if(_point==7){
        
        ofSetPolyMode(OF_POLY_WINDING_NONZERO);
        ofBeginShape();
        ofVertex((_x + size * cos(1 * 2 * PI / 7)), (_y + size * sin(1 * 2 * PI / 7)));
        ofVertex((_x + size * cos(2 * 2 * PI / 7)), (_y + size * sin(2 * 2 * PI / 7)));
        ofVertex((_x + size * cos(3 * 2 * PI / 7)), (_y + size * sin(3 * 2 * PI / 7)));
        ofVertex((_x + size * cos(4 * 2 * PI / 7)), (_y + size * sin(4 * 2 * PI / 7)));
        ofVertex((_x + size * cos(5 * 2 * PI / 7)), (_y + size * sin(5 * 2 * PI / 7)));
        ofVertex((_x + size * cos(6 * 2 * PI / 7)), (_y + size * sin(6 * 2 * PI / 7)));
         ofVertex((_x + size * cos(7 * 2 * PI / 7)), (_y + size * sin(7 * 2 * PI / 7)));
        ofEndShape();
        
    }else if(_point==8){
        
        ofSetPolyMode(OF_POLY_WINDING_NONZERO);
        ofBeginShape();
        ofVertex((_x + size * cos(1 * 2 * PI / 8)), (_y + size * sin(1 * 2 * PI / 8)));
        ofVertex((_x + size * cos(2 * 2 * PI / 8)), (_y + size * sin(2 * 2 * PI / 8)));
        ofVertex((_x + size * cos(3 * 2 * PI / 8)), (_y + size * sin(3 * 2 * PI / 8)));
        ofVertex((_x + size * cos(4 * 2 * PI / 8)), (_y + size * sin(4 * 2 * PI / 8)));
        ofVertex((_x + size * cos(5 * 2 * PI / 8)), (_y + size * sin(5 * 2 * PI / 8)));
        ofVertex((_x + size * cos(6 * 2 * PI / 8)), (_y + size * sin(6 * 2 * PI / 8)));
        ofVertex((_x + size * cos(7 * 2 * PI / 8)), (_y + size * sin(7 * 2 * PI / 8)));
        ofVertex((_x + size * cos(8 * 2 * PI / 8)), (_y + size * sin(8 * 2 * PI / 8)));
        ofEndShape();
        
    }
    
}
Пример #15
0
//--------------------------------------------------------------
void ofApp::draw(){
    
    int padding = 8;
    
    ofPushMatrix();
    
    ofTranslate(padding, padding*3);
    
    for (int x=0; x<GRID_SIZE; x++){
        for (int y=0; y<GRID_SIZE; y++){
            if (gridf[x][y] > 0){
                ofFill();
                ofColor thisCol = onColor * gridf[x][y] + offColor * (1-gridf[x][y]);
                ofSetColor(thisCol);
            }else{
                ofNoFill();
                ofSetColor(onColor);
            }
            
            ofDrawRectangle(x*cellSize, y*cellSize, cellSize, cellSize);
            
            //showing the array number
//            ofSetColor(0);
//            ofDrawBitmapString(ofToString(x*GRID_SIZE+y), x*cellSize+1, y*cellSize+13);
        }
    }
    
    //label it
    ofDrawBitmapString("Game:", 0, -4);
    
    ofPopMatrix();
    
    //let's draw the nasty sound we're making too
    int boxHeight = 64;
    float graphHeight = boxHeight - padding;
    
    ofPushMatrix();
    ofTranslate(padding, ofGetHeight()-padding*4);
    
    ofSetColor(onColor);
    for (int i=0; i<bufferSize-1; i++){
        
        float valA = audioValues[i] * graphHeight;
        float valB = audioValues[i+1] * graphHeight;
        
        ofDrawLine(i, -valA, i+1, -valB);
            
    }
    
    //frame it
    ofNoFill();
    ofDrawRectangle(0,padding/2, 256, -boxHeight);
    
    //label it
    ofDrawBitmapString("Audio Buffer:", 0, -boxHeight -2);
    
    ofPopMatrix();
    
    
    ofSetColor(onColor);
    ofDrawBitmapString("Andy Wallace  @andy_makes  2016", padding, ofGetHeight()-4);
    
    if (captureScreen || captureOneScreenshot){
        captureOneScreenshot = false;
        ofImage screenPic;
        screenPic.allocate(ofGetWidth(), ofGetHeight(), OF_IMAGE_COLOR);
        screenPic.grabScreen(0, 0, ofGetWidth(), ofGetHeight());
        screenPic.save("captures/pic"+ofToString(ofGetFrameNum())+".png");
        cout<<"snap "<<ofGetFrameNum()<<endl;
    }

}
Пример #16
0
//--------------------------------------------------------------
void ofApp::draw(){
    
    // draw the bug holes
    for(unsigned int i=0; i<holes.size(); i++) {
        ofSetColor(100);
		ofDrawCircle(holes[i], 10);
        ofSetColor(40);
		ofDrawCircle(holes[i], 7);
    }
    
    for(unsigned int i=0; i<bugs.size(); i++) {
        bugs[i].draw();
    }
    
    // draw the bullets
    for(unsigned int i=0; i<bullets.size(); i++) {
        bullets[i].draw();
    }
    
    
    
    // game stats
    ofSetColor(10);
    ofDrawBitmapString("Bullets "+ofToString(bullets.size())+"\nBugs Killed: "+ofToString(bugsKilled), 20, 20);
    
    
    // gun
    ofVec2f gunPos(ofGetWidth()/2, ofGetHeight()-20);
    ofVec2f mousePos(ofGetMouseX(), ofGetMouseY());
    
    // get the vector from the mouse to gun
    ofVec2f vec = mousePos - gunPos;
    vec.normalize();
    vec *= 100;
    
    // get the angle of the vector for rotating the rect
    float angle = ofRadToDeg(atan2(vec.y, vec.x)) - 90;
    
    ofPushMatrix();
    ofTranslate(gunPos.x, gunPos.y);    
    ofRotateZ(angle);
    
    ofFill();
    ofSetColor(10);
    ofDrawRectangle(-10, 0, 20, 100);
    
    float bulletPct = ofMap(bullets.size(), 0, maxBullets, 0.0, 100.0);
    ofSetColor(100);
    ofDrawRectangle(-10, 0, 20, bulletPct);
    
    ofSetColor(100);
    ofDrawRectangle(-10, 90, 20, 10);
    
    if(bFire) {
        ofSetColor(220, 0, 0);
        ofDrawRectangle(-10, 97, 20, 3);
    }
    ofPopMatrix();
    
    ofSetColor(255);
	ofDrawCircle(gunPos.x, gunPos.y, 2);
    
}
void ofxTimeMeasurements::draw(int x, int y) {

	if (!enabled){
		//drawString(ofToString(fr, msPrecision), 10, fontSize);
		return;
	}
	
	float fr = ofGetFrameRate();
	uint64_t timeNow;
	if(internalBenchmark){
		timeNow = TM_GET_MICROS();
	}
	currentFrameNum = ofGetFrameNum();

	drawLines.clear();
	float percentTotal = 0.0f;
	float timePerFrame = 1000.0f / desiredFrameRate;

	mutex.lock();

	vector<TimeMeasurement*> toResetUpdatedLastFrameFlag;

	//update time stuff, build draw lists
	for( unordered_map<string,TimeMeasurement*>::iterator ii = times.begin(); ii != times.end(); ++ii ){
		TimeMeasurement* t = ii->second;
		string key = ii->first;
		if(!t->measuring){
			if (t->life > 0.01){
				t->life *= idleTimeColorDecay; //decrease life
			}else{ //life decays very slow when very low
				t->life *= deadThreadExtendedLifeDecSpeed; //decrease life very slowly
			}
		}
//		if (!t->updatedLastFrame && averaging){ // if we didnt update that time, make it tend to zero slowly
//			t->avgDuration = (1.0f - timeAveragePercent) * t->avgDuration;
//		}
		toResetUpdatedLastFrameFlag.push_back(t);
	}

	unordered_map<ThreadId, ThreadInfo>::iterator ii;
	vector<ThreadId> expiredThreads;

	//lets make sure the Main Thread is always on top
	vector< ThreadContainer > sortedThreadList;

	for( ii = threadInfo.begin(); ii != threadInfo.end(); ++ii ){ //walk all thread trees
		ThreadContainer cont;
		cont.id = ii->first;
		cont.info = &ii->second;
		if (isMainThread(ii->first)){ //is main thread
			sortedThreadList.insert(sortedThreadList.begin(), cont);
		}else{
			sortedThreadList.push_back(cont);
		}
	}
	std::sort(sortedThreadList.begin(), sortedThreadList.end(), compareThreadPairs);

	#if defined(USE_OFX_HISTORYPLOT)
	vector<ofxHistoryPlot*> plotsToDraw;
	#endif

	for( int k = 0; k < sortedThreadList.size(); k++ ){ //walk all thread trees

		ThreadId thread = sortedThreadList[k].id;
		core::tree<string> &tr = sortedThreadList[k].info->tree;

		ThreadInfo & tinfo = threadInfo[thread];
		PrintedLine header;
		header.formattedKey = "+ " + *tr;
		header.color = tinfo.color;
		header.lineBgColor = ofColor(header.color, dimColorA * 2); //header twice as alpha
		header.key = *tr; //key for selection, is thread name
		drawLines.push_back(header); //add header to drawLines

		int numAlive = 0;
		int numAdded = 0;

		core::tree<string>::iterator wholeTreeWalker = tr.in();
		bool finishedWalking = false;
		float winW = ofGetWidth();

		while( !finishedWalking ){

			string key = *wholeTreeWalker;
			TimeMeasurement * t = times[*wholeTreeWalker];
			if(t->thread == thread){

				#if defined(USE_OFX_HISTORYPLOT)
				bool plotActive = false;
				ofxHistoryPlot* plot = plots[key];
				if(plot){
					if(t->settings.plotting){
						if(t->updatedLastFrame){
							//update plot res every now and then
							if(currentFrameNum%120 == 1) plot->setMaxHistory(MIN(maxPlotSamples, winW * plotResolution));
							if (!freeze) {
								if (t->accumulating) {
									plot->update(t->microsecondsAccum / 1000.0f);
								}
								else {
									plot->update(t->avgDuration / 1000.0f);
								}
							}
						}
						plotsToDraw.push_back(plot);
						plotActive = true;
					}
				}
				#endif

				bool visible = t->settings.visible;
				bool alive = t->life > 0.0001;
				if(alive){
					numAlive++;
				}

				if (visible && (removeExpiredTimings ? alive : true)){
					PrintedLine l;
					l.key = key;
					l.tm = t;
					l.lineBgColor = ofColor(tinfo.color, dimColorA);

					int depth = wholeTreeWalker.level();
					for(int i = 0; i < depth; ++i) l.formattedKey += " ";

					if (wholeTreeWalker.size() == 0){
						l.formattedKey += "-";
					}else{
						l.formattedKey += "+";
					}
					l.formattedKey += key + string(t->accumulating ? "[" + ofToString(t->numAccumulations)+ "]" : "" );
					l.isAccum = t->accumulating;
					l.time = getTimeStringForTM(t);
					if(drawPercentageAsGraph){
						l.percentGraph = getPctForTM(t);
					}

					l.color = tinfo.color * ((1.0 - idleTimeColorFadePercent) + idleTimeColorFadePercent * t->life);
					if (!t->settings.enabled){
						if(t->ifClause){
							l.color = disabledTextColor;
						}else{
							l.color = disabledTextColor.getInverted();
						}
					}

					#if defined(USE_OFX_HISTORYPLOT)
					if(plotActive){
						l.plotColor = ofColor(plots[key]->getColor(), 200);
					}
					#endif

					if (menuActive && t->key == selection){
						if(currentFrameNum%5 < 4){
							l.color.invert();
							l.lineBgColor = ofColor(tinfo.color, dimColorA * 1.5);
						}
					}

					drawLines.push_back(l);
					numAdded++;
				}

				//only update() and draw() count to the final %
				if(key == TIME_MEASUREMENTS_DRAW_KEY || key == TIME_MEASUREMENTS_UPDATE_KEY){
					percentTotal += (t->avgDuration * 0.1f) / timePerFrame;
				}
				//reset accumulator
				t->accumulating = false;
				t->numAccumulations = 0;
				t->microsecondsAccum = 0;
			}

			//control the iterator to walk the tree "recursively" without doing so.
			if(wholeTreeWalker.size()){
				wholeTreeWalker = wholeTreeWalker.in();
			}else{
				if ( wholeTreeWalker.next() == wholeTreeWalker.end() ){
					wholeTreeWalker = wholeTreeWalker.out();
					while( wholeTreeWalker.next() == wholeTreeWalker.end() && wholeTreeWalker != tr){
						wholeTreeWalker = wholeTreeWalker.out();
					}
					if(wholeTreeWalker == tr){
						finishedWalking = true;
					}else{
						wholeTreeWalker++;
					}
				}else{
					++wholeTreeWalker;
				}
			}
		}

		#if defined(USE_OFX_HISTORYPLOT)
		numActivePlots = plotsToDraw.size();
		#endif

		if (numAlive == 0 && removeExpiredThreads){
			//drop that whole section if all entries in it are not alive
			for(int i = 0; i < numAdded + 1; i++){
				if(drawLines.size() > 0){
					int delID = drawLines.size() - 1;
					//clear selection if needed
					if (selection == drawLines[delID].key){
						selection = TIME_MEASUREMENTS_UPDATE_KEY;
					}
					drawLines.erase(drawLines.begin() + delID);
				}
			}
			expiredThreads.push_back(thread);
		}
	}

	//delete expired threads
	for(int i = 0; i < expiredThreads.size(); i++){
		unordered_map<ThreadId, ThreadInfo>::iterator treeIt = threadInfo.find(expiredThreads[i]);
		if (treeIt != threadInfo.end()) threadInfo.erase(treeIt);
	}

	mutex.unlock();

	updateLongestLabel();

	//find headers
	int tempMaxW = -1;
	vector<int> headerLocations;
	for( int i = 0; i < drawLines.size(); i++ ){
		if (drawLines[i].tm){ //its a measurement
			//add padding to draw in columns
			for(int j = drawLines[i].formattedKey.length(); j < longestLabel; j++){
				drawLines[i].formattedKey += " ";
			}
			if (!drawLines[i].tm->error){
				drawLines[i].shouldDrawPctGraph = true;
				drawLines[i].fullLine = drawLines[i].formattedKey + " " + drawLines[i].time;
			}else{
				drawLines[i].shouldDrawPctGraph = true;
				drawLines[i].fullLine = drawLines[i].formattedKey + "    Error!" ;
			}
			int len = drawLines[i].fullLine.length();
			if(len > tempMaxW) tempMaxW = len;
			if(drawLines[i].tm->measuring) drawLines[i].shouldDrawPctGraph = false;
		}else{ //its a header
			drawLines[i].fullLine = drawLines[i].formattedKey;
			drawLines[i].shouldDrawPctGraph = false;
			headerLocations.push_back(i);
		}
	}

	int numInstructionLines = 0;
	if(menuActive){ //add instructions line if menu active
		PrintedLine l;
		//title line
		l.color = hilightColor;
		l.lineBgColor = ofColor(hilightColor, dimColorA * 2);
		l.fullLine = " KEYBOARD COMMANDS "; //len = 23
		int numPad = 2 + ceil((getWidth() - charW * (23)) / charW);
		for(int i = 0; i < floor(numPad/2.0); i++ ) l.fullLine = "#" + l.fullLine;
		for(int i = 0; i < ceil(numPad/2.0); i++ ) l.fullLine += "#";
		l.fullLine = " " + l.fullLine;
		drawLines.push_back(l); numInstructionLines++;
		//key command lines
		l.lineBgColor = ofColor(hilightColor, dimColorA);
		l.fullLine = " 'UP/DOWN' select measur."; drawLines.push_back(l); numInstructionLines++;
		l.fullLine = " 'LFT/RGHT' expand/collaps"; drawLines.push_back(l); numInstructionLines++;
		l.fullLine = " 'RET' toggle code section"; drawLines.push_back(l); numInstructionLines++;
		l.fullLine = " 'A' average measurements"; drawLines.push_back(l); numInstructionLines++;
		l.fullLine = " 'F' freeze measurements"; drawLines.push_back(l); numInstructionLines++;
		l.fullLine = " 'L' cycle widget location"; drawLines.push_back(l); numInstructionLines++;
		l.fullLine = " 'PG_DWN' en/disable addon"; drawLines.push_back(l); numInstructionLines++;
		l.fullLine = " 'B' internal benchmark"; drawLines.push_back(l); numInstructionLines++;
		l.fullLine = " 'V' expand all"; drawLines.push_back(l); numInstructionLines++;
		#if defined USE_OFX_HISTORYPLOT
		l.fullLine = " 'P' plot selectd measur."; drawLines.push_back(l); numInstructionLines++;
		#endif
	}

	maxW = tempMaxW;

	ofSetupScreen(); //mmmm----
	ofPushStyle();
	ofSetRectMode(OF_RECTMODE_CORNER);
	ofSetDrawBitmapMode(OF_BITMAPMODE_SIMPLE);
	ofEnableAlphaBlending();

	ofPushMatrix();
	ofScale(uiScale,uiScale);

	ofFill();

	//draw all plots
	#if defined(USE_OFX_HISTORYPLOT)
	//int numCols = plotsToDraw.size()

	float highest = FLT_MIN;
	for(auto plot : plotsToDraw){
		if(allPlotsTogether){ //lets find the range that covers all the plots
			float high = plot->getHigestValue();
			if (high > highest) highest = high;
			plot->setDrawTitle(false);
			plot->setDrawBackground(false);
			plot->setShowSmoothedCurve(false);
		}else{
			plot->setDrawTitle(true);
			plot->setDrawBackground(true);
			plot->setLowerRange(0);
			plot->setShowSmoothedCurve(true);
		}
	}

	float canvasW = ofGetWidth();
	float canvasH = ofGetHeight();

	if(allPlotsTogether && plotsToDraw.size()){
		ofSetColor(0, 230);
		ofDrawRectangle(0, canvasH - plotHeight, canvasW / uiScale, plotHeight);
	}

	for(int i = 0; i < plotsToDraw.size(); i++){
		int y = (plotBaseY == 0 ? canvasH : plotBaseY) / uiScale - plotHeight * (i + 1);
		if(allPlotsTogether){
			plotsToDraw[i]->setRange(0, highest);
			y = ((plotBaseY == 0 ? canvasH : plotBaseY) - plotHeight) / uiScale;
		}
		plotsToDraw[i]->draw(0, y, canvasW / uiScale, plotHeight);
		if(!allPlotsTogether){
			ofSetColor(99);
			if(i != plotsToDraw.size() -1){
				ofLine(0, y, canvasW / uiScale, y );
			}
		}

		if(allPlotsTogether){
			ofSetColor(plotsToDraw[i]->getColor());
			deque<float>& vals = plotsToDraw[i]->getValues();
			float val = 0.0f;
			if(!vals.empty()) val = vals.back();
			string msg = plotsToDraw[i]->getVariableName() + " " + ofToString(val, 2);
			drawString(msg, canvasW - charW * msg.size() - 2, ofGetHeight() - plotHeight - 4 - charH * (plotsToDraw.size() -1 - i));
		}
	}
	#endif

	float totalW = getWidth();
	float totalH = getHeight();

	//draw bg rect
	ofSetColor(bgColor);
	ofDrawRectangle(x, y + 1, totalW, totalH);

	//draw all lines
	for(int i = 0; i < drawLines.size(); i++){
		ofSetColor(drawLines[i].lineBgColor);
		ofRectangle lineRect = ofRectangle(x, y + 2 + i * charH, totalW, charH + (drawLines[i].tm ? 0 : 1));
		ofDrawRectangle(lineRect);
		if(drawLines[i].isAccum && drawLines[i].tm != NULL){
			ofSetColor(drawLines[i].color, 128);
			ofDrawRectangle(x + totalW,
							y + 3 + i * charH,
							-5,
							charH - 1 );
		}
		ofSetColor(drawLines[i].color);
		drawString(drawLines[i].fullLine, x , y + (i + 1) * charH);
		if(drawLines[i].plotColor.a > 0){ //plot highlight on the sides
			ofSetColor(drawLines[i].plotColor);
			float y1 = y + 2.4f + i * charH;
			ofDrawTriangle(	x, y1, 
							x, y1 + charH, 
							x + charW * 0.7f, y1 + charH * 0.5f);
		}

		if(drawPercentageAsGraph && drawLines[i].shouldDrawPctGraph && drawLines[i].percentGraph > 0.02f){
			float ww = charW * 5.5;
			float xx = lineRect.x + lineRect.width - charW * 7;
			float pct = MIN(drawLines[i].percentGraph, 1.0);
			unsigned char a = 64;
			ofColor gC;
			if(drawLines[i].percentGraph > 1.0){
				gC = ofColor(255,0,0, (currentFrameNum%4 > 2) ? 1.5 * a : a);
			}else{
				gC = ofColor(drawLines[i].lineBgColor, a) * (1.0f - pct) + ofColor(255,0,0,a) * pct;
			}

			ofSetColor(gC);
			ofDrawRectangle( xx,
							lineRect.y + 0.2 * lineRect.height ,
							ww * pct,
							lineRect.height * 0.65
							);
		}
	}

	if(internalBenchmark){
		float offset = 0;
		if(drawLocation == TIME_MEASUREMENTS_TOP_LEFT ||
		   drawLocation == TIME_MEASUREMENTS_TOP_RIGHT ||
		   drawLocation == TIME_MEASUREMENTS_CUSTOM_LOCATION ){
			offset = (drawLines.size() + 2.5) * charH;
		}
		ofSetColor(0);
		ofDrawRectangle(x, offset + y - charH, totalW, charH);
		ofSetColor(currentFrameNum%3 ? 255 : 64);
		drawString(" Meas: " + ofToString(wastedTimeAvg / 1000.f, 2) + "ms " +
				   " Draw: " + ofToString(wastedTimeDrawingAvg / 1000.f, 2) + "ms ",
				   x, offset + y - charH * 0.12);
	}

	if (freeze) {
		if(currentFrameNum%5 < 4) ofSetColor(frozenColor);
		else ofSetColor(ofColor::white);
		drawString("Frozen! 'F'", x + totalW - 13 * charW, y + charH );
	}

	{//lines
		ofSetColor(hilightColor);
		ofMesh lines;
		ofSetLineWidth(0.1);
		lines.setMode(OF_PRIMITIVE_LINES);
		float fuzzyFix = 0.5;
		float yy = y+1 + fuzzyFix;
		lines.addVertex(ofVec2f(x, yy));
		lines.addVertex(ofVec2f(x + totalW, yy));
		yy = y + totalH - charH - 3 + fuzzyFix;
		lines.addVertex(ofVec2f(x, yy));
		lines.addVertex(ofVec2f(x + totalW, yy));
		yy = y + totalH + fuzzyFix;
		lines.addVertex(ofVec2f(x, yy));
		lines.addVertex(ofVec2f(x + totalW, yy));
		if(menuActive){
			yy = y + totalH + fuzzyFix - (numInstructionLines + 1) * charH - 3;
			lines.addVertex(ofVec2f(x, yy));
			lines.addVertex(ofVec2f(x + totalW, yy));
			yy = y + totalH + fuzzyFix - (numInstructionLines) * charH - 3;
			lines.addVertex(ofVec2f(x, yy));
			lines.addVertex(ofVec2f(x + totalW, yy));
		}
		lines.draw();
	}//lines

	//print bottom line, fps and stuff
	bool missingFrames = ( fr < desiredFrameRate - 1.0 ); // tolerance of 1 fps TODO!
	static char msg[128];

	sprintf(msg, "%2.1f fps % 5.1f%%", fr, percentTotal );
	if(missingFrames){
		ofSetColor(170,33,33); //reddish fps below desired fps
	}else{
		ofSetColor(hilightColor);
	}
	int len = strlen(msg);
	string pad = " ";
	int diff = (maxW - len) - 1;
	for(int i = 0; i < diff; i++) pad += " ";
	int lastLine = ( drawLines.size() + 1 ) * charH + 2;
	drawString( pad + msg, x, y + lastLine );
	
	//show activate menu key
	if(menuActive ) ofSetColor(hilightColor.getInverted());
	else ofSetColor(hilightColor);
	drawString(" '" + ofToString(char(activateKey)) + "'", x, y + lastLine);

	//show averaging warning
	if (averaging) {
		if (currentFrameNum % 5 < 2) ofSetColor(hilightColor);
		else ofSetColor(ofColor::limeGreen);
		drawString(" avg!", x + charW * 3.5, y + lastLine);
	}

	for(int i = 0; i < toResetUpdatedLastFrameFlag.size(); i++){
		toResetUpdatedLastFrameFlag[i]->updatedLastFrame = false;
	}
	ofPopMatrix();
	ofPopStyle();

	if(internalBenchmark){
		wastedTimeDrawingThisFrame += TM_GET_MICROS() - timeNow;
		wastedTimeAvg = wastedTimeThisFrame * 0.025f + 0.975f * wastedTimeAvg;
		wastedTimeDrawingAvg = wastedTimeDrawingThisFrame * 0.025f + 0.975f * wastedTimeDrawingAvg;
		wastedTimeThisFrame = wastedTimeDrawingThisFrame = 0;
	}
}
Пример #18
0
void LightsEditor::draw(float x, float y, float w, float h)
{
    ofPushMatrix();
    ofTranslate(x,y,0);
    ofPushStyle();
    if(data->bShowBgImage) {
        treeimg[data->currentTree].draw(0,0,editorWidth,editorHeight);
    }

    ofSetRectMode(OF_RECTMODE_CENTER);
    unsigned int numLights = data->trees[data->currentTree]->lights.size();
    for(int j=0; j < numLights;j++)
    {
        /* Draw circle */
        ofVec2f pos = data->trees[data->currentTree]->lights.at(j)->getPosition();
        ofNoFill();
        ofSetLineWidth(3);
        if(data->currentLight == j) {
            ofSetColor(0,0,255);
            if(data->bEditMode) {
                data->trees[data->currentTree]->lights.at(j)->setColour(ofColor(255,255,255));
                data->trees[data->currentTree]->lights[j]->setBrightness(data->brightness);
            }
        }
        else {
            ofSetColor(100,100,100);
            if(data->bEditMode) {
                data->trees[data->currentTree]->lights.at(j)->setColour(ofColor(0,0,0));
                data->trees[data->currentTree]->lights[j]->setBrightness(data->brightness);
            }
        }
        ofDrawCircle(pos,circleRadius);

        /* draw lighth number */
        ofSetHexColor(0xff3355);
        float w = 10.0f + lightNum.stringWidth(ofToString(j+1));
        lightNum.drawString(ofToString(j+1),pos.x - w,pos.y + circleRadius);

        /* draw connecting grey lines */
        ofSetColor(100,100,100);
        ofSetLineWidth(1);
        if(j+1 < numLights-1) {
            ofVec2f pos2 = data->trees[data->currentTree]->lights.at(j+1)->getPosition();
            ofDrawLine(pos.x,pos.y,pos2.x,pos2.y);
        }

        /* Draw LEDs */
        for(int k=0; k < data->trees[data->currentTree]->lights.at(j)->pixels.size(); k++)
        {
            ofVec2f pixpos = data->trees[data->currentTree]->lights.at(j)->pixels[k]->getPosition();
            ofColor c = data->trees[data->currentTree]->lights.at(j)->pixels[k]->getColour();
            float b = data->trees[data->currentTree]->lights.at(j)->pixels[k]->getBrightness();
            ofSetColor(c.r * b, c.g * b, c.b * b);
            ofFill();
            ofDrawRectangle(pixpos,data->pixelWidth,data->pixelWidth);
        }
    }

    ofSetColor(255);
    ofDrawBitmapString("Name = " + data->trees[data->currentTree]->getName()+" Tree = "+ofToString(data->currentTree)+"  Light Id= "+ofToString(data->currentLight) ,20,ofGetHeight()-20);

    ofPopStyle();
    ofPopMatrix();

}
ofRectangle LoadingScreen::draw(ofRectangle drawArea){

	if(!font){
		ofLogError("LoadingScreen") << "Font Not Set!";
		return ofRectangle();
	}

	float avgSize = (drawArea.width + drawArea.height) * 0.5;

	ofSetColor(bgColor);
	ofDrawRectangle(drawArea);
	float padding = avgSize / 40;

	//status info
	float fontSize = ofClamp(drawArea.height / 50, 11, 50);
	float lineH = font->getBBox("M", fontSize, 0, 0).height;
	float usableDrawH = (drawArea.height - 5 * padding); //abobe the progress bar + 1 extra padding
	float numLines = usableDrawH / lineH; //more or less how many lines can fit in this space?


	//as this could be lots of lines, lets remove the lines that would be offscreen so that we dont have to draw them
	vector<string> splitLines = ofSplitString(statusString, "\n");
	if (splitLines.size() > numLines){
		splitLines.erase(splitLines.begin(), splitLines.begin() + splitLines.size() - 1 - numLines);
	}

	string shortMsg;
	for(int i = 0; i < splitLines.size(); i++){
		shortMsg += splitLines[i] + "\n";
	}

	ofVec2f msgBox = font->drawMultiColumnFormatted(shortMsg, fontSize, 10000000, false, true); //dry run!

	//offset to implement a cheap auto-scroll when status message is longer than the area we have available
	float offsetY = 0;

	if ( msgBox.y > usableDrawH ){
		offsetY = msgBox.y - usableDrawH;
	}
	ofSetColor(statusColor);
	ofPushMatrix();
		ofTranslate(padding + 1.0f, padding + 1.0f - offsetY);
		font->drawMultiColumnFormatted(shortMsg, fontSize, 10000000, false, false); //dry run
	ofPopMatrix();

	//progress bar
	float barH = avgSize / 40.;
	float barY = drawArea.height - padding * 3;
	progress.draw( padding, barY, drawArea.width - 2 * padding, barH);
	#ifdef LOGO_SUPPORT
	float svgW = lpLogoSvg.getWidth();
	float logoW = 2 * padding;//ofClamp(padding, 50, 150);
	float scale = logoW / svgW;
	#endif

	//progress bar font size bigger
	fontSize = barH * 0.6;
	string t = currentScreenName;
	ofStringReplace(t, "_", " ");
	string t2 = extraBarInfo;
	ofStringReplace(t2, "_", " ");

	string msg = t + " " + t2;
	ofRectangle r = font->getBBox(msg, fontSize, 0, 0);
	switch(((int)(ofGetFrameNum() * 0.2))%9){
		case 0: msg += "...  ";break;
		case 1: msg += " ... ";break;
		case 2: msg += "  ...";break;
		case 3: msg += "   ..";break;
		case 4: msg += "    .";break;
		case 5: msg += "     ";break;
		case 7: msg += ".    ";break;
		case 8: msg += "..   ";break;
	}
	ofSetColor(255);
	float off = 0.5 * fabs(r.height - barH);
	font->draw(msg, fontSize, drawArea.width / 2 - r.width / 2, barY + barH - off - (r.height + r.y) );

	//LP logo
	#ifdef LOGO_SUPPORT
	ofPushMatrix();
		ofTranslate(drawArea.width - padding - logoW, barY + barH + padding * 0.5 );
		ofScale(scale, scale);
		lpLogoSvg.draw();
	ofPopMatrix();
	#endif

	ofRectangle areaAboveProgress = ofRectangle(padding, 2 * padding,
												drawArea.width - 2 * padding, barY - 3 * padding );
	return areaAboveProgress;
}
Пример #20
0
//--------------------------------------------------------------
void ofApp::setup() {
	ofSetFrameRate(60);
	ofSetVerticalSync(true);
	ofBackground( 10, 10, 10);
    ofDisableArbTex();
	
	camera.setPosition(ofVec3f(0, -4.f, -10.f));
	camera.lookAt(ofVec3f(0, 0, 0), ofVec3f(0, -1, 0));
    camera.setDistance( 10 );
    camera.setNearClip( 0.1 );
    camera.setFarClip( 300 );
	
	world.setup();
	world.setCamera(&camera);
    
//    ofEnableSmoothing();
//    ofEnableAntiAliasing();
    
    anisotropy = 4.;
    
    float fboDiv = 4.f;
//    ofSetMinMagFilters( GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR_MIPMAP_LINEAR );
    fbo.allocate( (float)ofGetWidth() / fboDiv, (float)ofGetWidth() / fboDiv, GL_RGB, 4 );
    fbo.begin(); {
        ofClear(0, 0, 0, 255 );
        ofSetColor( 11,90,121, 255);
        ofDrawRectangle(0, 0, ofGetWidth(), ofGetHeight() );
        ofSetColor(120, 140, 150, 255);
        
        int numIterations = 4;
        float inc = (float)fbo.getWidth() / ((float)numIterations);
        for( int i = 0; i < numIterations; i++ ) {
            float tx = (float)i*inc + inc;
            float ty = (float)i*inc + inc;
            
            ofSetColor(152,197,190, 255);
            ofSetLineWidth( 1.5 );
            if( i % 2 == 0 ) ofSetLineWidth( 0.5 );
            
            ofDrawLine( tx, 0, tx, fbo.getHeight() );
            ofDrawLine( 0, ty, fbo.getWidth(), ty );
        }
        
    } fbo.end();
    
    ofSetLineWidth( 1 );
    
    fbo.getTexture().setTextureMinMagFilter( GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR_MIPMAP_LINEAR );
    
    fbo.getTexture().bind();
    glGenerateMipmap( fbo.getTexture().texData.textureTarget);
//    ofSetMinMagFilters( GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR_MIPMAP_LINEAR );
//    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, anisotropy);
//    glSamplerParameterf( fbo.getTextureReference().texData.textureTarget, GL_TEXTURE_MAX_ANISOTROPY_EXT, 2 );
    fbo.getTexture().unbind();
    
    
    fboSphere.allocate( 256, 256, GL_RGB, 4 );
    fboSphere.begin(); {
        ofClear(0, 0, 0, 255 );
        ofSetColor( 239,201,198 );
        ofDrawRectangle(0, 0, fboSphere.getWidth(), fboSphere.getHeight() );
        ofSetColor(90, 90, 90, 255 );
        ofSetLineWidth( 3 );
        ofDrawLine( 0, 0, fboSphere.getWidth(), fboSphere.getHeight() );
        ofDrawLine( 0, fboSphere.getHeight(), fboSphere.getWidth(), 0 );
        
    } fboSphere.end();
    
    ofSetLineWidth( 1 );
	
    omesh = ofMesh::plane( 70, 70, 14, 14, OF_PRIMITIVE_TRIANGLES );
    ofQuaternion rquat;
    rquat.makeRotate( 90, 1, 0, 0);
    ofSeedRandom();
    float rseed = ofRandom(0, 10000);
    vector< glm::vec3 >& verts = omesh.getVertices();
    for( int i = 0; i < verts.size(); i++ ) {
        verts[i] = rquat * verts[i];
        verts[i].y = ofSignedNoise( verts[i].x*0.02, verts[i].y*0.02 + verts[i].z*0.02, ofGetElapsedTimef() * 0.1 + rseed ) * 3;
    }
    
    vector< glm::vec2 >& tcoords = omesh.getTexCoords();
    for( int i = 0; i < tcoords.size(); i++ ) {
        tcoords[i].x *= 4.f;
        tcoords[i].y *= 4.f;
    }
    mesh = omesh;
    
    bulletMesh = shared_ptr< ofxBulletTriMeshShape >( new ofxBulletTriMeshShape() );
    bulletMesh->create( world.world, mesh, ofVec3f(0,0,0), 0.f, ofVec3f(-10000, -10000, -10000), ofVec3f(10000,10000,10000) );
    bulletMesh->add();
    bulletMesh->enableKinematic();
    bulletMesh->setActivationState( DISABLE_DEACTIVATION );
    
    bDrawDebug  = false;
    bSpacebar   = false;
	bDrawFbos   = false;
    bAnimated   = false;
}
Пример #21
0
//--------------------------------------------------------------
void ofApp::draw(){
	
	ofDrawBitmapString("test", 10, 10);
	
	//////////////////////////
	// BACKGROUND HIGHLIGHT
	//////////////////////////
	//
	ofDisableDepthTest();
	ofPushStyle();
	ofSetColor(100, 100, 100);
	ofDrawRectangle(viewGrid[iMainCamera]);
	ofPopStyle();
	ofEnableDepthTest();
	//
	//////////////////////////
	
	
	
	//////////////////////////
	// DRAW ALL VIEWPORTS
	//////////////////////////
	//
	
	//draw main viewport
	cameras[iMainCamera]->begin(viewMain);
	drawScene(iMainCamera);
	
	//calculate mouse ray whilst this camera is active
	updateMouseRay();
	
	cameras[iMainCamera]->end();
	
	//draw side viewports
	for (int i=0; i<N_CAMERAS; i++)
	{
		cameras[i]->begin(viewGrid[i]);
		drawScene(i);
		cameras[i]->end();
	}
	
	//
	//////////////////////////
	
	
	
	//////////////////////////
	// DRAW STUFF ON TOP
	//////////////////////////
	//
	ofPushStyle();
	glDepthFunc(GL_ALWAYS); // draw on top of everything
	
	//draw some labels
	ofSetColor(255, 255, 255);
	ofDrawBitmapString("Press keys 1-4 to select a camera for main view", viewMain.x + 20, 30);
	ofDrawBitmapString("Camera selected: " + ofToString(iMainCamera+1), viewMain.x + 20, 50);
	ofDrawBitmapString("Press 'f' to toggle fullscreen", viewMain.x + 20, 70);
	ofDrawBitmapString("Press 'p' to toggle parents on OrthoCamera's", viewMain.x + 20, 90);
	
	ofDrawBitmapString("EasyCam",	viewGrid[0].x + 20, viewGrid[0].y + 30);
	ofDrawBitmapString("Front",		viewGrid[1].x + 20, viewGrid[1].y + 30);
	ofDrawBitmapString("Top",		viewGrid[2].x + 20, viewGrid[2].y + 30);
	ofDrawBitmapString("Left",		viewGrid[3].x + 20, viewGrid[3].y + 30);

	//draw outlines on views
	ofSetLineWidth(5);
	ofNoFill();
	ofSetColor(255, 255, 255);
	//
	for (int i=0; i<N_CAMERAS; i++)
		ofDrawRectangle(viewGrid[i]);
	//
	ofDrawRectangle(viewMain);
	
	glDepthFunc(GL_LESS);
	ofPopStyle();
	//
	//////////////////////////
}
Пример #22
0
//--------------------------------------------------------------
void ofApp::draw() {
    //if we're using the camera, start it.
    //everything that you draw between begin()/end() shows up from the view of the camera
    if(usecamera) {
        camera.begin();
    }

    ofSetColor(0);
    //do the same thing from the first example...
    ofMesh mesh;
    mesh.setMode(OF_PRIMITIVE_TRIANGLE_STRIP);
    for(unsigned int i = 1; i < points.size(); i++) {

        //find this point and the next point
        ofVec3f thisPoint = points[i-1];
        ofVec3f nextPoint = points[i];

        //get the direction from one to the next.
        //the ribbon should fan out from this direction
        ofVec3f direction = (nextPoint - thisPoint);

        //get the distance from one point to the next
        float distance = direction.length();

        //get the normalized direction. normalized vectors always have a length of one
        //and are really useful for representing directions as opposed to something with length
        ofVec3f unitDirection = direction.getNormalized();

        //find both directions to the left and to the right
        ofVec3f toTheLeft = unitDirection.getRotated(-90, ofVec3f(0,0,1));
        ofVec3f toTheRight = unitDirection.getRotated(90, ofVec3f(0,0,1));

        //use the map function to determine the distance.
        //the longer the distance, the narrower the line.
        //this makes it look a bit like brush strokes
        float thickness = ofMap(distance, 0, 60, 20, 2, true);

        //calculate the points to the left and to the right
        //by extending the current point in the direction of left/right by the length
        ofVec3f leftPoint = thisPoint+toTheLeft*thickness;
        ofVec3f rightPoint = thisPoint+toTheRight*thickness;

        //add these points to the triangle strip
        mesh.addVertex(ofVec3f(leftPoint.x, leftPoint.y, leftPoint.z));
        mesh.addVertex(ofVec3f(rightPoint.x, rightPoint.y, rightPoint.z));
    }

    //end the shape
    mesh.draw();


    //if we're using the camera, take it away
    if(usecamera) {
        camera.end();
    }
    float hue = fmodf(ofGetElapsedTimef()*10,255);

    int step = 5;
    // step through horizontally
    for ( int i=0; i<ofGetWidth(); i+=step )
    {
        // step through vertically
        for ( int j=0; j<ofGetHeight(); j+=step )
        {
            // set HSB using our hue value that changes over time, saturation from the X position (i),
            // and brightness from the Y position (j). we also invert the Y value since it looks
            // nicer if the dark/black colors are along the bottom.
            ofColor c;
            // the range of each of the arguments here is 0..255 so we map i and j to that range.
            c.setHsb( hue, ofMap(i, 0,ofGetWidth(), 0,255), ofMap(j, ofGetHeight(),0, 0,255 ) );

            // assign the color and draw a rectangle
            ofSetColor( c );
            ofDrawRectangle( i, j, step-1, step-1 );
        }
    }

}
Пример #23
0
//--------------------------------------------------------------
void ofApp::draw() {
    
    float spinX = sin(ofGetElapsedTimef()*.35f);
    float spinY = cos(ofGetElapsedTimef()*.075f);
    
    if(bMousePressed) {
        spinX = spinY = 0.0f;
    }
    
    ofEnableDepthTest();
    
    ofEnableLighting();
    pointLight.enable();
    pointLight2.enable();
    pointLight3.enable();
    
	material.begin();
    
    
    ofSetColor(180);
    ofNoFill();
    ofDrawSphere(ofGetWidth()/2, ofGetHeight()/2, ofGetWidth());
    
    if(mode == 1 || mode == 3) texture.getTexture().bind();
    if(mode == 2) vidGrabber.getTexture().bind();
    
    
    // Plane //
    plane.setPosition(ofGetWidth()*.2, ofGetHeight()*.25, 0);
    plane.rotate(spinX, 1.0, 0.0, 0.0);
    plane.rotate(spinY, 0, 1.0, 0.0);
    
    
    if(mode == 3) {
        deformPlane = plane.getMesh();
        // x = columns, y = rows //
        ofVec3f planeDims = plane.getResolution();
        float planeAngleX = ofGetElapsedTimef()*3.6;
        float planeAngleInc = 3.f/(float)planeDims.x;
        ofVec3f vert;
        for(int i = 0; i < deformPlane.getNumIndices(); i++ ) {
            planeAngleX += planeAngleInc;
            int ii = deformPlane.getIndex( i );
            vert = deformPlane.getVertex( ii );
            vert.z += cos(planeAngleX) * 50;
            deformPlane.setVertex( ii, vert );
        }
    }
    
    if(bFill) {
        ofFill();
        ofSetColor(255);
        if(mode == 3) {
            plane.transformGL();
            deformPlane.draw();
            plane.restoreTransformGL();
        } else {
            plane.draw();
        }
    }
    if(bWireframe) {
        ofNoFill();
        ofSetColor(0, 0, 0);
        if(!bFill) ofSetColor(255);
        plane.setPosition(plane.getPosition().x, plane.getPosition().y, plane.getPosition().z+1);
        //if(bFill) {
        if( mode == 3 ) {
            ofSetColor(255);
        }
        plane.drawWireframe();
        //}
        plane.setPosition(plane.getPosition().x, plane.getPosition().y, plane.getPosition().z-2);
        
    }
    
    
    // Box //
    box.setPosition(ofGetWidth()*.5, ofGetHeight()*.25, 0);
    box.rotate(spinX, 1.0, 0.0, 0.0);
    box.rotate(spinY, 0, 1.0, 0.0);
    
    if(bFill) {
        ofFill();
        ofSetColor(255);
        if(mode == 3) {
            box.transformGL();
            for(int i = 0; i < ofBoxPrimitive::SIDES_TOTAL; i++ ) {
                ofPushMatrix();
                ofTranslate( boxSides[i].getNormal(0) * sin(ofGetElapsedTimef()) * 50  );
                boxSides[i].draw();
                ofPopMatrix();
            }
            box.restoreTransformGL();
        } else {
            box.draw();
        }
    }
    if(bWireframe) {
        ofNoFill();
        ofSetColor(0, 0, 0);
        if(!bFill) ofSetColor(255);
        box.setScale(1.01f);
        if(mode == 3) {
            ofSetColor(255);
        }
        box.drawWireframe();
        box.setScale(1.f);
    }
    
    
    // Sphere //
    sphere.setPosition(ofGetWidth()*.8f, ofGetHeight()*.25, 0);
    sphere.rotate(spinX, 1.0, 0.0, 0.0);
    sphere.rotate(spinY, 0, 1.0, 0.0);
    
    if(mode == 3) {
        sphere.setMode( OF_PRIMITIVE_TRIANGLES );
        triangles = sphere.getMesh().getUniqueFaces();
    }
    
    if(bFill) {
        ofFill();
        ofSetColor(255);
        if(mode == 3) {
            float angle = ofGetElapsedTimef()*3.2;
            float strength = (sin( angle+.25 )) * .5f * 5.f;
            ofVec3f faceNormal;
            for(int i = 0; i < triangles.size(); i++ ) {
                // store the face normal here.
                // we change the vertices, which makes the face normal change
                // every time that we call getFaceNormal //
                faceNormal = triangles[i].getFaceNormal();
                for(int j = 0; j < 3; j++ ) {
                    triangles[i].setVertex( j, triangles[i].getVertex(j) + faceNormal * strength);
                }
            }
            sphere.getMesh().setFromTriangles( triangles );
        }
        sphere.draw();
        
    }
    if(bWireframe) {
        ofNoFill();
        ofSetColor(0, 0, 0);
        if(!bFill) ofSetColor(255);
        sphere.setScale(1.01f);
        sphere.drawWireframe();
        sphere.setScale(1.f);
    }
    
    
    // ICO Sphere //
    icoSphere.setPosition(ofGetWidth()*.2, ofGetHeight()*.75, 0);
    icoSphere.rotate(spinX, 1.0, 0.0, 0.0);
    icoSphere.rotate(spinY, 0, 1.0, 0.0);
    
    if(mode == 3) {
        triangles = icoSphere.getMesh().getUniqueFaces();
    }
    
    if(bFill) {
        ofFill();
        ofSetColor(255);
        
        if(mode == 3) {
            float angle = (ofGetElapsedTimef() * 1.4);
            ofVec3f faceNormal;
            for(int i = 0; i < triangles.size(); i++ ) {
                float frc = ofSignedNoise(angle* (float)i * .1, angle*.05) * 4;
                faceNormal = triangles[i].getFaceNormal();
                for(int j = 0; j < 3; j++ ) {
                    triangles[i].setVertex(j, triangles[i].getVertex(j) + faceNormal * frc );
                }
            }
            icoSphere.getMesh().setFromTriangles( triangles );
        }
        
        icoSphere.draw();
    }
    if(bWireframe) {
        ofNoFill();
        ofSetColor(0, 0, 0);
        if(!bFill) ofSetColor(255);
        icoSphere.setScale(1.01f);
        icoSphere.drawWireframe();
        icoSphere.setScale(1.f);
    }
    
    
    // Cylinder //
    if(mode == 3) {
        topCap      = cylinder.getTopCapMesh();
        bottomCap   = cylinder.getBottomCapMesh();
        body        = cylinder.getCylinderMesh();
    }
    
    cylinder.setPosition(ofGetWidth()*.5, ofGetHeight()*.75, 0);
    cylinder.rotate(spinX, 1.0, 0.0, 0.0);
    cylinder.rotate(spinY, 0, 1.0, 0.0);
    if(bFill) {
        ofFill();
        ofSetColor(255);
        if(mode == 3) {
            cylinder.transformGL();
            ofPushMatrix(); {
                if(topCap.getNumNormals() > 0) {
                    ofTranslate( topCap.getNormal(0) * (cos(ofGetElapsedTimef()*5)+1)*.5f * 100 );
                    topCap.draw();
                }
            } ofPopMatrix();
            ofPushMatrix(); {
                if(bottomCap.getNumNormals() > 0) {
                    ofTranslate( bottomCap.getNormal(0) * (cos(ofGetElapsedTimef()*4)+1)*.5f * 100 );
                    bottomCap.draw();
                }
            } ofPopMatrix();
            ofPushMatrix(); {
                float scale = (cos(ofGetElapsedTimef()*3)+1)*.5f + .2;
                ofScale( scale, scale, scale );
                body.draw();
            } ofPopMatrix();
            cylinder.restoreTransformGL();
        } else {
            cylinder.draw();
        }
    }
    if(bWireframe) {
        ofNoFill();
        ofSetColor(0, 0, 0);
        if(!bFill || mode == 3) ofSetColor(255);
        cylinder.setScale(1.01f);
        cylinder.drawWireframe();
        cylinder.setScale(1.0f);
    }
    
    
    // Cone //
    cone.setPosition(ofGetWidth()*.8, ofGetHeight()*.75, 0);
    cone.rotate(spinX, 1.0, 0.0, 0.0);
    cone.rotate(spinY, 0, 1.0, 0.0);
    
    if(mode == 3) {
        bottomCap   = cone.getCapMesh();
        body        = cone.getConeMesh();
    }
    if(bFill) {
        ofFill();
        ofSetColor(255);
        if(mode == 3) {
            cone.transformGL();
            ofPushMatrix();
            if(bottomCap.getNumNormals() > 0 ) {
                ofTranslate( bottomCap.getNormal(0) * cone.getHeight()*.5 );
                ofRotate( sin(ofGetElapsedTimef()*5) * RAD_TO_DEG, 1, 0, 0);
                bottomCap.draw();
            }
            ofPopMatrix();
            
            ofPushMatrix();
            ofRotate(90, 1, 0, 0);
            ofRotate( (cos(ofGetElapsedTimef()*6) +1)*.5 * 360 , 1, 0, 0 );
            body.draw();
            ofPopMatrix();
            cone.restoreTransformGL();
        } else {
            cone.draw();
        }
    }
    if(bWireframe) {
        ofNoFill();
        ofSetColor(0, 0, 0);
        if(!bFill || mode == 3) ofSetColor(255);
        cone.setScale(1.01f);
        cone.drawWireframe();
        cone.setScale(1.0f);
    }
    
    if(mode == 1 || mode == 3) texture.getTexture().unbind();
    if(mode == 2) vidGrabber.getTexture().unbind();
    
    material.end();
    ofDisableLighting();
    
    if(bDrawLights) {
        ofFill();
        ofSetColor(pointLight.getDiffuseColor());
        pointLight.draw();
        ofSetColor(pointLight2.getDiffuseColor());
        pointLight2.draw();
        ofSetColor(pointLight3.getDiffuseColor());
        pointLight3.draw();
    }
    
    if(bDrawNormals) {
        ofSetColor(225, 0, 255);
        plane.drawNormals(20, bSplitFaces);
        box.drawNormals(20, bSplitFaces);
        sphere.drawNormals(20, bSplitFaces);
        icoSphere.drawNormals(20, bSplitFaces);
        cylinder.drawNormals(20, bSplitFaces);
        cone.drawNormals(20, bSplitFaces);
    }
    if(bDrawAxes) {
        plane.drawAxes(plane.getWidth()*.5+30);
        box.drawAxes(box.getWidth()+30);
        sphere.drawAxes(sphere.getRadius()+30);
        icoSphere.drawAxes(icoSphere.getRadius()+30);
        cylinder.drawAxes(cylinder.getHeight()+30);
        cone.drawAxes(cone.getHeight()+30);
    }
    
    ofDisableDepthTest();
    
    ofFill();
    
    ofSetColor(0);
    ofDrawRectangle(plane.getPosition().x-154, plane.getPosition().y + 120, 140, 24);
    ofSetColor(255);
    ofDrawBitmapString("ofPlanePrimitive", plane.getPosition().x-150, plane.getPosition().y+136 );
    
    ofSetColor(0);
    ofDrawRectangle(box.getPosition().x-154, box.getPosition().y + 120, 126, 24);
    ofSetColor(255);
    ofDrawBitmapString("ofBoxPrimitive", box.getPosition().x-150, box.getPosition().y+136 );
    
    ofSetColor(0);
    ofDrawRectangle(sphere.getPosition().x-154, sphere.getPosition().y + 120, 148, 24);
    ofSetColor(255);
    ofDrawBitmapString("ofSpherePrimitive", sphere.getPosition().x-150, sphere.getPosition().y+136 );
    
    ofSetColor(0);
    ofDrawRectangle(icoSphere.getPosition().x-154, icoSphere.getPosition().y + 120, 168, 24);
    ofSetColor(255);
    ofDrawBitmapString("ofIcoSpherePrimitive", icoSphere.getPosition().x-150, icoSphere.getPosition().y+136 );
    
    ofSetColor(0);
    ofDrawRectangle(cylinder.getPosition().x-154, cylinder.getPosition().y + 120, 160, 24);
    ofSetColor(255);
    ofDrawBitmapString("ofCylinderPrimitive", cylinder.getPosition().x-150, cylinder.getPosition().y+136 );
    
    ofSetColor(0);
    ofDrawRectangle(cone.getPosition().x-154, cone.getPosition().y + 120, 136, 24);
    ofSetColor(255);
    ofDrawBitmapString("ofConePrimitive", cone.getPosition().x-150, cone.getPosition().y+136 );
        
    if(bInfoText) {
        stringstream ss;
        ss << "Framerate: " << ofToString(ofGetFrameRate(),0) << "\n";
        ss << "(f): Toggle Fullscreen"<<endl<<"(s): Draw Solid Shapes"<<endl<<"(w): Draw Wireframes"<<endl;
        ss <<"(1/2/3/4): Set Resolutions" <<endl<<"(n): Draw Normals"<<"\n(LEFT/RIGHT): Set Mode "<<ofToString(mode,0)<<endl;
        ss <<"(z): Split Faces " <<bSplitFaces<<endl;
        ss <<"(a): Draw Axes"<<endl<<"(l): Render lights"<<endl<<"(t): Info Text"<<endl;
        
        ofDrawBitmapString(ss.str().c_str(), 20, 20);
    }
    
    
}
Пример #24
0
//--------------------------------------------------------------
void GuiElement::drawBackground(){

	ofSetColor(this->backgroundColor);

	ofDrawRectangle(*this);
}
Пример #25
0
//--------------------------------------------------------------
void ofApp::draw(){
	//we translate everything to the center of the circle so it's easier to draw and understand.
	ofTranslate(center);
	
	//draw the yellow circle
	ofSetColor(240, 230, 10);
	ofDrawCircle(0,0, radius);
	
	//draw the cyan circle that's moving over the yellow circle's perimeter 
	ofSetColor(0, 140, 255);
	ofDrawCircle(point, 10);
	
	//draw the orange arc that represents the angle
	angleArc.draw();
	
	
	//draw the axis lines
	ofSetColor(20);
	ofSetLineWidth(1);
	ofDrawLine(-radius * 1.3f, 0, radius * 2, 0);
	ofDrawLine(0, -radius * 2, 0, radius * 1.3f);
	
	ofSetColor(180);
	ofDrawLine(0, -radius , radius * 2, -radius);
	ofDrawLine(0,  radius , radius * 2,  radius);
	ofDrawLine(-radius, 0 ,-radius,  -radius * 2);
	ofDrawLine( radius, 0 , radius,  -radius * 2);
	
	//draw the pink bars
	ofSetColor(255, 0, 127);
	ofDrawRectangle(0, -radius * 2, cosine * radius, 20);
	ofDrawRectangle(radius * 2, 0, -20, sine * radius);
	
	
	ofSetLineWidth(3);
	
	
	//draw lines from the cyan ball to the pink bars
	ofSetColor(255, 0, 50);
	ofDrawLine(point.x, point.y, cosine * radius, -radius * 2);
	ofDrawLine(point.x, point.y, radius * 2, sine * radius);
	
	//draw the line from the yellow circle's center to the cyan circle 
	ofSetColor(0, 127, 255);
	ofDrawLine(0, 0, point.x, point.y);
	

	//draw the dark lines inside the yellow circle that represent the distance from the axis to the cyan circle
	ofSetColor(40);
	ofDrawLine(0, sine * radius, cosine * radius, sine * radius);
	ofDrawLine(cosine * radius, 0, cosine * radius, sine * radius);
	

	// draw the info text
	ofSetColor(10);
	ofDrawBitmapString("Angle (RAD): " + ofToString(angle), 3,-3);
	ofSetColor(30);
	ofDrawBitmapString("Angle (DEG): " + ofToString(ofRadToDeg(angle)), 3,20);
	
	ofDrawBitmapString("Radius: " + ofToString(radius), -radius +20, -3);	
	
	ofSetColor(220);
	ofDrawBitmapString("Angle Sine: " + ofToString(sine), radius *2 +3, 0);
	ofDrawBitmapString("sine x radius: " + ofToString(sine * radius), radius *2 +3, 15	);
	
	ofDrawBitmapString("Angle cosine: " + ofToString(cosine), 0, -radius *2 -20);
	ofDrawBitmapString("cosine x radius: " + ofToString(cosine * radius), 0, -radius *2 -5 );
	
}
Пример #26
0
void ofApp::draw()
{
    ofBackground(0);

    std::stringstream ss;

    ss << "Press 'c' to cancel all tasks." << std::endl;
    ss << "Press 'C' to cancel queued tasks." << std::endl;
    ss << "Press 'a' to add tasks." << std::endl;

    ofDrawBitmapStringHighlight(ss.str(), ofPoint(10, 14));

    ss.str("");
    ss << "Total Active Tasks: " << queue.getActiveCount() << std::endl;
    ss << "Total Queued Tasks: " << queue.getQueuedCount();

    ofDrawBitmapStringHighlight(ss.str(), ofPoint(ofGetWidth() / 2, 14));

    int height = 20;
    int y = height * 3;

    ofx::TaskQueue::ProgressMap progress = queue.getTaskProgress();
    ofx::TaskQueue::ProgressMap::const_iterator iter = progress.begin();

    while (iter != progress.end() && y < ofGetHeight())
    {
        const ofx::TaskProgressEventArgs& progressInfo = iter->second;

        float progress = progressInfo.progress();

        std::string taskId = progressInfo.taskId();

        std::string name = progressInfo.taskName();

        ofColor color;

        std::string statusString;

        switch (progressInfo.state())
        {
            case Poco::Task::TASK_IDLE:
                color = ofColor(127);
                statusString = "idle";
                break;
            case Poco::Task::TASK_STARTING:
                color = ofColor(255, 255, 0);
                statusString = "starting";
                break;
            case Poco::Task::TASK_RUNNING:
                color = ofColor(255, 127, 127);
                statusString = "running";
                break;
            case Poco::Task::TASK_CANCELLING:
                color = ofColor(255, 0, 0);
                statusString = "cancelling";
                break;
            case Poco::Task::TASK_FINISHED:
                color = ofColor(0, 255, 0);
                statusString = "finished";
                break;
        }

        std::stringstream ss;

        ss << taskId << ": " << statusString << " : " << name << std::endl;

        ofPushMatrix();
        ofTranslate(0, y);

        ofFill();
        ofSetColor(color, 127);
        ofDrawRectangle(0, 0, ofGetWidth() * progress, height - 2);

        ofNoFill();
        ofSetColor(color);
        ofDrawRectangle(0, 0, ofGetWidth() * progress, height - 2);

        ofFill();
        ofSetColor(255);
        ofDrawBitmapString(ss.str(), 4, 14);

        ofPopMatrix();

        y += height;

        ++iter;
    }
}
Пример #27
0
void StBlue::draw(){
    float alpha = ofMap(app->p1, 0, 1, 0, 255);
    ofSetColor(0, 0, 255, alpha);
    ofDrawRectangle(0, 0, ofGetWidth(), ofGetHeight());
}
Пример #28
0
void Paddle::draw()
{
    ofDrawRectangle(x, y - (height/2), width, height);
}
Пример #29
0
//--------------------------------------------------------------
void ofApp::draw(){
    renderFbo.begin();
    ofClear(255,255,255,255);
	ofFill();
	ofSetHexColor(0xe0be21);

	//------(a)--------------------------------------
	//
	// 		draw a star
	//
	// 		use poly winding odd, the default rule
	//
	// 		info about the winding rules is here:
	//		http://glprogramming.com/red/images/Image128.gif
	//
	ofSetPolyMode(OF_POLY_WINDING_ODD);	// this is the normal mode
	ofBeginShape();
		ofVertex(200,135);
		ofVertex(15,135);
		ofVertex(165,25);
		ofVertex(105,200);
		ofVertex(50,25);
	ofEndShape();


	//------(b)--------------------------------------
	//
	// 		draw a star
	//
	// 		use poly winding nonzero
	//
	// 		info about the winding rules is here:
	//		http://glprogramming.com/red/images/Image128.gif
	//
	ofSetHexColor(0xb5de10);
	ofSetPolyMode(OF_POLY_WINDING_NONZERO);
	ofBeginShape();
		ofVertex(400,135);
		ofVertex(215,135);
		ofVertex(365,25);
		ofVertex(305,200);
		ofVertex(250,25);
	ofEndShape();
	//-------------------------------------



	//------(c)--------------------------------------
	//
	// 		draw a star dynamically
	//
	// 		use the mouse position as a pct
	//		to calc nPoints and internal point radius
	//
	float xPct = (float)(mouseX) / (float)(ofGetWidth());
	float yPct = (float)(mouseY) / (float)(ofGetHeight());
	int nTips = 5 + xPct * 60;
	int nStarPts = nTips * 2;
	float angleChangePerPt = TWO_PI / (float)nStarPts;
	float innerRadius = 0 + yPct*80;
	float outerRadius = 80;
	float origx = 525;
	float origy = 100;
	float angle = 0;

	ofSetHexColor(0xa16bca);
	ofBeginShape();
	for (int i = 0; i < nStarPts; i++){
		if (i % 2 == 0) {
			// inside point:
			float x = origx + innerRadius * cos(angle);
			float y = origy + innerRadius * sin(angle);
			ofVertex(x,y);
		} else {
			// outside point
			float x = origx + outerRadius * cos(angle);
			float y = origy + outerRadius * sin(angle);
			ofVertex(x,y);
		}
		angle += angleChangePerPt;
	}
	ofEndShape();
	//-------------------------------------

	//------(d)--------------------------------------
	//
	// 		poylgon of random points
	//
	// 		lots of self intersection, 500 pts is a good stress test
	//
	//
	ofSetHexColor(0x0cb0b6);
	ofSetPolyMode(OF_POLY_WINDING_ODD);
	ofBeginShape();
	for (int i = 0; i < 10; i++){
		ofVertex(ofRandom(650,850), ofRandom(20,200));
	}
	ofEndShape();
	//-------------------------------------


	//------(e)--------------------------------------
	//
	// 		use sin cos and time to make some spirally shape
	//
	ofPushMatrix();
		ofTranslate(100,300,0);
		ofSetHexColor(0xff2220);
		ofFill();
		ofSetPolyMode(OF_POLY_WINDING_ODD);
		ofBeginShape();
		float angleStep 	= TWO_PI/(100.0f + sin(ofGetElapsedTimef()/5.0f) * 60);
		float radiusAdder 	= 0.5f;
		float radius 		= 0;
		for (int i = 0; i < 200; i++){
			float anglef = (i) * angleStep;
			float x = radius * cos(anglef);
			float y = radius * sin(anglef);
			ofVertex(x,y);
			radius 	+= radiusAdder;
		}
		ofEndShape(OF_CLOSE);
	ofPopMatrix();
	//-------------------------------------

	//------(f)--------------------------------------
	//
	// 		ofCurveVertex
	//
	// 		because it uses catmul rom splines, we need to repeat the first and last
	// 		items so the curve actually goes through those points
	//

	ofSetHexColor(0x2bdbe6);
	ofBeginShape();

		for (int i = 0; i < nCurveVertices; i++){


			// sorry about all the if/states here, but to do catmull rom curves
			// we need to duplicate the start and end points so the curve acutally
			// goes through them.

			// for i == 0, we just call the vertex twice
			// for i == nCurveVertices-1 (last point) we call vertex 0 twice
			// otherwise just normal ofCurveVertex call

			if (i == 0){
				ofCurveVertex(curveVertices[0].x, curveVertices[0].y); // we need to duplicate 0 for the curve to start at point 0
				ofCurveVertex(curveVertices[0].x, curveVertices[0].y); // we need to duplicate 0 for the curve to start at point 0
			} else if (i == nCurveVertices-1){
				ofCurveVertex(curveVertices[i].x, curveVertices[i].y);
				ofCurveVertex(curveVertices[0].x, curveVertices[0].y);	// to draw a curve from pt 6 to pt 0
				ofCurveVertex(curveVertices[0].x, curveVertices[0].y);	// we duplicate the first point twice
			} else {
				ofCurveVertex(curveVertices[i].x, curveVertices[i].y);
			}
		}

	ofEndShape();


	// show a faint the non-curve version of the same polygon:
	ofEnableAlphaBlending();
		ofNoFill();
		ofSetColor(0,0,0,40);
		ofBeginShape();
			for (int i = 0; i < nCurveVertices; i++){
				ofVertex(curveVertices[i].x, curveVertices[i].y);
			}
		ofEndShape(true);


		ofSetColor(0,0,0,80);
		for (int i = 0; i < nCurveVertices; i++){
			if (curveVertices[i].bOver == true) ofFill();
			else ofNoFill();
			ofDrawCircle(curveVertices[i].x, curveVertices[i].y,4);
		}
	ofDisableAlphaBlending();
	//-------------------------------------


	//------(g)--------------------------------------
	//
	// 		ofBezierVertex
	//
	// 		with ofBezierVertex we can draw a curve from the current vertex
	//		through the the next three vertices we pass in.
	//		(two control points and the final bezier point)
	//

	float x0 = 500;
	float y0 = 300;
	float x1 = 550+50*cos(ofGetElapsedTimef()*1.0f);
	float y1 = 300+100*sin(ofGetElapsedTimef()/3.5f);
	float x2 = 600+30*cos(ofGetElapsedTimef()*2.0f);
	float y2 = 300+100*sin(ofGetElapsedTimef());
	float x3 = 650;
	float y3 = 300;



	ofFill();
	ofSetHexColor(0xFF9933);
	ofBeginShape();
	ofVertex(x0,y0);
	ofBezierVertex(x1,y1,x2,y2,x3,y3);
	ofEndShape();


	ofEnableAlphaBlending();
		ofFill();
		ofSetColor(0,0,0,40);
		ofDrawCircle(x0,y0,4);
		ofDrawCircle(x1,y1,4);
		ofDrawCircle(x2,y2,4);
		ofDrawCircle(x3,y3,4);
	ofDisableAlphaBlending();



	//------(h)--------------------------------------
	//
	// 		holes / ofNextContour
	//
	// 		with ofNextContour we can create multi-contour shapes
	// 		this allows us to draw holes, for example...
	//
	ofFill();
	ofSetHexColor(0xd3ffd3);
	ofDrawRectangle(80,480,140,70);
	ofSetHexColor(0xff00ff);

	ofBeginShape();

		ofVertex(100,500);
		ofVertex(180,550);
		ofVertex(100,600);

		ofNextContour(true);

		ofVertex(120,520);
		ofVertex(160,550);
		ofVertex(120,580);

	ofEndShape(true);
	//-------------------------------------


	//------(i)--------------------------------------
	//
	// 		CSG / ofNextContour
	//
	// 		with different winding rules, you can even use ofNextContour to
	// 		perform constructive solid geometry
	//
	// 		be careful, the clockwiseness or counter clockwisenss of your multiple
	// 		contours matters with these winding rules.
	//
	// 		for csg ideas, see : http://glprogramming.com/red/chapter11.html
	//
	// 		info about the winding rules is here:
	//		http://glprogramming.com/red/images/Image128.gif
	//
	ofNoFill();


	ofPushMatrix();

	ofSetPolyMode(OF_POLY_WINDING_ODD);

	ofBeginShape();

		ofVertex(300,500);
		ofVertex(380,550);
		ofVertex(300,600);

		ofNextContour(true);

		for (int i = 0; i < 20; i++){
			float anglef = ((float)i / 19.0f) * TWO_PI;
			float x = 340 + 30 * cos(anglef);
			float y = 550 + 30 * sin(anglef);
			ofVertex(x,y);
			radius 	+= radiusAdder;
		}


	ofEndShape(true);

	ofTranslate(100,0,0);

	ofSetPolyMode(OF_POLY_WINDING_NONZERO);
	ofBeginShape();

		ofVertex(300,500);
		ofVertex(380,550);
		ofVertex(300,600);

		ofNextContour(true);

		for (int i = 0; i < 20; i++){
			float anglef = ((float)i / 19.0f) * TWO_PI;
			float x = 340 + 30 * cos(anglef);
			float y = 550 + 30 * sin(anglef);
			ofVertex(x,y);
			radius 	+= radiusAdder;
		}

	ofEndShape(true);

	ofTranslate(100,0,0);
	ofSetPolyMode(OF_POLY_WINDING_ABS_GEQ_TWO);
	ofBeginShape();
		ofVertex(300,500);
		ofVertex(380,550);
		ofVertex(300,600);
		ofNextContour(true);

		for (int i = 0; i < 20; i++){
			float anglef = ((float)i / 19.0f) * TWO_PI;
			float x = 340 + 30 * cos(anglef);
			float y = 550 + 30 * sin(anglef);
			ofVertex(x,y);
			radius 	+= radiusAdder;
		}


	ofEndShape(true);

	ofPopMatrix();

	//-------------------------------------

	ofSetHexColor(0x000000);
	ofDrawBitmapString("(a) star\nwinding rule odd", 20,210);

	ofSetHexColor(0x000000);
	ofDrawBitmapString("(b) star\nwinding rule nonzero", 220,210);

	ofSetHexColor(0x000000);
	ofDrawBitmapString("(c) dynamically\ncreated shape", 420,210);

	ofSetHexColor(0x000000);
	ofDrawBitmapString("(d) random points\npoly", 670,210);

	ofSetHexColor(0x000000);
	ofDrawBitmapString("(e) fun with sin/cos", 20,410);

	ofSetHexColor(0x000000);
	ofDrawBitmapString("(f) ofCurveVertex\nuses catmull rom\nto make curved shapes", 220,410);

	ofSetHexColor(0x000000);
	ofDrawBitmapString("(g) ofBezierVertex\nuses bezier to draw curves", 460,410);


	ofSetHexColor(0x000000);
	ofDrawBitmapString("(h) ofNextContour\nallows for holes", 20,610);

	ofSetHexColor(0x000000);
	ofDrawBitmapString("(i) ofNextContour\ncan even be used for CSG operations\nsuch as union and intersection", 260,620);

	renderFbo.end();

    //Now draw to the screen
    renderFbo.draw(0,0);


    // Write the frame rate in green
    ofSetHexColor(0x00ff00);
    ofDrawBitmapString("Fps: " + ofToString( ofGetFrameRate()), 15,15);
    ofSetHexColor(0xffffff);



    uint64_t t = ofGetElapsedTimeMicros();
    //recorder.draw(renderFbo);
    c.writeframe();
    //ofLogNotice()<< "time recorder ="<< (ofGetElapsedTimeMicros() - t) / 1000.0<< " ms";



}
Пример #30
0
void ofApp::ofxAppDrawPhaseProgress(ofxApp::Phase, const ofRectangle & r){
	//you can override what gets draw at startup in any way you want
	ofSetColor(255,0,0, 32);
	ofDrawRectangle(r);
	ofSetColor(255);
};