//-------------------------------------------------------------- void testApp::draw(){ ofDrawBitmapString("test", 10, 10); ////////////////////////// // BACKGROUND HIGHLIGHT ////////////////////////// // glDisable(GL_DEPTH_TEST); ofPushStyle(); ofSetColor(100, 100, 100); ofRect(viewGrid[iMainCamera]); ofPopStyle(); glEnable(GL_DEPTH_TEST); // ////////////////////////// ////////////////////////// // 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++) ofRect(viewGrid[i]); // ofRect(viewMain); glDepthFunc(GL_LESS); ofPopStyle(); // ////////////////////////// }
//-------------------------------------------------------------- void testApp::draw(){ ofDrawBitmapStringHighlight(ofToString(aaFrame.volume), ofPoint(30,30)); //temp.draw(30,100); ofNoFill(); ofSetColor(255,255,255); ofRect(30,100, 128,32); ofBeginShape(); for (int i = 0; i < ACM.volume.size(); i++){ ofVertex(30+i, 100 + 32 - ofClamp(32*ACM.volume[i]*5,0,32)); } ofEndShape(); ofNoFill(); ofRect(30,150, 128,32); ofBeginShape(); for (int i = 0; i < ACM.volumeTrigger.size(); i++){ ofVertex(30+i, 150 + 32 - 32*ACM.volumeTrigger[i]); } ofEndShape(); //temp2.draw(30,150); ACM.pitch.draw(30,200); ofFill(); ofSetColor(255,255,255); for (int i = 0; i < AA.FFTanalyzer.nAverages; i++){ ofRect(200+(i*20),600,20,-AA.FFTanalyzer.averages[i] * 6); } ofSetColor(255,0,0); for (int i = 0; i < AA.FFTanalyzer.nAverages; i++){ ofRect(200+(i*20),600-AA.FFTanalyzer.peaks[i] * 6,20,-4); } ofSetColor(0,255,255); for (int i = 0; i < AA.FFTanalyzer.nAverages; i++){ int who = i / 3; //cout << peaks[who] << endl; ofRect(200+(i*20),600-ACM.peaks[who] * 6,20,-4); } for (int i = 0; i < colorsForMessage.size(); i++){ ofSetColor(colorsForMessage[i]); ofLine(i,0,i,10); } }
void testApp::fadeToColor(float r, float g, float b, float speed) { glColor4f(r, g, b, speed); ofRect(0, 0, ofGetWidth(), ofGetHeight()); }
//-------------------------------------------------------------- void gamuzaMain::draw(){ if(splashFinish){ ofBackground(0,0,0); ////////////////////////////////////////////// // GUI draw if(!liveCodingMode){ ofSetLineWidth(1.2); gui.draw(); drawGui(); ofSetLineWidth(1); } ////////////////////////////////////////////// ////////////////////////////////////////////// // FBO texture draw glColor4f(1.0,1.0,1.0,1.0); drawFBO(); ////////////////////////////////////////////// //////////////////////////////////// // TIMELINE if(showTimeline && !isFullscreen){ ofEnableAlphaBlending(); glColor4f(0.0,0.0,0.0,0.9); ofRect(0,0,MAIN_WINDOW_W-4,MAIN_WINDOW_H); ofDisableAlphaBlending(); }else if(showTimeline && isFullscreen){ ofEnableAlphaBlending(); glColor4f(0.0,0.0,0.0,0.9); ofRect(0,0,mainScreenW-1,mainScreenH); ofDisableAlphaBlending(); } timeline.draw(); //////////////////////////////////// }else{ ofBackground(20,20,20); ofEnableAlphaBlending(); if(isFullscreen){ // image glColor4f(1.0,1.0,1.0,1.0); splashImage.draw((mainScreenW/2) - 256,(mainScreenH/2) - 153); // loading bar ofSetColor(9,147,211,235); ofRect((mainScreenW/2) - 240,(mainScreenH/2) - 144,(ofGetElapsedTimeMillis()*1.0f/splashWait)*480.0f,6); ofDisableAlphaBlending(); }else{ // image glColor4f(1.0,1.0,1.0,1.0); splashImage.draw((MAIN_WINDOW_W/2) - 256,(MAIN_WINDOW_H/2) - 153); // loading bar ofSetColor(9,147,211,235); ofRect((MAIN_WINDOW_W/2) - 240,(MAIN_WINDOW_H/2) - 144,(ofGetElapsedTimeMillis()*1.0f/splashWait)*480.0f,6); ofDisableAlphaBlending(); } } }
//------------------------------- void ofxControlPanel::draw(){ if( hidden ) return; lastFrameDrawn = ofGetFrameNum(); ofPushStyle(); ofEnableAlphaBlending(); float panelH = boundingBox.height; if( minimize ){ panelH = topBar.height; } if(!bInvisible || !elementSelected){ glPushMatrix(); glTranslatef(boundingBox.x, boundingBox.y, 0); //draw the background ofFill(); glColor4fv(bgColor.getColorF()); ofRect(0, 0, boundingBox.width, panelH); //draw the outline ofNoFill(); glColor4fv(outlineColor.getColorF()); ofRect(0, 0, boundingBox.width, panelH); ofLine(0, topBar.height, boundingBox.width, topBar.height); glPopMatrix(); ofRect(minimizeButton.x, minimizeButton.y, minimizeButton.width, minimizeButton.height); if ( bDoSaveRestore ){ ofPushStyle(); ofFill(); if( saveDown )glColor4fv(fgColor.getSelectedColorF()); else glColor4fv(fgColor.getColorF()); ofRect(saveButton.x, saveButton.y, saveButton.width,saveButton.height); ofSetColor(255, 255, 255); displayText.renderString("save", saveButton.x + 3, saveButton.y + saveButton.height -3); ofPopStyle(); ofPushStyle(); ofFill(); if( restoreDown )glColor4fv(fgColor.getSelectedColorF()); else glColor4fv(fgColor.getColorF()); ofRect(restoreButton.x, restoreButton.y, restoreButton.width,restoreButton.height); ofSetColor(255, 255, 255); displayText.renderString("restore", restoreButton.x + 3, restoreButton.y + restoreButton.height -3); ofPopStyle(); } ofPushMatrix(); ofTranslate(2,0,0); glColor4fv(textColor.getColorF()); guiBaseObject::renderText(); ofPopMatrix(); } if( !minimize ){ //don't let gui elements go out of their panels glEnable(GL_SCISSOR_TEST); glScissor(boundingBox.x, ofGetHeight() - ( boundingBox.y + boundingBox.height - (-2 + topSpacing) ), boundingBox.width - borderWidth , boundingBox.height); if(!bInvisible || !elementSelected){ for(int i = 0; i < (int) panelTabs.size(); i++){ if( i == selectedPanel){ ofPushStyle(); ofFill(); glColor4fv(fgColor.getSelectedColorF()); ofRect(panelTabs[i].x, panelTabs[i].y, panelTabs[i].width, panelTabs[i].height); glColor4fv(outlineColor.getColorF()); ofPopStyle(); } glColor4fv(outlineColor.getColorF()); ofNoFill(); ofRect(panelTabs[i].x, panelTabs[i].y, panelTabs[i].width, panelTabs[i].height); } } glPushMatrix(); glTranslatef(hitArea.x, hitArea.y, 0); for(int i = 0; i < (int) panels.size(); i++){ if( i == selectedPanel ){ panels[i]->setShowOnlySelectedElement(bInvisible); panels[i]->render(); } } glPopMatrix(); glDisable(GL_SCISSOR_TEST); } ofPopStyle(); if(bShowStatusBar){ ofPushStyle(); float textH = displayText.getTextSingleLineHeight() + 4; float yPos = ofGetHeight()-textH; glColor4fv(bgColor.getColorF()); ofRect(0, yPos, ofGetWidth(), textH); glColor4fv(textColor.getColorF()); displayText.renderString("Fps: " + ofToString(ofGetFrameRate(), 0) + " Status: " + statusMessage, 4, yPos + textH - 4); ofPopStyle(); } }
//-------------------------------------------------------------- void testApp::draw() { // glActiveTexture(GL_TEXTURE0); if (bSetup) { arhelper.draw(); if (bText) { glPushMatrix(); ofSetColor(255 , 255, 255 ); string msg = "";; myFont.drawString(msg, (ofGetWidth()/2)-myFont.stringWidth(msg)/2,ofGetHeight()/2); glPopMatrix(); } ofSetupScreen(); glDisable(GL_DEPTH_TEST); if (fadable.getAlpha()>0) { ofPushStyle(); ofEnableAlphaBlending(); ofSetColor(0,0,0,maskA*fadable.getAlpha()); ofRect(0,0,ofGetWidth(),ofGetHeight()); if (bLoaded) { #ifdef INSTRUCTION int cx = ofGetWidth()/2; int cy = ofGetHeight()/2; ofSetColor(255,255,255); shaderBGSub.setShaderActive(true); shaderBGSub.setUniform("tex1", 1); shaderBGSub.setUniform("tex2", 2); shaderBGSub.setUniform("tol", tol); player.draw(cx-vw/2,cy-vh/2); myTexture2.unbind(); myTexture.unbind(); shaderBGSub.setShaderActive(false); glDisable(GL_DEPTH_TEST); #endif //#ifdef INSTRUCTION } ofDisableAlphaBlending(); ofPopStyle(); } ofSetColor(0xffffff); gui.draw(); } else { ofEnableAlphaBlending(); ofSetColor(255,255,255,255*sinf(ofGetElapsedTimef())+125); loading.draw(0,0); ofDisableAlphaBlending(); ofDrawBitmapString("Loading ... ",ofGetWidth()/2,ofGetHeight()/2); } }
//-------------------------------------------------------------- void testApp::draw(){ ofRectangle previewWindow(20,20,640,480); ofRectangle playbackWindow(20+640,20,640,480); // draw the background boxes ofPushStyle(); ofSetColor(0); ofFill(); ofRect(previewWindow); ofRect(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); ofLine(20, 20, 640+20, 480+20); ofLine(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); } ofRect(previewWindow); ofPopStyle(); //draw instructions ofPushStyle(); ofSetColor(255); ofDrawBitmapString("' ' space bar to toggle recording", 680, 540); ofDrawBitmapString("'v' switches video device", 680, 560); ofDrawBitmapString("'a' swiches 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(); }
void MaskFrame::drawLive(DisplayMode mode, StretchMode stretchMode){ ofPushMatrix(); ofTranslate(this->livePosition.x, this->livePosition.y); if(this->canDrawLive()){ homographyMode = stretchMode == HOMOGRAPHY && maskPoints.size() == 4; ofSetColor(ofColor::white); if(homographyMode) { prepareHomography(); homography.begin(input, output); pattern->drawLayer(0, false); homography.end(); } else { pattern->beginMask(); ofPushStyle(); { ofFill(); ofBackground(ofColor::black); ofBeginShape(); for(int i = 0; i < maskPoints.size(); i++){ if(stretchMode == STRETCH_TO_MASKFRAME) { x = ofMap(maskPoints[i]->getLiveX(), 0, getLiveWidth(), 0, pattern->getWidth()); y = ofMap(maskPoints[i]->getLiveY(), 0, getLiveHeight(), 0, pattern->getHeight()); } else { x = maskPoints[i]->getLiveX(); y = maskPoints[i]->getLiveY(); } ofVertex(x, y); } ofEndShape(); } ofPopStyle(); pattern->endMask(); if(stretchMode == STRETCH_TO_MASKFRAME) { pattern->draw(0, 0, getLiveWidth(), getLiveHeight()); } else { pattern->draw(); } } } if(mode != Live){ bool hasHighlightedDragHandle = this->hasHighlightedDragHandle(); bool hasHighlightedMaskPoint = this->hasHighlightedMaskPoint(); ofPushStyle(); { if((highlighted || hasHighlightedDragHandle || getTransformState() == Scaling) && !hasHighlightedMaskPoint){ ofSetColor(highlightedColor); }else{ ofSetColor(notHighlightedColor); } ofRect(0, 0, this->liveWidth, this->liveHeight); if((highlighted || hasHighlightedDragHandle) && !hasHighlightedMaskPoint){ for(int i = 0; i < dragHandles.size(); i++){ dragHandles[i]->drawLive(); } } } ofPopStyle(); } if(mode == Design){ if(maskPoints.size() > 2){ ofSetColor(maskLineColor); for(int i = 0; i < maskPoints.size(); i++){ int nextIndex = getNextIndex(i, maskPoints.size()); ofLine(maskPoints[i]->getLiveX(), maskPoints[i]->getLiveY(), maskPoints[nextIndex]->getLiveX(), maskPoints[nextIndex]->getLiveY()); } } } if(mode != Live){ if(this->hasAGhostPoint){ ghostPoint.drawLive(); } for(int i = 0; i < maskPoints.size(); i++){ maskPoints[i]->drawLive(); } } ofPopMatrix(); }
//-------------------------------------------------------------- void ofApp::draw(){ gui.draw(); videoGrayscaleCvImage.draw(120,20, 312,240); // videoBgImage.draw(312+40, 20, 312, 240); // this is where the point image comes(20,240+40); panel.draw(); //draw 24x24 ofSetColor(255, 255, 255); for (int i = 0; i*10 < video.getWidth()-72; i++){ for (int j = 0; j*10 < video.getHeight(); j++){ int pct = ofMap(leds_flip[24*j+i], 0,255, 0,5); ofSetColor(255,255,255); ofCircle(120 + i*10 + 13/2, 240 + 40 + j*10 + 10/2, pct); } //draw 8x72 for (int i=0; i<72; i++) { for (int j=0; j<8; j++) { int pct = ofMap(led_matrix[j][i], 0, 255, 0, 5); ofCircle(120-1 + 13/2 + i*10, 280-1 + 240 + 20 + 10/2 + j*10, pct); } } //additional line ofPushStyle(); ofNoFill(); ofSetColor(255, 0, 0); ofSetLineWidth(1.5); ofSetRectMode(OF_RECTMODE_CORNER); //3x3 grid for (int i=0; i<3; i++) { for (int j=0; j<3; j++) { ofRect(120-1 + 240/3*i,280-1 + 240/3*j, 240/3, 240/3); } } ofSetColor(0, 255, 0); //9 strip for (int i=0; i<9; i++) { ofRect(120-1 + 240/3*i,280-1 + 240 + 20, 240/3, 240/3); } //8 lines for casode ofSetColor(255, 0, 0); for (int i=0; i<8; i++) { ofLine(120-1 +13/2, 280-1 + 240 + 20 + 10/2 + 10*i, 120-1 +13/2 + 10*(72-1), 280-1 + 240 + 20 + 10/2 + 10*i); } ofPopStyle(); } if(!isInitialized) ofDrawBitmapString("PRESS 'S' TO SEND KICKOFF BYTE", 400, 400); else { //just for debug ofDrawBitmapString("num messages sent total: "+ ofToString(numMsgSent), 400, 450); } }
//-------------------------------------------------------------- void testApp::draw() { ofBackground(0); ofSetColor(255); ofSetRectMode(OF_RECTMODE_CORNER); backgroundimg.draw(0,0, ofGetWidth(), ofGetHeight()); ofSetColor(0, 173, 238, 125); if(startScreen){ ofSetColor(236, 28, 36); visitor82.drawString("VFA PONG", bounds.x + bounds.width/2 - visitor82.stringWidth("VFA PONG")/2, bounds.y + bounds.height/2); visitor82.drawString("Press button to start a new game", bounds.x + bounds.width/2 - 775,bounds.y + bounds.height/2 + 100); printf("startscreen \n"); } if(!user1load && players && !startScreen){ // printf("alpha: %d: \n", alpha); ofSetColor(0, 173, 238, alpha); ofSetRectMode(OF_RECTMODE_CORNER); ofRect(bounds.x,bounds.y + 86, bounds.width/2, bounds.height - 86); ofSetColor(255); visitor82.drawString("Left Player Tap!", bounds.x + 80, bounds.y + bounds.height/2); visitor42.drawString("Press button to play as guest!", bounds.x + 30, bounds.y + bounds.height/2 + 100); } if(user1load && !user2load && players){ ofSetColor(0, 173, 238, alpha); ofSetRectMode(OF_RECTMODE_CORNER); ofRect(bounds.x + bounds.width/2, bounds.y + 86, bounds.width/2, bounds.height - 86); ofSetColor(255); user1.draw(bounds.x + bounds.width/4 - 50, bounds.height/2, 100, 100); visitor82.drawString(username1, bounds.x + bounds.width/4 - visitor82.stringWidth(username1)/2, bounds.y + bounds.height/2 + 120); ofSetColor(255); visitor82.drawString("Right Player Tap!", bounds.x + bounds.width/2 + 80, bounds.y + bounds.height/2); visitor42.drawString("Press button to play as guest", bounds.x + 30 + bounds.width/2, bounds.y + bounds.height/2 + 100); } if(user1load && user2load){ countdownnumbool = true; ofSetColor(255); user1.draw(bounds.x + bounds.width/4 - 50, bounds.height/2, 100, 100); user2.draw(bounds.x + bounds.width/4 - 50 + bounds.width/2, bounds.height/2, 100, 100); visitor82.drawString(username1, bounds.x + bounds.width/4 - visitor82.stringWidth(username1)/2, bounds.y + bounds.height/2 + 120); visitor82.drawString(username2, bounds.x + bounds.width/4 - visitor82.stringWidth(username2)/2 + bounds.width/2, bounds.y + bounds.height/2 + 120); if(countdownnum > 300) visitor82.drawString("3", bounds.x + bounds.width/2, bounds.y + bounds.height/2); if(countdownnum > 200 &&countdownnum < 300 ) visitor82.drawString("2", bounds.x + bounds.width/2, bounds.y + bounds.height/2); if(countdownnum > 100 && countdownnum < 200) visitor82.drawString("1", bounds.x + bounds.width/2, bounds.y + bounds.height/2); if(countdownnum > 0 && countdownnum < 100) visitor82.drawString("GO!", bounds.x + bounds.width/2, bounds.y + bounds.height/2); if (countdownnum == 0 && countdownnumbool){ countdownnumbool = false; countdownnum = 400; startGame(); drawusers = true; players = false; user1load = false; user2load = false; newBall(); } } if(startGameBool){ for(int i=0; i<circles.size(); i++) { Data * data = (Data*)circles[i].getData(); ofSetColor(255); ofEnableAlphaBlending(); // ofRectMode(OF_RECTMODE_CORNER); vimeologo.draw(circles[i].getPosition().x, circles[i].getPosition().y, circles[i].getRadius() * 2, circles[i].getRadius() * 2); } for(int i=0; i<paddles.size(); i++) { ofFill(); Data * data = (Data*)paddles[i].getData(); ofSetColor(236, 28, 36); paddles[i].draw(); } for(int i=0; i<winningvideos.size(); i++) { winningvideos[i].draw(); } for(int i=0; i<nomvideos.size(); i++) { nomvideos[i].draw(); } if (score1 > 4 && counter < 200) { ofSetColor(255,221,21); visitor82.drawString("YOU WIN!", bounds.x + bounds.width/4 - visitor82.stringWidth("YOU WIN!")/2, bounds.y + bounds.height/2 - 120); visitor82.drawString("YOU LOSE!", bounds.x + bounds.width/4 - visitor82.stringWidth("YOU LOSE!")/2 + bounds.width/2, bounds.y + bounds.height/2 - 120); ofSetColor(255); ofSetRectMode(OF_RECTMODE_CORNER); user1.draw(bounds.x + bounds.width/4 - 50, bounds.height/2 + 20, 100, 100); user2.draw(bounds.x + bounds.width/4 - 50 + bounds.width/2, bounds.height/2 + 20, 100, 100); ofSetColor(255,221,21); visitor82.drawString(username1, bounds.x + bounds.width/4 - visitor82.stringWidth(username1)/2, bounds.y + bounds.height/2 + 120); visitor82.drawString(username2, bounds.x + bounds.width/4 - visitor82.stringWidth(username2)/2 + bounds.width/2, bounds.y + bounds.height/2 + 120); counter++; if (!user1photo.compare("images/guest.jpg")){ ofxOscMessage m; m.setAddress( "/user" ); m.addStringArg( user1photo ); sender.sendMessage( m ); } } if (score2 > 4 && counter < 200) { ofSetColor(255,221,21); visitor82.drawString("YOU LOSE!", bounds.x + bounds.width/4 - visitor82.stringWidth("YOU LOSE!")/2, bounds.y + bounds.height/2 - 120); visitor82.drawString("YOU WIN!", bounds.x + bounds.width/4 - visitor82.stringWidth("YOU WIN!")/2 + bounds.width/2, bounds.y + bounds.height/2 - 120); ofSetColor(255); ofSetRectMode(OF_RECTMODE_CORNER); user1.draw(bounds.x + bounds.width/4 - 50, bounds.height/2 + 20, 100, 100); user2.draw(bounds.x + bounds.width/4 - 50 + bounds.width/2, bounds.height/2 + 20, 100, 100); ofSetColor(255,221,21); visitor82.drawString(username1, bounds.x + bounds.width/4 - visitor82.stringWidth(username1)/2, bounds.y + bounds.height/2 + 120); visitor82.drawString(username2, bounds.x + bounds.width/4 - visitor82.stringWidth(username2)/2 + bounds.width/2, bounds.y + bounds.height/2 + 120); counter++; if (!user2photo.compare("images/guest.jpg")){ ofxOscMessage m; m.setAddress( "/user" ); m.addStringArg( user2photo ); sender.sendMessage( m ); } } ofSetColor(236, 28, 36); if (drawusers){ visitor82.drawString("SCORE " + ofToString(score1, 1), bounds.x+120, bounds.y +65); visitor82.drawString("SCORE " + ofToString(score2, 1), bounds.x + bounds.width/2 + 120, bounds.y +65); ofSetColor(255); user1.draw(bounds.x+ 30, bounds.y+35, 80,80); user2.draw(bounds.x+ 30 + bounds.width/2, bounds.y+35, 80,80); } } }
//-------------------------------------------------------------- void testApp::draw() { tileSaver.begin(); //-- background. ofFill(); ofSetColor( 0x000000 ); ofRect( 0, 0, ofGetWidth(), ofGetHeight() ); //-- large. if( bDrawColor ) { ofColor c0 = colorPicker0.getColor(); ofFill(); ofSetColor( c0.r, c0.g, c0.b ); ofRect( 0, 0, ofGetWidth(), ofGetHeight() ); drawContourLines( contourBlobsSimplified, true ); } if( bDrawLines ) { ofNoFill(); ofSetColor( 0xFFFFFF ); drawContourLines( contourBlobsScaled ); } if( bDrawSimplified ) { ofNoFill(); ofSetColor( 0xFFFFFF ); drawContourLines( contourBlobsSimplified ); } if( bDrawCurves ) { ofNoFill(); ofSetColor( 0xFFFFFF ); drawContourCurveLines( contourBlobsScaled ); } if( bDrawPoints ) { ofFill(); ofSetColor( 0xFF0000 ); drawContourPoints( contourBlobsScaled ); } tileSaver.end(); if( screenGrabUtil.isRecording() ) screenGrabUtil.save(); //-- debug. if( !bDebug ) return; int pad; pad = 10; glPushMatrix(); glTranslatef( ofGetWidth() - debugRect.width - pad, pad, 0 ); drawBorder( debugRect ); drawNoiseImage(); glTranslatef( 0, debugRect.height + pad, 0 ); drawBorder( debugRect ); drawNoiseBand(); glTranslatef( 0, debugRect.height + pad, 0 ); drawBorder( debugRect ); drawNoiseBandSum(); glTranslatef( 0, debugRect.height + pad, 0 ); drawBorder( debugRect ); drawContoursSmall(); glPopMatrix(); gui.draw(); }
//-------------------------------------------------------------- void testApp::draw(){ #pragma mark BUTTON if(folderPath == "") ofSetColor(100, 100, 100); else ofSetColor(100, 200, 100); ofRect(10, 10, 100, 40); if(!imageCnt) ofSetColor(100, 100, 100); else ofSetColor(100, 200, 100); ofRect(120, 10, 100, 40); if(!colorTable.size()) ofSetColor(100, 100, 100); else ofSetColor(100, 200, 100); ofRect(230, 10, 100, 40); if(!bFileDone) ofSetColor(100, 100, 100); else ofSetColor(100, 200, 100); ofRect(340, 10, 100, 40); #pragma mark BUTTON TEXT ofSetColor(0, 0, 0); ofDrawBitmapString(" Open(O)", 10, 35); ofDrawBitmapString(" Load(L)", 120, 35); ofDrawBitmapString(" Analysts(A)", 230, 35); ofDrawBitmapString(" Create(C)", 340, 35); #pragma mark IMAGE SCALE ofSetColor(150,0,0); ofDrawBitmapString("set Image Width : " + ofToString(imgWidth), 10, 70); ofDrawBitmapString("set Image Height : " + ofToString(imgHeight), 10, 90); #pragma mark SCALE CONTROL BUTTON ofSetColor(150,150,150); ofRect(204+36*0+4*0, 58, 36, 16); ofRect(204+36*1+4*1, 58, 36, 16); ofRect(204+36*2+4*2, 58, 36, 16); ofRect(204+36*3+4*3, 58, 36, 16); ofRect(204+36*4+4*4, 58, 36, 16); ofRect(204+36*5+4*5, 58, 36, 16); ofRect(204+36*0+4*0, 78, 36, 16); ofRect(204+36*1+4*1, 78, 36, 16); ofRect(204+36*2+4*2, 78, 36, 16); ofRect(204+36*3+4*3, 78, 36, 16); ofRect(204+36*4+4*4, 78, 36, 16); ofRect(204+36*5+4*5, 78, 36, 16); ofSetColor(150,0,0); ofDrawBitmapString("+100 -100 +10 -10 +1 -1", 206, 70); ofDrawBitmapString("+100 -100 +10 -10 +1 -1", 206, 90); #pragma mark RESULT STRING ofSetColor(0); if(folderPath.length() >= 35) { tmpPath = folderPath; while (tmpPath.size() > 35) { tmpPath.erase(tmpPath.begin()); } ofDrawBitmapString("Folder Path : ..." + tmpPath, 10, 120); } else ofDrawBitmapString("Folder Path : " + folderPath, 10, 120); ofDrawBitmapString("Loaded Image : " + ofToString(imageCnt), 10, 140); ofDrawBitmapString("Pixel : " + ofToString(colorCnt), 10, 160); if (colorTable.size() > 0) { ofDrawBitmapString("Used Color : " + ofToString(colorTable.size()), 10, 180); }else{ ofDrawBitmapString("Used Color : 0", 10, 180); } #pragma mark EXPANSION PANNEL if(bFileDone){ ofSetWindowShape(450,330); ofDrawBitmapString("------------------------------------------------------", 10, 200); if(ofToInt(chgColorNumStr) >= 1 && ofToInt(chgColorNumStr) <= colorCnt+1){ for(int i=0; i<cutterInt.size(); i++){ ofSetColor(colorTable[cutterInt[i]-1]); ofRect(10+i*430/cutterInt.size(), 224, 430/cutterInt.size(), 20); } }else{ ofSetColor(255,255,255); ofRect(10, 224, 430, 20); } ofSetColor(0); if(chgColorNumStr.length() >= 30){ int tmp = chgColorNumStr.length(); ofDrawBitmapString(" "+ chgColorNumStr, 12+(30-tmp)*8, 218); }else{ ofDrawBitmapString(" "+ chgColorNumStr, 12, 218); } ofSetColor(200, 200, 200); ofRect(0,200, 173, 20); ofSetColor(0); ofDrawBitmapString("input color number : ",12, 218); ofSetColor(wantColor); ofRect(10, 244, 430, 20); ofSetColor(150,150,150); ofRect(10, 278, 60, 40); ofSetColor(0); ofDrawBitmapString("Change", 12, 302); } #pragma mark SCALE CONTROL BUTTON2 ofSetColor(150,0,0); ofDrawBitmapString("R : " + ofToString(wr), 110, 278); ofDrawBitmapString("G : " + ofToString(wg), 110, 298); ofDrawBitmapString("B : " + ofToString(wb), 110, 318); ofSetColor(150,150,150); ofRect(204+36*0+4*0, 266, 36, 16); ofRect(204+36*1+4*1, 266, 36, 16); ofRect(204+36*2+4*2, 266, 36, 16); ofRect(204+36*3+4*3, 266, 36, 16); ofRect(204+36*4+4*4, 266, 36, 16); ofRect(204+36*5+4*5, 266, 36, 16); ofRect(204+36*0+4*0, 286, 36, 16); ofRect(204+36*1+4*1, 286, 36, 16); ofRect(204+36*2+4*2, 286, 36, 16); ofRect(204+36*3+4*3, 286, 36, 16); ofRect(204+36*4+4*4, 286, 36, 16); ofRect(204+36*5+4*5, 286, 36, 16); ofRect(204+36*0+4*0, 306, 36, 16); ofRect(204+36*1+4*1, 306, 36, 16); ofRect(204+36*2+4*2, 306, 36, 16); ofRect(204+36*3+4*3, 306, 36, 16); ofRect(204+36*4+4*4, 306, 36, 16); ofRect(204+36*5+4*5, 306, 36, 16); ofSetColor(150,0,0); ofDrawBitmapString("+100 -100 +10 -10 +1 -1", 206, 278); ofDrawBitmapString("+100 -100 +10 -10 +1 -1", 206, 298); ofDrawBitmapString("+100 -100 +10 -10 +1 -1", 206, 318); #pragma mark PROCESS MESSAGE if(bPushLoad) { ofSetColor(100, 100, 100); ofRect(0, 0, 450, 200); ofSetColor(255, 255, 255); ofDrawBitmapString("Load... ", 190, 100); bLoad = true; } if(bPushAnal) { ofSetColor(100, 100, 100); ofRect(0, 0, 450, 200); ofSetColor(255, 255, 255); ofDrawBitmapString("Analyst... ", 190, 100); bAnal = true; } if(bPushCreate) { ofSetColor(100, 100, 100); ofRect(0, 0, 450, 200); ofSetColor(255, 255, 255); ofDrawBitmapString("Create... ", 190, 100); bCreate = true; } if(bImageMakePush) { ofSetColor(100, 100, 100); ofRect(0, 0, 450, 270); ofSetColor(255, 255, 255); ofDrawBitmapString("Change... ", 190, 100); bImageMakeStart = true; } }
//-------------------------------------------------------------- void ofApp::draw(){ float lineHeight = ofMap(mouseY, 0, ofGetHeight(), 0, 2, true); unicodeFont.setLineHeight(lineHeight); float x = 30; float y = 40; string demoText = "This is my text in BitStream Vera font."; float fontSize = 28; // simple demo ////////////////////////////////////////////////////////// drawPoint(x, y); //draw insertion point ofSetColor(255); TIME_SAMPLE_START("simple draw"); font.draw( demoText, //text to draw fontSize, //font size x, //x coord where to draw y //y coord where to draw ); TIME_SAMPLE_STOP("simple draw"); // bounding box demo /////////////////////////////////////////////////// ofRectangle bbox; ofRectangle bboxMultiline; ofSetColor(255, 0, 0, 32); TIME_SAMPLE_START("bbox"); bbox = font.getBBox( demoText, fontSize, x, y); TIME_SAMPLE_STOP("bbox"); ofRect( bbox ); // draw multiline text ///////////////////////////////////////////////// y += 25 + bbox.height; drawPoint(x, y); //draw insertion point ofSetColor(255); string s = (string)"ofxFontStash can draw multiline text" + "\n" + "It also supports unicode strings: " + "\n" + "槊監しゅ祟䤂לרפובליקה. אם מיזם 銆銌 憉 圩芰敔 तकनिकल कार्यलय"; TIME_SAMPLE_START("drawMultiLine"); unicodeFont.drawMultiLine( s, fontSize, x, y); TIME_SAMPLE_STOP("drawMultiLine"); // multiline bbox ///////////////////////////////////////////////////// ofSetColor(0, 255, 0, 32); TIME_SAMPLE_START("getBoundingBoxSize"); bboxMultiline = unicodeFont.getBBox( s, fontSize, x, y); TIME_SAMPLE_STOP("getBoundingBoxSize"); ofRect( bboxMultiline ); // draw multiline column with a fixed width /////////////////////////// y += 25 + bboxMultiline.height; drawPoint(x, y); //draw insertion point ofSetColor(255); s = "And you can wrap text to a certain (mouseX) width:\n\nLorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam."; //s = "international bananas"; int numLines = 0; bool wordsWereCropped; ofRectangle column; TIME_SAMPLE_START("drawMultiLineColumn"); column = font.drawMultiLineColumn( s, /*string*/ fontSize, /*size*/ x, y, /*where*/ MAX( 10 ,mouseX - x), /*column width*/ numLines, /*get back the number of lines*/ false, /* if true, we wont draw (just get bbox back) */ 5, /* max number of lines to draw, crop after that */ true, /*get the final text formatting (by adding \n's) in the supplied string; BE ARWARE that using TRUE in here will modify your supplied string! */ &wordsWereCropped /* this bool will b set to true if the box was to small to fit all text*/ ); TIME_SAMPLE_STOP("drawMultiLineColumn"); //report if some words had to be cropped to fit in the column when using drawMultiLineColumn() if(!wordsWereCropped) ofSetColor(255,32); else (ofGetFrameNum()%6 <= 2) ? ofSetColor(255,32):ofSetColor(255,0,0,32); //flash if cropped ofRect(column); // batch drawing, optimized for multiple drawing calls ///////////////// y += column.height + 25; drawPoint(x, y); //draw insertion point ofSetColor(255); TIME_SAMPLE_START("drawBatch"); font.beginBatch(); //call "begin" before drawing fonts for (int i = 0; i < 5; i++){ font.drawBatch("batch mode #" + ofToString(i+1), fontSize, x, y + i * fontSize ); } font.endBatch(); //call "end" once finished TIME_SAMPLE_STOP("drawBatch"); // formatted text ////////////////////////////////////////////////////// string formattedText = "the #0xff0000 @1 %2.0 red %1.0 #0xffffff @0 apple is on the big %4.0 #0x00ff00 tree."; ofPushMatrix(); ofTranslate(20,500); ofSetColor(255); ofVec2f size = font.drawMultiColumnFormatted(formattedText, 22, mouseX); ofSetColor(255,10); ofRect(0, 0, size.x, size.y); ofPopMatrix(); // rotating text /////////////////////////////////////////////////////// ofPushMatrix(); ofTranslate(x + 400, y + 50); ofRotate( -200 * ofGetElapsedTimef(), 0, 0, 1); ofSetColor(ofRandom(255), ofRandom(255), ofRandom(255)); font.draw("surrealismoooo!", fontSize, 0, 0 ); drawPoint(0,0); ofPopMatrix(); // scaling text with mipmaps /////////////////////////////////////////// ofPushMatrix(); ofTranslate(600, 40); float scale = mouseY /(float) ofGetHeight(); ofPushMatrix(); ofScale(scale, scale); ofSetColor(255); unicodeFont.draw("MIPMAPS :)", fontSize * 2, 0, 0 ); drawPoint(0,0); ofPopMatrix(); ofTranslate(0, 30); ofScale(scale, scale); font.draw("NO MIPMAPS :(", fontSize * 2, 0, 0 ); drawPoint(0,0); ofPopMatrix(); }
void ofxTLCurves::drawModalContent(){ //****** DRAW EASING CONTROLS if(!drawingEasingWindow){ return; } ofxTLTweenKeyframe* tweenFrame = (ofxTLTweenKeyframe*) selectedKeyframe; if(tweenFrame == NULL){ if(selectedKeyframes.size() == 0){ return; } tweenFrame = (ofxTLTweenKeyframe*)selectedKeyframes[0]; } for(int i = 0; i < easingTypes.size(); i++){ //TODO turn into something like selectionContainsEaseType(); //so that we can show the multi-selected easies if(easingTypes[i] == ((ofxTLTweenKeyframe*)selectedKeyframes[0])->easeType){ ofSetColor(150, 100, 10); } else{ ofSetColor(80, 80, 80); } ofFill(); ofRect(easingWindowPosition.x + easingTypes[i]->bounds.x, easingWindowPosition.y + easingTypes[i]->bounds.y, easingTypes[i]->bounds.width, easingTypes[i]->bounds.height); ofSetColor(200, 200, 200); timeline->getFont().drawString(easingTypes[i]->name, easingWindowPosition.x + easingTypes[i]->bounds.x+11, easingWindowPosition.y + easingTypes[i]->bounds.y+10); ofNoFill(); ofSetColor(40, 40, 40); ofRect(easingWindowPosition.x + easingTypes[i]->bounds.x, easingWindowPosition.y + easingTypes[i]->bounds.y, easingTypes[i]->bounds.width, easingTypes[i]->bounds.height); } for(int i = 0; i < easingFunctions.size(); i++){ //TODO: turn into something like selectionContainsEaseFunc(); if(easingFunctions[i] == tweenFrame->easeFunc){ ofSetColor(150, 100, 10); } else{ ofSetColor(80, 80, 80); } ofFill(); ofRect(easingWindowPosition.x + easingFunctions[i]->bounds.x, easingWindowPosition.y +easingFunctions[i]->bounds.y, easingFunctions[i]->bounds.width, easingFunctions[i]->bounds.height); ofSetColor(200, 200, 200); // timeline->getFont().drawString(easingFunctions[i]->name, // easingWindowPosition.x + easingFunctions[i]->bounds.x+10, // easingWindowPosition.y + easingFunctions[i]->bounds.y+15); ofPushMatrix(); ofTranslate(easingWindowPosition.x + easingFunctions[i]->bounds.x, easingWindowPosition.y + easingFunctions[i]->bounds.y); if(tweenFrame->easeType->type == ofxTween::easeIn){ easingFunctions[i]->easeInPreview.draw(); } else if(tweenFrame->easeType->type == ofxTween::easeOut){ easingFunctions[i]->easeOutPreview.draw(); } else { easingFunctions[i]->easeInOutPreview.draw(); } ofPopMatrix(); ofNoFill(); ofSetColor(40, 40, 40); ofRect(easingWindowPosition.x + easingFunctions[i]->bounds.x, easingWindowPosition.y +easingFunctions[i]->bounds.y, easingFunctions[i]->bounds.width, easingFunctions[i]->bounds.height); } }
void ServiceEntity::draw(void) { ODL_OBJENTER(); //#### ServiceViewerApp & owner = _panel.getOwner(); _panel.draw(); if (_drawConnectMarker) { ofPoint markerPos(_panel.getWidth() / 2, _panel.getHeader()); ofSetColor(ServiceViewerApp::getMarkerColor()); ofFill(); ofCircle(markerPos + getShape().getTopLeft(), kMarkerSide / 2); } else if (_drawDisconnectMarker) { ofPoint markerPos(_panel.getWidth() / 2, _panel.getHeader()); ofSetColor(ServiceViewerApp::getMarkerColor()); ofNoFill(); ofSetLineWidth(2); ofCircle(markerPos + getShape().getTopLeft(), kMarkerSide / 2); } else if (_drawMoveMarker) { ofPoint markerPos(_panel.getWidth() / 2, _panel.getHeader()); ofSetColor(ServiceViewerApp::getMarkerColor()); ofFill(); markerPos += getShape().getTopLeft() - ofPoint(kMarkerSide / 2, kMarkerSide / 2); ofRect(markerPos, kMarkerSide, kMarkerSide); } for (int ii = 0, mm = _panel.getNumPorts(); mm > ii; ++ii) { PortEntry * anEntry = _panel.getPort(ii); if (anEntry) { ofPoint aCentre(anEntry->getCentre()); const PortEntry::Connections & connex = anEntry->getOutputConnections(); for (PortEntry::Connections::const_iterator walker(connex.begin()); connex.end() != walker; ++walker) { PortEntry::AnchorSide anchorHere; PortEntry::AnchorSide anchorThere; MplusM::Common::ChannelMode mode = walker->_connectionMode; PortEntry * otherEntry = walker->_otherPort; ofPoint otherCentre(otherEntry->getCentre()); ofPoint fromHere; ofPoint toThere; // Check if the destination is above the source, in which case we // determine the anchors in the reverse order. if (aCentre.y < otherCentre.y) { anchorHere = anEntry->calculateClosestAnchor(fromHere, true, false, otherCentre); anchorThere = otherEntry->calculateClosestAnchor(toThere, false, PortEntry::kAnchorBottomCentre == anchorHere, aCentre); } else { anchorThere = otherEntry->calculateClosestAnchor(toThere, false, false, aCentre); anchorHere = anEntry->calculateClosestAnchor(fromHere, true, PortEntry::kAnchorBottomCentre == anchorThere, otherCentre); } if (otherEntry->isService()) { ofSetLineWidth(owner.getServiceConnectionWidth()); } else if (otherEntry->isInputOutput()) { ofSetLineWidth(owner.getInputOutputConnectionWidth()); } else { ofSetLineWidth(owner.getNormalConnectionWidth()); } switch (mode) { case MplusM::Common::kChannelModeTCP : ofSetColor(ServiceViewerApp::getTcpConnectionColor()); break; case MplusM::Common::kChannelModeUDP : ofSetColor(ServiceViewerApp::getUdpConnectionColor()); break; default : ofSetColor(ServiceViewerApp::getOtherConnectionColor()); break; } DrawBezier(fromHere, toThere, aCentre, otherCentre); ofSetLineWidth(1); PortEntry::drawSourceAnchor(anchorHere, fromHere); PortEntry::drawTargetAnchor(anchorThere, toThere); } } } ODL_OBJEXIT(); //#### } // ServiceEntity::draw
//-------------------------------------------------------------- void ofApp::draw(){ ofBackground(0, 0, 0); ofSetColor(255, 255, 255); // ofFill(); // // ofCircle(300, 250, 100); // ofRect(200, 450, 200, 200); // ofTriangle(100, 100, 100, 200, 150, 150); // ofEllipse(500, 500, 100, 200); // ofLine(0, 0, 300, 400); // // // ofNoFill(); // ofSetLineWidth(5.0); // ofBeginShape(); // ofVertex(30, 30); // ofVertex(40, 35); // ofVertex(50, 100); // ofVertex(60, 45); // ofVertex(70, 50); // ofVertex(80, 55); // ofVertex(90, 60); // ofVertex(190, 95); // ofEndShape(); // // make grid easycam.begin(); int gridXNum = 8; int gridYNum = 6; int gridX = ofGetWidth() / gridXNum; int gridY = ofGetHeight() / gridYNum; ofSetColor(100, 100, 100); for (int i = 0; i < gridXNum; i++) { ofLine(i * gridX, 0, i * gridX, ofGetHeight()); } for (int i = 0; i < gridYNum; i++) { ofLine(0, i * gridY, ofGetWidth(), i * gridY); } ofSetColor(255, 0, 0); // draw // ofEllipse(gridX * 1, gridY * 3, gridX * 1.5, gridY * 5); ofCircle(x, y, gridX * 0.6); // ofRect(gridX * 4, gridY * 2, gridX * 2, gridY * 2); // ofColor color = ofColor(255, 0, 0); // ofSetColor(color); // ofTriangle(gridX * 2.3, gridY * 4.3, gridX * 2.3, gridY * 5.6, gridX * 3.6, gridY * 5.6); ofPushMatrix(); ofTranslate(ofGetWidth() / 2, ofGetHeight() / 2); ofRotate(45); ofRect(-100, -100, 200, 200); ofPopMatrix(); ofRect(200, 200, 200, 200); easycam.end(); }
//-------------------------------------------------------------- void ofApp::draw(){ ofSetColor(225); verdana14.drawString("Font Example - use keyboard to type", 30, 35); ofSetColor(245, 58, 135); verdana14.drawString("anti aliased", 155, 92); verdana14.drawString("anti aliased", 155, 195); verdana14A.drawString("aliased", 545, 92); ofSetColor(225); verdana14.drawString("verdana 14pt - ", 30, 92); verdana14.drawString(typeStr, 30, 111); verdana14A.drawString("verdana 14pt - ", 422, 92); ofRect(420, 97, 292, 62); ofSetColor(54, 54, 54); verdana14A.drawString(typeStr, 422, 111); ofSetColor(29,29,29); ofLine(30, 169, ofGetWidth()-4, 169); ofSetColor(225); verdana14.drawString("verdana 30pt - ", 30, 195); verdana30.drawString(typeStr, 30, 229); ofSetColor(29,29,29); ofLine(30, 312, ofGetWidth()-4, 312); ofSetColor(245, 58, 135); franklinBook14.drawString("anti aliased", 169, 338); franklinBook14A.drawString("aliased", 560, 338); ofSetColor(225); franklinBook14.drawString("franklin book 14pt - ", 30, 338); franklinBook14.drawString(typeStr, 30, 358); franklinBook14A.drawString("franklin book 14pt - ", 422, 338); ofRect(420, 345, 292, 62); ofSetColor(54, 54, 54); franklinBook14A.drawString(typeStr, 422, 358); ofSetColor(29,29,29); ofLine(30, 418, ofGetWidth()-4, 418); ofSetColor(225); verdana14.drawString("ROTATION", 30, 445); verdana14.drawString("SCALE", 422, 445); ofPushMatrix(); string rotZ = "Rotate Z"; ofRectangle bounds = verdana30.getStringBoundingBox(rotZ, 0, 0); ofTranslate(110 + bounds.width/2, 500 + bounds.height / 2, 0); ofRotateZ(ofGetElapsedTimef() * -30.0); verdana30.drawString(rotZ, -bounds.width/2, bounds.height/2 ); ofPopMatrix(); ofPushMatrix(); string scaleAA = "SCALE AA"; bounds = verdana14.getStringBoundingBox(scaleAA, 0, 0); ofTranslate(500 + bounds.width/2, 480 + bounds.height / 2, 0); ofScale(2.0 + sin(ofGetElapsedTimef()), 2.0 + sin(ofGetElapsedTimef()), 1.0); verdana14.drawString(scaleAA, -bounds.width/2, bounds.height/2 ); ofPopMatrix(); ofPushMatrix(); string scaleA = "SCALE ALIASED"; bounds = verdana14A.getStringBoundingBox(scaleA, 0, 0); ofTranslate(500 + bounds.width/2, 530 + bounds.height / 2, 0); ofScale(2.0 + cos(ofGetElapsedTimef()), 2.0 + cos(ofGetElapsedTimef()), 1.0); verdana14A.drawString(scaleA, -bounds.width/2, bounds.height/2 ); ofPopMatrix(); }
void ofxTimeMeasurements::draw(float x, float y) { if (!enabled) return; 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 && timeAveragePercent < 1.0f){ // 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<Poco::Thread*, ThreadInfo>::iterator ii; vector<Poco::Thread*> expiredThreads; //lets make sure the Main Thread is always on top vector< pair<Poco::Thread*, ThreadInfo> > sortedThreadList; for( ii = threadInfo.begin(); ii != threadInfo.end(); ++ii ){ //walk all thread trees if (ii->first == NULL){ //main thread is NULL! sortedThreadList.insert(sortedThreadList.begin(), *ii); }else{ sortedThreadList.push_back(*ii); } } 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 Poco::Thread* thread = sortedThreadList[k].first; core::tree<string> &tr = sortedThreadList[k].second.tree; PrintedLine header; header.formattedKey = "+" + *tr; header.color = threadInfo[thread].color; 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; while( !finishedWalking ){ string key = *wholeTreeWalker; TimeMeasurement * t = times[*wholeTreeWalker]; #if defined(USE_OFX_HISTORYPLOT) bool plotActive = false; if(plots[key]){ if(t->settings.plotting){ if(t->updatedLastFrame){ if (t->accumulating){ plots[key]->update(t->microsecondsAccum / 1000.0f); }else{ plots[key]->update(t->avgDuration / 1000.0f); } } plotsToDraw.push_back(plots[key]); plotActive = true; } } #endif bool visible = t->settings.visible; bool alive = t->life > 0.0001; if(alive){ numAlive++; } if (visible){ PrintedLine l; l.key = key; l.tm = t; 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; #if defined(USE_OFX_HISTORYPLOT) if(plotActive) l.formattedKey += " [p]"; #endif l.time = getTimeStringForTM(t); l.color = threadInfo[thread].color * ((1.0 - idleTimeColorFadePercent) + idleTimeColorFadePercent * t->life); if (!t->settings.enabled){ l.color = disabledTextColor; } if (t->key == selection && menuActive){ if(ofGetFrameNum()%5 < 4){ l.color.invert(); } } 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; } t->accumulating = false; t->microsecondsAccum = 0; //control the iterator to walk the tree "recursivelly" 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 (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<Poco::Thread*, ThreadInfo>::iterator treeIt = threadInfo.find(expiredThreads[i]); if (treeIt != threadInfo.end()) threadInfo.erase(treeIt); } mutex.unlock(); updateLongestLabel(); //update max width, 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].fullLine = drawLines[i].formattedKey + " " + drawLines[i].time; }else{ drawLines[i].fullLine = drawLines[i].formattedKey + " Error!" ; } int len = drawLines[i].fullLine.length(); if(len > tempMaxW) tempMaxW = len; }else{ //its a header drawLines[i].fullLine = drawLines[i].formattedKey; headerLocations.push_back(i); } } maxW = tempMaxW; ofSetupScreen(); //mmmm---- ofPushStyle(); ofPushMatrix(); ofScale(uiScale,uiScale); ofSetDrawBitmapMode(OF_BITMAPMODE_SIMPLE); ofFill(); ofEnableAlphaBlending(); #if defined(USE_OFX_HISTORYPLOT) //int numCols = plotsToDraw.size() for(int i = 0; i < plotsToDraw.size(); i++){ int y = ofGetHeight() / uiScale - plotHeight * (i + 1); plotsToDraw[i]->draw(0, y, ofGetWidth() / uiScale, plotHeight); ofSetColor(99); if(i != plotsToDraw.size() -1){ ofLine(0, y, ofGetWidth() / uiScale, y ); } } #endif float totalW = getWidth(); float totalH = getHeight(); ofSetColor(bgColor, 245); int barH = 1; ofRect(x, y + 1, totalW, totalH); //thread header bg highlight for(int i = 0; i < headerLocations.size(); i++){ int loc = headerLocations[i]; //whole section ofSetColor(drawLines[loc].color, 40); int h = charH * ((i < headerLocations.size() - 1) ? headerLocations[i+1] - headerLocations[i] : drawLines.size() - loc ); ofRect(x, y + 2 + loc * charH, totalW, h); //thread header ofSetColor(drawLines[loc].color, 40); ofRect(x, y + 2 + loc * charH, totalW, charH + 1); } ofSetColor(hilightColor); ofRect(x, y + 1, totalW, barH); ofRect(x, y + totalH - charH - 4 , totalW, barH); ofRect(x, y + totalH, totalW - barH, barH); for(int i = 0; i < drawLines.size(); i++){ ofSetColor(drawLines[i].color); drawString(drawLines[i].fullLine, x , y + (i + 1) * charH); } //print bottom line, fps and stuff bool missingFrames = ( ofGetFrameRate() < desiredFrameRate - 1.0 ); // tolerance of 1 fps TODO! static char msg[128]; sprintf(msg, "%2.1f fps % 5.1f%%", ofGetFrameRate(), percentTotal ); if(missingFrames){ ofSetColor(170,33,33); }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 ); ofSetColor(hilightColor); drawString( " '" + ofToString(char(activateKey)) + "'" + string(timeAveragePercent < 1.0 ? " avgd!" : ""), x, y + lastLine ); for(int i = 0; i < toResetUpdatedLastFrameFlag.size(); i++){ toResetUpdatedLastFrameFlag[i]->updatedLastFrame = false; } ofPopMatrix(); ofPopStyle(); }
//------------------------------------------------------------------ void rectangle::draw() { ofFill(); ofSetRectMode(OF_RECTMODE_CENTER); // center around the position ofSetColor(198,246,55); ofRect(pos.x, pos.y, 20,20); }
void ofxMPD24::drawInterface(int x, int y){ int numCols = 4; int numRows = 4; int padWidth = 50; int padHeight = 50; ofPushStyle(); //Draw Pads Area 1----------------------- ofPushMatrix(); ofTranslate(x,y); int countpos = 1; for(int k = 4; k>0;k--){ //start in bottom left for(int j = 0; j<4;j++){ ofPushMatrix(); ofTranslate((j*55)+50, (k*55)); ofSetRectMode(OF_RECTMODE_CORNER); ofSetColor(0, 0, 0); ofNoFill(); ofRect(0,0,padWidth, padHeight); float xScale, yScale, pressureScale; pressureScale = ofMap(afterTouchVals[(countpos)], 0, 127, 0, padWidth); ofSetRectMode(OF_RECTMODE_CENTER); ofSetColor(100, 100, 255); ofFill(); ofRect(padWidth/2,(padWidth/2),pressureScale, pressureScale); //name of pad ofSetColor(0); ofDrawBitmapString(ofToString(countpos), 20,20); ofPopMatrix(); countpos++; } } ofPopMatrix(); // Draw pads area 2 ofPushMatrix(); ofTranslate(x+55*4+50+5, y); int countpos2 = 17; for(int k = 4; k>0;k--){ //start in bottom left for(int j = 0; j<4;j++){ ofPushMatrix(); ofTranslate((j*55)+50, (k*55)); ofSetRectMode(OF_RECTMODE_CORNER); ofSetColor(0, 0, 0); ofNoFill(); ofRect(0,0,padWidth, padHeight); float xScale, yScale, pressureScale; pressureScale = ofMap(afterTouchVals[(countpos2)], 0, 127, 0, padWidth); ofSetRectMode(OF_RECTMODE_CENTER); ofSetColor(100, 100, 255); ofFill(); ofRect(padWidth/2,(padWidth/2),pressureScale, pressureScale); ofSetRectMode(OF_RECTMODE_CORNER); //name of pad ofSetColor(0); ofDrawBitmapString(ofToString(countpos2), 20,20); ofPopMatrix(); countpos2++; } } ofPopMatrix(); //Draw Sliders Buttons---------------------- ofPushMatrix(); ofTranslate(x+50, y); ofDrawBitmapString("Sliders", 0,40); for (int i=0; i<6; i++){ ofPushMatrix(); ofTranslate(i*20,0); ofSetRectMode(OF_RECTMODE_CENTER); int locScale = ofMap(controlVals[mpdSliderLocNum[i]], 127, 0, 0, padHeight); ofNoFill(); ofSetColor(0, 0, 0); ofRect(0,0,10, padHeight); ofFill(); ofSetColor(0, 0, 0); ofRect(0, locScale-padHeight/2, 10, 3); ofPopMatrix(); } ofPopMatrix(); //Draw Knobs---------------------- ofPushMatrix(); ofTranslate(x+50, y+320); ofDrawBitmapString("Knob", 0,40); for (int i=0; i<8; i++){ ofPushMatrix(); ofTranslate(i*20,0); ofSetRectMode(OF_RECTMODE_CENTER); int locScale = ofMap(controlVals[knobNum[i]], 127, 0, 0, padHeight); ofNoFill(); ofSetColor(0, 0, 0); ofRect(0,0,10, padHeight); ofFill(); ofSetColor(0, 0, 0); ofRect(0, locScale-padHeight/2, 10, 3); ofPopMatrix(); } ofPopMatrix(); //Draw Buttons---------------------- //These dont update because they just send 127 continuously and never get a 0 message like a velocity change ofPushMatrix(); ofTranslate(x+240, y+320); ofDrawBitmapString("Buttons", 0,40); for (int i=0; i<5; i++){ ofPushMatrix(); ofTranslate(i*20,0); ofSetRectMode(OF_RECTMODE_CENTER); int locScale = ofMap(controlVals[buttonNum[i]], 127, 0, 0, padHeight); ofNoFill(); ofSetColor(0, 0, 0); ofRect(0,0,10, padHeight); ofFill(); ofSetColor(0, 0, 0); ofRect(0, locScale-padHeight/2, 10, 3); ofPopMatrix(); } for (int i=0; i<oscPaths.size(); i++){ ofDrawBitmapString(oscPaths[i], 20, 100+i*20); } ofPopMatrix(); ofPopStyle(); }
void gpuPictoString::update(){ float w = testApp::getInstance()->getW(); float h = testApp::getInstance()->getH(); if(bNeedUpdateCharPos){ charPosList = calcCharPos(); bNeedUpdateCharPos = false; } int total = gpuPicto::totalPicto; int totalPix = textureRes*textureRes; // manual mipmap // *** should check icon size resizeIcon(h); int iconSize = prm.iconSize * h; iconSize*=0.5; if(iconSize<1){ iconSize=1; } // // nomad // bool bNomad = true; if(bNomad){ if(total>0 && ofRandom(1.0)>0.95){ if(gpchars.size()>2){ int charIndexA = (int)ofRandom(2, gpchars.size()-2); int charIndexB = charIndexA + (int)ofRandom(-2, 2); if(charIndexA!=charIndexB){ int numPictoA = gpchars[charIndexA]->numPicto; int numPictoB = gpchars[charIndexB]->numPicto; int firstIdA = gpchars[charIndexA]->firstIndex; int firstIdB = gpchars[charIndexB]->firstIndex; int indexA = ofRandom(firstIdA, numPictoA-1); int indexB = ofRandom(firstIdB, numPictoB-1); float attractOnA = springPrmData[indexA*4+3]; float attractOnB = springPrmData[indexB*4+3]; if(attractOnA<0 && attractOnB<0){ float Ax = finalTargetPosData[indexA*3 + 0]; float Ay = finalTargetPosData[indexA*3 + 1]; finalTargetPosData[indexA*3 + 0] = finalTargetPosData[indexB*3 + 0]; finalTargetPosData[indexA*3 + 1] = finalTargetPosData[indexB*3 + 1]; finalTargetPosData[indexB*3 + 0] = Ax; finalTargetPosData[indexB*3 + 1] = Ay; finalTargetTex.loadData(finalTargetPosData, textureRes, textureRes, GL_RGB); } } } } } { // offset = attractor::getPos(); const ofVec2f& attr = attractor::getPos(); float K = 20; float maxSpeed = 0.05; ofVec2f dir = attr - offset; ofVec2f acc = K * 0.000167 * dir; offsetVel += acc; offsetVel.limit(maxSpeed); offset += offsetVel; ofVec2f dirf = attr - offset; if(dirf.length() > 0.1){ offset += dirf - dirf.normalized() * 0.1; } } // // check pictoChar // bool shouldUpdateSpringTexture = false; GPICTO_STR_ITR itr = gpchars.begin(); int particleMax = textureRes*textureRes; for(; itr!=gpchars.end(); itr++){ if((*itr)->update()){ shouldUpdateSpringTexture = true; int index = (*itr)->firstIndex; int numPicto = (*itr)->numPicto; if(index<=particleMax){ for(int i=0; i<numPicto; i++){ springPrmData[index*4 + 3] = -1; // attractOn index++; if(index>particleMax){ index = 0; } } } } } if(clearCheck()){ clearAll(); bNeedUpdateCharPos = true; } if(testApp::gprm.bAutoPlay) shouldStartNextCheck(); if(shouldUpdateSpringTexture){ springPrmTex.loadData(springPrmData, textureRes, textureRes, GL_RGBA); } // // make random tex // // if(ofGetFrameNum()%3 == 0){ for(int index=0; index<total; index++){ randomData[index*3 + 0] = ofRandom(1.0); randomData[index*3 + 1] = ofRandom(1.0); randomData[index*3 + 2] = ofRandom(1.0); // randomData[index*4 + 3] = ofRandom(1.0); } randomTex.loadData(randomData, textureRes, textureRes, GL_RGB); // } // // 1. calc vel // velPingPong.dst->begin();{ ofClear(0); updateVel.begin();{ updateVel.setUniformTexture("backbuffer", velPingPong.src->getTextureReference(), 0); updateVel.setUniformTexture("posData", posPingPong.src->getTextureReference(), 1); updateVel.setUniformTexture("springData", springPrmTex, 2); updateVel.setUniformTexture("randomData", randomTex, 3); updateVel.setUniformTexture("targetData", finalTargetTex, 4); updateVel.setUniform1i("resolution", (int)textureRes); updateVel.setUniform2f("screen", (float)width, (float)height); updateVel.setUniform2f("offset", (float)offset.x, (float)offset.y); updateVel.setUniform2f("pastOffset", (float)pastOffset.x, (float)pastOffset.y); updateVel.setUniform1f("timestep", (float)timeStep); updateVel.setUniform1f("ACCEL",(float) prm.accel ); updateVel.setUniform1f("SPEED",(float) prm.speed); updateVel.setUniform1f("VIBRATION",(float) prm.vibration ); // draw the source velocity texture to be updated velPingPong.src->draw(0, 0); }updateVel.end(); }velPingPong.dst->end(); velPingPong.swap(); // // 2. calc pos // posPingPong.dst->begin();{ ofClear(0); updatePos.begin();{ updatePos.setUniformTexture("prevPosData", posPingPong.src->getTextureReference(), 0); // Previus position updatePos.setUniformTexture("velData", velPingPong.src->getTextureReference(), 1); // Velocity updatePos.setUniformTexture("springData", springPrmTex, 2); updatePos.setUniform1f("timestep",(float) timeStep ); // updatePos.setUniform2f("offset", (float)offset.x, (float)offset.y); // updatePos.setUniform2f("pastOffset", (float)pastOffset.x, (float)pastOffset.y); posPingPong.src->draw(0, 0); }updatePos.end(); }posPingPong.dst->end(); posPingPong.swap(); // // 3. render // renderFBO.begin();{ ofClear(testApp::getBackgroundColor()); // ofClear(0); //ofClear(0, 0, 0, 0); updateRender.begin();{ updateRender.setUniformTexture("posTex", posPingPong.dst->getTextureReference(), 0); updateRender.setUniformTexture("sparkTex", img->getTextureReference() , 1); updateRender.setUniformTexture("iconPrmTex", iconPrmTex, 2); updateRender.setUniformTexture("springData", springPrmTex, 3); updateRender.setUniform1i("resolution", (float)textureRes); updateRender.setUniform2f("screen", (float)testApp::getInstance()->getW(), (float)testApp::getInstance()->getH()); updateRender.setUniform1i("size", (int)iconSize); updateRender.setUniform1f("imgWidth", imgSize); updateRender.setUniform1f("imgHeight", imgSize); // updateRender.setUniform2f("offset", (float)offset.x, (float)offset.y); ofPushStyle(); //ofEnableBlendMode( OF_BLENDMODE_ADD ); ofEnableBlendMode( OF_BLENDMODE_ALPHA); ofEnableAlphaBlending(); ofEnableSmoothing(); ofSetColor(255); ofFill(); glBegin( GL_POINTS );{ int count = 0; for(int y = 0; y < textureRes; y++){ for(int x = 0; x < textureRes; x++){ if(count >= total) break; count++; glVertex2d(x,y); glTexCoord2i(x, y); } if(count >= total) break; } }glEnd(); ofPopStyle(); }updateRender.end(); if(testApp::getDebugDraw()){ { // Attractor const ofVec2f& attr = attractor::getPos(); ofFill(); ofSetColor(255, 55, 0); ofRect(attr.x*w, attr.y*h, 10, 10); ofFill(); ofSetColor(5, 255, 0); ofRect(pastOffset.x*w, pastOffset.y*h, 10, 10); ofFill(); ofSetColor(0, 5, 220); ofRect(offset.x*w, offset.y*h, 10, 10); } { // + line if(testApp::gprm.bWallMapMouseAdjust){ ofSetColor(0, 255, 0); }else{ ofSetColor(255, 0, 0); } glBegin(GL_LINES); glVertex3f(w/2, 0, 0); glVertex3f(w/2, h, 0); glVertex3f(0, h/2, 0); glVertex3f(w, h/2, 0); glVertex3f(1, 1, 0); glVertex3f(w-1, 1, 0); glVertex3f(1, h-1, 0); glVertex3f(w-1, h-1, 0); glVertex3f(1, 1, 0); glVertex3f(1, h-1, 0); glVertex3f(w-1, 1, 0); glVertex3f(w-1, h-1, 0); glVertex3f(1, 1, 0); glVertex3f(w-1, h-1, 0); glVertex3f(w-1, 1, 0); glVertex3f(1, h-1, 0); glEnd(); } } if(testApp::gprm.bShowInfo){ ofPushMatrix();{ ofTranslate(0,0); ofSetColor(ofColor(255,255,255)-testApp::gprm.bg); ofFill(); ofRect(0, 0, w, 30); ofSetColor(testApp::gprm.bg); int y = 23; ofDrawBitmapString("fps: " + ofToString(ofGetFrameRate()),20,y); ofDrawBitmapString("picto num: " + ofToString(gpuPicto::totalPicto), 200, y); ofDrawBitmapString("Frame num: " + ofToString(ofGetFrameNum()), 400, y); }ofPopMatrix(); } }renderFBO.end(); pastOffset = offset; }
//-------------------------------------------------------------- void testApp::draw(){ // MARK: DRAW KINECT POINT CLOUD // int inc = 20; // for (int i = 0; i < kinect.pointCloud.size(); i+=inc) { // // float z = (kinect.pointCloud[i].z < 0.001) ? 1 : kinect.pointCloud[i].z; // // float prox = (1.0 - z); // float sz = pow(prox, 3) * inc; // ofCircle(kinect.pointCloud[i].x * (float)ofGetWidth(), kinect.pointCloud[i].y * (float)ofGetHeight(), sz); // // int limit_w = kinect.getOutputWidth(); // if(i % limit_w == 0) { // i += inc * limit_w; // } // } // MARK: DRAW BOX2D PARTICLES TO FBO fbo.begin(); ofClear(0, 0, 0, 255); if(isFilterActive) { shader.begin(); shader.setUniform1i("u_ratio", ledRatio); } for(int i = 0; i < b2dParticles.size(); i++) { CustomParticle p = b2dParticles[i]; Data * customData = (Data*)p.getData(); if(kinect.pointCloud.size() > 0) { // int relativeX = ofMap(p.getPosition().x, 0, FBO_W, 0, kinect.getOutputWidth()); int relativeX = ofMap(p.getPosition().x, 0, FBO_W, 0, OUTPUT_SCREEN_W); relativeX = ofMap(relativeX, 0, OUTPUT_SCREEN_W, 0, kinect.getOutputWidth()); int relativeY = ofMap(p.getPosition().y, 0, FBO_H, 0, kinect.getOutputHeight()); int relativeKinectIndex = relativeX + (kinect.getOutputWidth() * relativeY); if(relativeKinectIndex < kinect.pointCloud.size()) { ofPoint kinectPoint = kinect.pointCloud[relativeKinectIndex]; float z = (kinectPoint.z < 0.001) ? 1 : kinectPoint.z; float prox = 1.2 - z; float sz = 0; switch(customData->scope) { case PERSONAL: sz += personalMinParticleSize; break; case NEIGHBORHOOD: sz += neighborhoodMinParticleSize; break; case CITY: sz += cityMinParticleSize; break; } sz += prox * 80.0; float r = p.getRadius(); // property = (target - property) / speed r += (sz - r) / 4.0f; p.setRadius(r); } } p.draw(); } if(isDebugingBox2d) { ofEnableAlphaBlending(); // DRAW JOINTS for(int j = 0; j < b2dJoints.size(); j++) { ofSetColor(255, 70); b2dJoints[j].draw(); } // DRAW ANCHORS ofSetColor(70); ofCircle(personalAnchorBottom.getPosition(), 4); ofCircle(personalAnchorTop.getPosition(), 4); ofCircle(personalAnchorLeft.getPosition(), 4); ofCircle(personalAnchorRight.getPosition(), 4); ofCircle(neighborhoodAnchorBottom.getPosition(), 4); ofCircle(neighborhoodAnchorTop.getPosition(), 4); ofCircle(neighborhoodAnchorLeft.getPosition(), 4); ofCircle(neighborhoodAnchorRight.getPosition(), 4); ofCircle(cityAnchorBottom.getPosition(), 4); ofCircle(cityAnchorTop.getPosition(), 4); ofCircle(cityAnchorLeft.getPosition(), 4); ofCircle(cityAnchorRight.getPosition(), 4); } if(isFilterActive) { shader.end(); } fbo.end(); ofSetColor(255); fbo.draw(0,0); // -------------------------------------------- // CHEAT: PILLARS MASK ofSetColor(25, 255); ofFill(); ofRect(OUTPUT_SCREEN_W/3.0, 0, (FBO_W-OUTPUT_SCREEN_W)/2.0, FBO_H); ofRect(FBO_W - (OUTPUT_SCREEN_W/3.0) - (FBO_W-OUTPUT_SCREEN_W)/2.0, 0, (FBO_W-OUTPUT_SCREEN_W)/2.0, FBO_H); // -------------------------------------------- if(isGUIActive) { drawGUI(); } }
void ofApp::boxE(){ float _sizeRatio = 0.7; ofPushStyle(); ofNoFill(); ofSetColor( 120, 255 ); ofPushMatrix(); ofRect(0, 0, platePointSpacing*_sizeRatio, platePointSpacing*_sizeRatio); ofRotateX(90); ofRect(0, 0, platePointSpacing*_sizeRatio, platePointSpacing*_sizeRatio); ofRotateX(90); ofTranslate( 0, -platePointSpacing*_sizeRatio, -platePointSpacing*_sizeRatio); ofRect(0, 0, platePointSpacing*_sizeRatio, platePointSpacing*_sizeRatio); ofRotateX(90); ofRect(0, 0, platePointSpacing*_sizeRatio, platePointSpacing*_sizeRatio); ofPopMatrix(); ofPushMatrix(); ofRotateY(270); ofRect(0, 0, platePointSpacing*_sizeRatio, platePointSpacing*_sizeRatio); ofPopMatrix(); ofPushMatrix(); ofRotateY(270); ofTranslate( 0, 0, -platePointSpacing*_sizeRatio ); ofRect(0, 0, platePointSpacing*_sizeRatio, platePointSpacing*_sizeRatio); ofPopMatrix(); ofPopStyle(); ofPushStyle(); ofFill(); ofSetColor( 250, 255 ); ofPushMatrix(); ofRect(0, 0, platePointSpacing*_sizeRatio, platePointSpacing*_sizeRatio); ofRotateX(90); ofRect(0, 0, platePointSpacing*_sizeRatio, platePointSpacing*_sizeRatio); ofRotateX(90); ofTranslate( 0, -platePointSpacing*_sizeRatio, -platePointSpacing*_sizeRatio); ofRect(0, 0, platePointSpacing*_sizeRatio, platePointSpacing*_sizeRatio); ofRotateX(90); ofRect(0, 0, platePointSpacing*_sizeRatio, platePointSpacing*_sizeRatio); ofPopMatrix(); ofPushMatrix(); ofRotateY(270); ofRect(0, 0, platePointSpacing*_sizeRatio, platePointSpacing*_sizeRatio); ofPopMatrix(); ofPushMatrix(); ofRotateY(270); ofTranslate( 0, 0, -platePointSpacing*_sizeRatio ); ofRect(0, 0, platePointSpacing*_sizeRatio, platePointSpacing*_sizeRatio); ofPopMatrix(); ofPopStyle(); }
//-------------------------------------------------------------- void testApp::draw(){ if (bPrintToPdf){ ofBackground(255); ofBeginSaveScreenAsPDF("screenshot-"+ofGetTimestampString()+".pdf", false); } else { ofBackground(11,94,148); ofBackgroundGradient(ofColor(11,94,148), ofColor(0,45,128,100)); float margin = 10; ofRectangle grid = ofRectangle(margin,margin,ofGetWidth()-margin*2.0,ofGetHeight()-margin*2.0); ofPushStyle(); ofSetColor(200,20); ofSetLineWidth(2); ofNoFill(); ofRect(grid); ofSetLineWidth(0.3); drawGrid(grid, 10); ofPopStyle(); } // Potentialy New Gear // if( bValid && !bPrintToPdf) { ofSetColor(255,0,0); picked->update(); picked->draw(); } // Draw Disk // if (bPrintToPdf){ ofSetColor(0,100); } else { ofSetColor(255,100); } ofFill(); ofBeginShape(); for (int i = 0; i < disk.size(); i++) { ofVertex(disk[i]); } ofEndShape(); if (onA) ofFill(); else ofNoFill(); ofCircle(A, 10); if (onB) ofFill(); else ofNoFill(); ofCircle(B, 10); ofNoFill(); ofDrawBitmapString("A", A.x-3,A.y+4); ofDrawBitmapString("B", B.x-3,B.y+4); ofRect(window); // Draw Gears // for (int i = 0; i < gears.size(); i++) { gears[i]->bPrint = bPrintToPdf; gears[i]->bSelected = (hoverGear == i); ofSetColor(255); gears[i]->update(); gears[i]->draw(); } if (bPrintToPdf){ ofEndSaveScreenAsPDF(); bPrintToPdf = false; } }
//-----------------------------------------------. void guiTypeTextDropDown::render(){ ofPushStyle(); guiBaseObject::renderText(); //draw the background ofFill(); glColor4fv(bgColor.getNormalColorF()); ofRect(hitArea.x, hitArea.y, hitArea.width, hitArea.height); if(bShowDropDown) { for(int i = 0; i < (int) vecDropList.size(); i++) { float bx = hitArea.x; float by = hitArea.y + i * (boxHeight); if(value.getValueI() == i){ glColor4fv(fgColor.getSelectedColorF()); }else{ glColor4fv(fgColor.getNormalColorF()); } ofFill(); ofRect(bx, by, boundingBox.width, boxHeight); ofNoFill(); glColor4fv(outlineColor.getColorF()); ofRect(bx, by, boundingBox.width, boxHeight); if(i==0) { ofFill(); glColor4fv(outlineColor.getColorF()); ofRect(bx + boundingBox.width - boxHeight*0.5, by, boxHeight*0.5, boxHeight*0.5); } glColor4fv(textColor.getColorF()); displayText.renderString(vecDropList[i], bx + 2, by + boxHeight -4); } } else { float bx = hitArea.x; float by = hitArea.y; ofFill(); glColor4fv(bgColor.getColorF()); ofRect(bx, by, boundingBox.width, boxHeight); ofNoFill(); glColor4fv(outlineColor.getColorF()); ofRect(bx, by, boundingBox.width, boxHeight); ofFill(); glColor4fv(outlineColor.getColorF()); //ofTriangle(bx + boundingBox.width - 7, by + boxHeight, bx + boundingBox.width - 14, by,bx + boundingBox.width, by); ofRect(bx + boundingBox.width - boxHeight*0.5, by, boxHeight*0.5, boxHeight*0.5); glColor4fv(textColor.getColorF()); //displayText.renderString(vecDropList[value.getValueI()], bx + 2, by + boxHeight -4); } ofPopStyle(); }
//-------------------------------------------------------------- void testApp::draw() { ofBackground(0, 0, 0); ofSetColor(0, 0, 0); ofRect(0,0,1400,1400); for(int i = 0; i < dropletNumber; i++) { droplets[i].draw(); } //test.draw(); if(! generatedObjects.empty() ) { for(int i = 0; i < generatedObjects.size(); i++) { generatedObjects[i].draw(); } } for(int i =0; i < obstacleNumber; i++) { //lineNumber[i].draw(); } if(showCameraStuff) { // draw the incoming, the grayscale, the bg and the thresholded difference //ofSetColor(0xffffff); colorImg.draw(20,20); grayImage.draw(360,20); grayBg.draw(20,280); grayDiff.draw(360,280); ofSetColor(255, 255, 255); ofLine(0, 432, 2000, 432); ofSetColor(255, 0, 0); ofLine(370, 0, 370, 1000); ofLine(570, 0, 570, 1000); // then draw the contours: ofFill(); ofSetColor(0x333333); ofRect(360,540,320,240); ofSetColor(0xffffff); // we could draw the whole contour finder //contourFinder.draw(360,540); // or, instead we can draw each blob individually, // this is how to get access to them: for (int i = 0; i < contourFinder.nBlobs; i++) { contourFinder.blobs[i].draw(360,540); } // finally, a report: ofSetColor(0xffffff); char reportStr[1024]; sprintf(reportStr, "bg subtraction and blob detection\npress ' ' to capture bg\nthreshold %i (press: +/-)\nnum blobs found %i", threshold, contourFinder.nBlobs); ofDrawBitmapString(reportStr, 20, 600); } ofSetColor(0, 0, 0); ofFill(); ofRect(950, 0, 1000,1000); ofFill(); }
void testApp::draw(){ ofSetColor(255, 255, 255); // draw the debug screens ofPushMatrix(); ofScale(0.5, 0.5); if (isLive) { recordDepth.draw(0, 0, 640, 480); recordImage.draw(640, 0, 640, 480); if (panel.getValueB("isTracking")) { recordUser.draw(); if(panel.getValueB("isMasking")) { glEnable(GL_BLEND); glBlendFunc(GL_DST_COLOR, GL_ZERO); recordUser.drawUserMasks(640, 0); glDisable(GL_BLEND); } } } else { playDepth.draw(0, 0, 640, 480); playImage.draw(640, 0, 640, 480); if (panel.getValueB("isTracking")) { playUser.draw(); if(panel.getValueB("isMasking")) { glEnable(GL_BLEND); glBlendFunc(GL_DST_COLOR, GL_ZERO); playUser.drawUserMasks(640, 0); glDisable(GL_BLEND); } } } // draw rectangles to ground the debug screens ofNoFill(); ofRect(0, 0, 640, 480); ofRect(640, 0, 640, 480); ofFill(); ofPopMatrix(); // draw the point cloud //glMatrixMode(GL_MODELVIEW); // glPushMatrix(); // glTranslatef(320, 240, 0); // glRotatef(panel.getValueF("cloud_rotation"), 0, 1, 0); // glTranslatef(-320, -240, 0); ofPushMatrix(); ofTranslate(ofGetWidth() / 2, ofGetHeight() / 2, -300); ofRotateY(panel.getValueF("cloud_rotation")); ofTranslate(-320, -240, 0); // if (panel->getValueB("autoRotate")){ // ofRotateY(ofGetElapsedTimef()*5); // } //glCallList(SCENE); /* draw the scene */ if (isLive) { //recordUser.drawPointCloud(!panel.getValueB("cloudMasking"), panel.getValueI("cloud_point_size")); recordUser.drawOrthogonalPointCloud(panel.getValueF("ppm"), false, panel.getValueB("show_scene_box"), panel.getValueI("cloud_point_size")); recordUser.drawOrthogonal(panel.getValueF("ppm")); } else { //playUser.drawPointCloud(!panel.getValueB("cloudMasking"), panel.getValueI("cloud_point_size")); } ofPopMatrix(); ofSetColor(255, 255, 0); string msg1, msg2, msg3; //drawBitmapString is limited to some numebr of characters -> is this a bug in 007 or always the case? msg1 += "Press 's' to start/stop recording\n"; msg1 += "Press 'p' to toggle playback/live streams\n"; msg3 += (string)(isLive ? "LIVE STREAM\n" : "PLAY STREAM\n"); msg3 += (string)(!isRecording ? "READY\n" : "RECORDING\n"); ofDrawBitmapString(msg1, 20, 500); ofDrawBitmapString(msg3, 20, 600); ofDrawBitmapString(currentFileName, 20, 700); }
//-------------------------------------------------------------- void testApp::draw(){ // set my color ofSetColor(255, 0, 0); // b ofRect(10, 10, 50, 200); ofRect(50, 110, 50, 100); // r ofRect(110, 110, 50, 100); ofRect(150, 110, 50, 25); // i ofRect(210, 110, 50, 25); ofRect(210, 140, 50, 70); // a ofRect(270, 110, 75, 25); ofRect(295, 130, 50, 80); ofRect(270, 160, 50, 50); // n ofRect(355, 110, 75, 25); ofRect(355, 130, 25, 80); ofRect(405, 130, 25, 80); }
void ofxGuiMatrix::draw() { glPushMatrix(); glTranslatef(mObjX, mObjY, 0.0f); if(mParamName != "") drawParamString(0.0, 0.0, mParamName + ": " + ofToString(mValue), false); ofFill(); // background glColor4f(mGlobals->mCoverColor.r, mGlobals->mCoverColor.g, mGlobals->mCoverColor.b, mGlobals->mCoverColor.a); ofRect(mCtrX, mCtrY, mCtrWidth, mCtrHeight); ofNoFill(); // pads glColor4f(mGlobals->mFrameColor.r, mGlobals->mFrameColor.g, mGlobals->mFrameColor.b, mGlobals->mFrameColor.a); int s = mSpacing / 2; float x = mCtrX + s; float y = mCtrY + s; float w = (mCtrWidth - mSpacing) / mXGrid; float h = (mCtrHeight - mSpacing) / mYGrid; for(int i = 0; i < mYGrid; i++) { for(int j = 0; j < mXGrid; j++) { int index = j + (i * mXGrid); if((mBuffer[index] & kofxGui_Matrix_Set) == kofxGui_Matrix_Set) { ofFill(); glColor4f(mGlobals->mButtonColor.r, mGlobals->mButtonColor.g, mGlobals->mButtonColor.b, mGlobals->mButtonColor.a); ofRect(x + s, y + s, w - mSpacing, h - mSpacing); } if((mBuffer[index] & kofxGui_Matrix_Selected) == kofxGui_Matrix_Selected) { ofNoFill(); glColor4f(mGlobals->mMatrixColor.r, mGlobals->mMatrixColor.g, mGlobals->mMatrixColor.b, mGlobals->mMatrixColor.a); ofRect(x + s, y + s, w - mSpacing, h - mSpacing); } else if(mValue == index) { ofNoFill(); glColor4f(mGlobals->mAxisColor.r, mGlobals->mAxisColor.g, mGlobals->mAxisColor.b, mGlobals->mAxisColor.a); ofRect(x + s, y + s, w - mSpacing, h - mSpacing); } else { ofNoFill(); glColor4f(mGlobals->mFrameColor.r, mGlobals->mFrameColor.g, mGlobals->mFrameColor.b, mGlobals->mFrameColor.a); ofRect(x + s, y + s, w - mSpacing, h - mSpacing); } x += w; } y += h; x = mCtrX + s; } // frame glColor4f(mGlobals->mFrameColor.r, mGlobals->mFrameColor.g, mGlobals->mFrameColor.b, mGlobals->mFrameColor.a); ofRect(mCtrX, mCtrY, mCtrWidth, mCtrHeight); glPopMatrix(); }
void ofxTLSwitches::draw(){ ofPushStyle(); ofFill(); //draw a little wobble if its on //if(isOnAtMillis(timeline->getCurrentTimeMillis())){ //play solo change if(isOn()){ ofSetColor(timeline->getColors().disabledColor, 20+(1-powf(sin(ofGetElapsedTimef()*5)*.5+.5,2))*20); ofRect(bounds); } for(int i = 0; i < keyframes.size(); i++){ ofxTLSwitch* switchKey = (ofxTLSwitch*)keyframes[i]; float startScreenX = MAX(millisToScreenX(switchKey->timeRange.min), 0); float endScreenX = MIN(millisToScreenX(switchKey->timeRange.max), bounds.getMaxX()); if(startScreenX == endScreenX){ continue; } switchKey->display = ofRectangle(startScreenX, bounds.y, endScreenX-startScreenX, bounds.height); //draw handles ofSetLineWidth(2); bool keyIsSelected = isKeyframeSelected(switchKey); if(keyIsSelected || switchKey->startSelected){ ofSetColor(timeline->getColors().textColor); } else{ ofSetColor(timeline->getColors().keyColor); } ofLine(switchKey->display.x, bounds.y, switchKey->display.x, bounds.y+bounds.height); if(keyIsSelected || switchKey->endSelected){ ofSetColor(timeline->getColors().textColor); } else{ ofSetColor(timeline->getColors().keyColor); } ofLine(switchKey->display.x+switchKey->display.width, bounds.y, switchKey->display.x+switchKey->display.width, bounds.y+bounds.height); //draw region if(keyIsSelected){ ofSetColor(timeline->getColors().textColor, 100); } else{ ofSetColor(timeline->getColors().keyColor, 100); } //set overlay colors, this will override the colors above if(hoverKeyframe == switchKey){ if(startHover){ ofPushStyle(); if(switchKey->startSelected){ ofSetColor(timeline->getColors().highlightColor); } else{ ofSetColor(timeline->getColors().keyColor); } ofRect(switchKey->display.x-2, bounds.y, 4, bounds.height); ofPopStyle(); } else if(endHover){ ofPushStyle(); if(switchKey->endSelected){ ofSetColor(timeline->getColors().highlightColor); } else{ ofSetColor(timeline->getColors().keyColor); } ofRect(switchKey->display.x+switchKey->display.width-2, bounds.y, 4.0, bounds.height); ofPopStyle(); } else { if(keyIsSelected){ ofSetColor(timeline->getColors().highlightColor); }else { ofSetColor(timeline->getColors().keyColor); } } } ofRect(switchKey->display); } ofPopStyle(); }