//-------------------------------------------------------------- void testApp::draw(){ ofSetColor(255, 255, 255); ofPushMatrix(); // draw debug (ie., image, depth, skeleton) openNIDevice.drawDebug(); ofPopMatrix(); ofPushMatrix(); // use a blend mode so we can see 'through' the mask(s) ofEnableBlendMode(OF_BLENDMODE_ALPHA); // get number of current users int numUsers = openNIDevice.getNumTrackedUsers(); // iterate through users for (int i = 0; i < numUsers; i++){ // get a reference to this user ofxOpenNIUser & user = openNIDevice.getTrackedUser(i); // draw the mask texture for this user user.drawMask(); // get joint position head = user.getJoint(JOINT_HEAD).getProjectivePosition(); leftHand = user.getJoint(JOINT_LEFT_HAND).getProjectivePosition(); rightHand = user.getJoint(JOINT_RIGHT_HAND).getProjectivePosition(); leftFoot = user.getJoint(JOINT_LEFT_FOOT).getProjectivePosition(); rightFoot = user.getJoint(JOINT_RIGHT_FOOT).getProjectivePosition(); torso = user.getJoint(JOINT_TORSO).getProjectivePosition(); // OSC stuff m.setAddress("/nodes"); m.addIntArg(head.x); m.addIntArg(head.y); m.addIntArg(leftHand.x); m.addIntArg(leftHand.y); m.addIntArg(rightHand.x); m.addIntArg(rightHand.y); m.addIntArg(leftFoot.x); m.addIntArg(leftFoot.y); m.addIntArg(rightFoot.x); m.addIntArg(rightFoot.y); sender.sendMessage(m); // array_head.push_back(head); // array_leftFoot.push_back(leftFoot); // array_leftHand.push_back(leftHand); // array_rightFoot.push_back(rightFoot); // array_rightHand.push_back(rightHand); // array_torso.push_back(torso); // // if(array_head.size() > array_size) { // array_head.erase(array_head.begin()); // } // // if(array_leftHand.size() > array_size) { // array_leftHand.erase(array_leftHand.begin()); // } // // if(array_leftFoot.size() > array_size) { // array_leftFoot.erase(array_leftFoot.begin()); // } // // if(array_rightFoot.size() > array_size) { // array_rightFoot.erase(array_rightFoot.begin()); // } // // if(array_rightHand.size() > array_size) { // array_rightHand.erase(array_rightHand.begin()); // } // if(array_torso.size() > array_size) { // array_torso.erase(array_torso.begin()); // } // you can also access the pixel and texture references individually: // TEXTURE REFERENCE //ofTexture & tex = user.getMaskTextureReference(); // do something with texture... // PIXEL REFERENCE //ofPixels & pix = user.getMaskPixels(); // do something with the pixels... // and point clouds: ofPushMatrix(); // move it a bit more central ofTranslate(320, 240, 10); user.drawPointCloud(); // you can also access the mesh: // MESH REFERENCE //ofMesh & mesh = user.getPointCloud(); // do something with the point cloud mesh ofPopMatrix(); } ofDisableBlendMode(); ofPopMatrix(); // draw some info regarding frame counts etc // ofSetColor(0, 255, 0); // string msg = " MILLIS: " + ofToString(ofGetElapsedTimeMillis()) + " FPS: " + ofToString(ofGetFrameRate()) + " Device FPS: " + ofToString(openNIDevice.getFrameRate()); // // verdana.drawString(msg, 20, openNIDevice.getNumDevices() * 480 - 20); //ofSetColor(leftHand.y,torso.x/10,rightHand.y*20); // draw the ploy circle(sh) // ofBeginShape(); // // for (int i = 0; i <6; i++){ // // if (i == 0){ // ofCurveVertex(leftFoot.x,leftFoot.y); // we need to duplicate 0 for the curve to start at point 0 // ofCurveVertex(leftHand.x,leftHand.y); // we need to duplicate 0 for the curve to start at point 0 // } else if (i == 5){ // ofCurveVertex(head.x,head.y); // ofCurveVertex(torso.x, torso.y); // to draw a curve from pt 6 to pt 0 // ofCurveVertex(rightHand.x,rightHand.y); // we duplicate the first point twice // }else { // ofCurveVertex(rightFoot.x,rightHand.y); // } // // } // // ofEndShape(); //SH group adding parts~ ofSetColor(leftHand.y,torso.x,rightHand.y*2); //ofSetColor(255, 255, 255); //ofRect(0, 0,1000, 1000); bg.draw(-200, 0); ofSetColor(255,255,255); ofSetLineWidth(3); ofLine(leftHand.x+10, leftHand.y+10, head.x+10, head.y+10); ofLine(head.x+20, head.y+10, rightHand.x+10, rightHand.y+15); ofLine(rightHand.x+8, rightHand.y+10, rightFoot.x+20, rightFoot.y+10); ofLine(rightFoot.x, rightFoot.y, leftFoot.x, leftFoot.y); ofLine(leftFoot.x,leftFoot.y, leftHand.x, leftHand.y); ofSetColor(255,255,255); ofCircle(leftHand.x+20, leftHand.y+20,10); ofCircle(rightHand.x+10, rightHand.y+10,6); ofSetColor(leftHand.y,torso.x/10,rightHand.y*20); ofSetPolyMode(OF_POLY_WINDING_NONZERO); ofBeginShape(); ofVertex(leftFoot.x,leftFoot.y); ofVertex(leftHand.x,leftHand.y); ofVertex(head.x,head.y); ofVertex(rightHand.x,rightHand.y); ofVertex(rightFoot.x,rightFoot.y); ofEndShape(); // for(int i=0; i<array_head.size();i++) { // if(i > 1) { // ofLine(array_head[i-1].x, array_head[i-1].y, array_head[i].x, array_head[i].y); // } // } // for(int i=0; i<array_leftFoot.size();i++) { // if(i > 1) { // ofLine(array_leftFoot[i-1].x, array_leftFoot[i-1].y, array_leftFoot[i].x, array_leftFoot[i].y); // } // } // for(int i=0; i<array_rightFoot.size();i++) { // if(i > 1) { // ofLine(array_rightFoot[i-1].x, array_rightFoot[i-1].y, array_rightFoot[i].x, array_rightFoot[i].y); // } // } // for(int i=0; i<array_leftHand.size();i++) { // if(i > 1) { // ofLine(array_leftHand[i-1].x, array_leftHand[i-1].y, array_leftHand[i].x, array_leftHand[i].y); // } // } // for(int i=0; i<array_rightHand.size();i++) { // if(i > 1) { // ofLine(array_rightHand[i-1].x, array_rightHand[i-1].y, array_rightHand[i].x, array_rightHand[i].y); // } // } // for(int i=0; i<array_torso.size();i++) { // if(i > 1) { // ofLine(array_torso[i-1].x, array_torso[i-1].y, array_torso[i].x, array_torso[i].y); // } // } //// // for (int i=1;i<60 ; i+=10) { // CX=i+40; // CY=i; // ofCircle(CX, CY, 20); // } // CX=ofRandom(50,400); // CY=ofRandom(0,600); // ofCircle(40 ,80, 20); //ofSetColor(100); ofCircle(100, 100, 20); ofCircle(250, 100, 20); ofCircle(400, 100, 20); a=rightHand.y; b=head.y; c=leftHand.y; if (abs(a-b<10)) { la.play(); } if (abs(c-b<10)) { so.play(); } if (abs(leftHand.x-100)<10&&abs(leftHand.y-100)<10) { Do.play(); } if (abs(leftHand.x-250)<10&&abs(leftHand.y-100)<10) { re.play(); } if (abs(leftHand.x-400)<10&&abs(leftHand.y-100)<10) { Mi.play(); } if (abs(rightHand.x-100)<10&&abs(rightHand.y-100)<10) { Do.play(); } if (abs(rightHand.x-250)<10&&abs(rightHand.y-100)<10) { re.play(); } if (abs(rightHand.x-400)<10&&abs(rightHand.y-100)<10) { Mi.play(); } }
//-------------------------------------------------------------- void Particle::draw(){ ofSetColor(colorR, colorG, colorB); ofCircle(pos.x, pos.y, particleSize); }
void PartiCircle::draw(){ ofSetCircleResolution(size*5); ofSetColor(color); ofCircle(loc, size); }
//-------------------------------------------------------------- void testApp::draw() { if(count++>360) count=0;; ofRectangle drawRect((ofGetWidth()-sqWid)/2,yOffset,sqWid,sqWid); ofSetColor(175,175,175); background.draw(0, 0,width,height); int xint=ofMap(xpos, 0, maxValue.x-minValue.x, (width-sqWid)/2, (width+sqWid)/2,true); int yint=ofMap((maxValue.y-minValue.y)-ypos, 0, maxValue.y-minValue.y, yOffset, yOffset+sqWid,true); ofSetShadowDarkness( .5), ofShadowRounded((width-sqWid)/2-5, yOffset, sqWid+5, sqWid+5, 20); ofSetColor(255, 255, 255); ofRect((width-sqWid)/2-5, yOffset, sqWid+5, sqWid+5); net.draw(); ofSetColor(255, 255, 255); for (int i=0; i<numOctaves+1; i++) { ofPoint k=net.vertex(0, i); char num[32]; sprintf(num, "%i",i); arialLabel.drawString(num, k.x-30, k.y+arialLabel.stringHeight(num)/2); } for (int i=1; i<numOctaves+1; i++) { ofPoint k=net.vertex(i, 0); char num[32]; sprintf(num, "%i",i); arialLabel.drawString(num, k.x-arialLabel.stringWidth(num)/2, k.y+arialLabel.stringHeight(num)+7); } /************************** Reporting data ******************** ofSetColor(0xFFFFFF); char reportString[255]; sprintf(reportString, "nread = %i", nBytesRead); if (!bNoise) sprintf(reportString, "%s (%fhz)", reportString, targetFrequency); ofDrawBitmapString(reportString,80,380); //arialHeader.drawString(reportString,20, height-50); **************************************************************/ overlays(xint,yint); xMet.draw(((width-sqWid)/2-xMet.w)/2,ofGetHeight()/2); yMet.draw((width+sqWid)/2+((ofGetWidth()-(width+sqWid)/2)-yMet.w)/2,ofGetHeight()/2); ofSetLineWidth(6); ofEnableSmoothing(); for (unsigned int i=1; i<lines.size(); i++) { ofSetColor(65, 134, 200,255-i); ofLine(lines[i-1].x, lines[i-1].y, lines[i].x, lines[i].y); } ofDisableSmoothing(); frets((width-sqWid)/2, yOffset, sqWid, numOctaves, xint, yint); ofSetColor(65, 134, 200); ofCircle(xint, yint, 7); lines.push_front(ofPoint(xint,yint)); if (lines.size()>255) { lines.pop_back(); } if (overlayCnt==4) { reducedRatios(xint, yint); } if(newTimer>ofGetElapsedTimeMillis()) { int mW=ofGetWidth(); int mH=ofGetHeight(); string rep=\ "Trace the lines using the sliders.\n\ Press the New Activities button to access\n\ more screens.\n\ \n\ Trazar las lineas con los reguladores.\n\ Pulse el boton de Nuevas Actividades para acceder\n\ a mas pantallas."; ofRectangle s=arialLabel.getBoundingBox(rep, 0, 0); ofSetColor(64, 64,64); ofRoundedRect((mW-(s.width+40))/2, (mH-(s.height+40))/2, s.width+40, 40+s.height, 20); ofSetColor(255, 255, 255); arialLabel.drawString(rep, (mW-s.width)/2, (mH-s.height)/2+20); } if (calib) { ofSetColor(0,0,0,128); ofRect(0,0,ofGetWidth(),ofGetHeight()); ofSetColor(128, 128, 128); ofRoundedRect(150, 100, ofGetWidth()-300, ofGetHeight()-200, 20); char freq[32]; sprintf(freq, "%f",ypos+minValue.y); char reportString[255]; sprintf(reportString, "<-- yslider xslider -->"); int w= arialHeader.stringWidth(reportString); int h= arialHeader.stringHeight(reportString); ofSetColor(255, 255, 255); arialHeader.drawString(reportString,(width-w)/2, ofGetHeight()/4*2); arialHeader.drawString(freq,200, ofGetHeight()/4*2); sprintf(freq, "%f",xpos+minValue.x); arialHeader.drawString(freq,ofGetWidth()-(200+arialHeader.stringWidth(freq)), ofGetHeight()/4*2); sprintf(freq, "%f",ypos); sprintf(reportString, "<-- yoff from calibrated values xoff -->"); w= arialHeader.stringWidth(reportString); h= arialHeader.stringHeight(reportString); ofSetColor(255, 255, 255); arialHeader.drawString(reportString,(width-w)/2, ofGetHeight()/4*3); arialHeader.drawString(freq,200, ofGetHeight()/4*3); sprintf(freq, "%f",xpos); arialHeader.drawString(freq,ofGetWidth()-(200+arialHeader.stringWidth(freq)), ofGetHeight()/4*3); if(maxValue.x<1024&&maxValue.y<1024) { sprintf(reportString, "To re-calibrate, pull back sliders and press 'r'."); w= arialHeader.stringWidth(reportString); h= arialHeader.stringHeight(reportString); ofSetColor(255, 255, 255); arialHeader.drawString(reportString,(width-w)/2, ofGetHeight()/4); } else { sprintf(reportString, "Out of calibration range; tune with screwdriver."); w= arialHeader.stringWidth(reportString); h= arialHeader.stringHeight(reportString); ofSetColor(255, 255, 255); arialHeader.drawString(reportString,(width-w)/2, ofGetHeight()/4); } } }
//-------------------------------------------------------------- void ofApp::draw(){ // ofEnableLighting(); cam.begin(); // mainLight.enable(); // for (int i=0; i<buildingsPolyline_33975_22294.size(); i++) { // buildingsPolyline_33975_22294[i].draw(); // } // ofPushStyle(); // ofSetColor(255, 160); // // for (int i=0; i<buildings_33975_22294.size(); i++) { // vector<ofVec3f> & _v = buildings_33975_22294[i].getVertices(); // for (int j=0; j<_v.size(); j++) { // ofDrawLine( _v[j] - ofVec3f(0, 0, 0), _v[j] + ofVec3f(0, 0, 100) ); // } // } // ofPopStyle(); for (int i=0; i<roadsPolyline_33975_22294.size(); i++) { roadsPolyline_33975_22294[i].draw(); } for (int i=0; i<roadsPolyline_33975_22294.size(); i++) { ofDrawCircle(roadsPolyline_33975_22294[i].getPointAtPercent( roadMoving_33975_22294 ) , 2); } ofPushStyle(); ofSetColor(255, 180); for (int i=0; i<buildingsPolyline_33975_22294.size(); i++) { buildingsPolyline_33975_22294[i].draw(); // ofBeginShape(); // vector<ofVec3f>& vertices = buildingsPolyline_33975_22294[i].getVertices(); // for(int j = 0; j < vertices.size(); j++) { // ofVertex(vertices[j]); // } // ofEndShape(); // // ofBeginShape(); // vector<ofVec3f>& verticesUp = buildingsPolyline_33975_22294[i].getVertices(); // for(int j = 0; j < verticesUp.size(); j++) { // ofVec3f _v = verticesUp[j] + ofVec3f(0, 0, 100); // ofVertex(_v); // } // ofEndShape(); } ofPopStyle(); // mainLight.disable(); cam.end(); // ofDisableLighting(); ofPushMatrix(); ofTranslate( mainOffSetXPos, mainOffSetYPos ); baseArch.guideFrames(); baseArch.drawEdgeCover( ofColor(0) ); baseArch.guideLines(); baseArch.guidePoints(); ofPopMatrix(); ofDrawBitmapString("control : w, s, a, d, r, q, e, c, mouse", 10, 20); }
void Sentence::draw(){ int i = 0; xoff = 0; float x = 0; // If there are no start/stop index do not calculate scale factors if(startShine.size() > 0 ) { p = floor(10*(startShine[0] + stopShine[0]) / 2); r = ofGetWidth() - p; l = p / 10; m = r / 10; float incr = 1 / l; } myFont->beginBatch(); while(x <= ofGetWidth()){ // Calculate a y value according to noise, map to float y = yStart + ofMap(ofNoise(xoff, yoff), 0, 1, 0,400); // Option #1: 2D Noise // Set the vertex //if(x > 0){ line.addVertex(ofVec2f(x,y)); if(i < strLen){ ofVec2f tanVec = ofVec2f(xPrev,yPrev) - ofVec2f(x,y); float yDiff = tanVec.y; float xDiff = tanVec.x; float arcTan = ofRadToDeg(atan(yDiff / xDiff)); ofPushMatrix(); ofTranslate(x,y); ofRotateZ(arcTan); float alphaVal = ofMap(x,0,ofGetWidth(),10,255); // useScaleFac = false; float scaleFac2 = incr; //cout << incr << endl; /* if(!useScaleFac) { ofScale(scaleFac2,scaleFac2,1); } else { ofScale(scaleFac2,scaleFac2,1); } */ //cout << incr << endl; //ofSetColor(255-(alphaVal)); // If start/stop index is lower than 0 do nothing set colors and incr to zero if(startShine.size()>0) { if(x > startShine[0] * 10 && x < stopShine[0] * 10){ // incr = 1; }else{ if(x <= p){ incr += 1/l; }else{ incr -= 1/m; } } if((i >= startShine[0] && i< stopShine[0]) || (i >= startShine[1] && i< stopShine[1])|| (i >= startShine[2] && i< stopShine[2])|| (i >= startShine[3] && i< stopShine[3]) || (i >= startShine[4] && i< stopShine[4]) ){ ofSetColor(0,col,0,255); ofScale(scaleFac,scaleFac,1); //ofScale(1,1,1); }else{ ofScale(scaleFac,scaleFac,1); //ofScale(0.8,0.8,1); ofSetColor(0,100,0,255); } }else{ ofScale(scaleFac,scaleFac,1); //ofScale(0.2,0.2,1); ofSetColor(0,100,0,255); } myFont->drawBatch(letters[i],24, 0, 0); ofPopMatrix(); //} i++; } xPrev = x; yPrev = y; // Increment x dimension for noise //xoff += ofMap(p, 0, ofGetWidth(), 0,0.1); xoff += xFactor; x += 10; } myFont->endBatch(); //yoff += ofMap(ofGetMouseY(), 0, ofGetHeight(), 0.001,0.05); yoff += speed; ofSetColor(0,100,0,255); line.draw(); line.clear(); }
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(); } }
//------------------------------------------------------------------------------------ void CircleVisualization::Draw() { ofSetColor(InitialColor, CurrentAlpha); ofSetCircleResolution(CIRCLE_RESOLUTION); ofCircle(Position.x, Position.y, CurrentRadius); }
void ofApp::updateBoard(){ ofSetColor(ofColor::black); //Draw all the buttons in grid for (int i = 0; i < grid_size; i++){ for(int j = 0; j < grid_size; j++){ if (grid[i][j].isLinePassing(lineXPos)&& !grid[i][j].isOn) { //if the line is passing through ofSetColor(ofColor::mediumPurple); grid[i][j].isPlaying = false; } else if (grid[i][j].isLinePassing(lineXPos) && grid[i][j].isOn) { grid[i][j].isPlaying = true; if (grid[i][j].resetTimeBuffer) { grid[i][j].timeBuffer = ofGetFrameNum(); grid[i][j].resetTimeBuffer = false; } int x = grid[i][j].x_pos; int y = grid[i][j].y_pos; int rad = grid[i][j].radius/2; int repeat = 3; int frametime = 100 / speed; float div = ofGetFrameNum()- grid[i][j].timeBuffer; div = (frametime - div) / frametime; //draw more circles while (repeat > 1) { ofSetColor(ofColor::lightBlue); ofDrawCircle(x, y - rad*repeat, rad*div); ofDrawCircle(x, y + rad*repeat, rad*div); ofSetColor(ofColor::lightBlue); ofDrawCircle(x + rad*repeat, y, rad*div); ofDrawCircle(x + rad*repeat, y + rad*repeat, rad*div); ofDrawCircle(x + rad*repeat, y - rad*repeat, rad*div); ofSetColor(ofColor::lightBlue); ofDrawCircle(x - rad*repeat, y, rad *div); ofDrawCircle(x - rad*repeat, y - rad*repeat, rad *div); ofDrawCircle(x - rad*repeat, y + rad*repeat, rad *div); ofSetColor(ofColor::midnightBlue); repeat--; } } //Draw active buttons as green else if (grid[i][j].isOn) { ofSetColor(ofColor::skyBlue); grid[i][j].isPlaying = false; grid[i][j].resetTimeBuffer = true; } else { grid[i][j].resetTimeBuffer = true; } ofDrawCircle(grid[i][j].x_pos, grid[i][j].y_pos, grid[i][j].radius); ofSetColor(ofColor::black); //Set back to black when done grid[i][j].freq = frequencyFloat + (i * 100); } } lineXPos+=speed; frequencyFloat = frequency+440; if (lineXPos > 1024) lineXPos = 0; }
//-------------------------------------------------------------- void testApp::mouseMoved(int x, int y){ ofSetColor(255, 0, 0); ofDrawBitmapString("mouse moved!!!!", x, y); }
void Circle::draw() { ofSetColor(color_); ofEllipse(x_, y_, size_, size_); }
void Ball::draw() { //ofSetColor(m_colorList[static_cast<unsigned int>(m_ColorIdx) % COLOR_NUMBER]); ofSetColor(m_colorList[(unsigned int)(m_ColorIdx) % COLOR_NUMBER]); ofCircle(m_Position.x, m_Position.y, m_Radius); }
//-------------------------------------------------------------- void ofApp::draw(){ //---------draw videos------------------------------------- //city-------------------------------------------------- for (int i = 0; i < videoNum; i ++) { if (i < 3){ ofSetColor(255, 255, 255, opacity[i]); if (opacity[i] != 0) { cityVid[i].setSpeed(1); cityVid[i].draw(i * vidW + 10, 10, vidW, vidH); }else{ cityVid[i].setSpeed(0); } ofSetColor(255, 255, 255, 255 - opacity[i]); if (255 - opacity[i] != 0) { greenVid[i].setSpeed(1); greenVid[i].draw(i * vidW + 10, 10, vidW, vidH); }else{ greenVid[i].setSpeed(0); } }else{ ofSetColor(255, 255, 255, opacity[i]); if (opacity[i] != 0) { cityVid[i].setSpeed(1); cityVid[i].draw((i-3) * vidW + 10, 10 + vidH, vidW, vidH); }else{ cityVid[i].setSpeed(0); } ofSetColor(255, 255, 255, 255 - opacity[i]); if (255 - opacity[i] != 0) { greenVid[i].setSpeed(1); greenVid[i].draw((i-3) * vidW + 10, 10 + vidH, vidW, vidH); }else{ greenVid[i].setSpeed(0); } } } //--------------------------------------------------------- // Syphon Stuff mClient.draw(50, 50); mainOutputSyphonServer.publishScreen(); // individualTextureSyphonServer.publishTexture(&tex); // ofDrawBitmapString("Note this text is not captured by Syphon since it is drawn after publishing.nYou can use this to hide your GUI for example.", 150,500); ofSetColor(255, 255, 255, 255); ofDrawBitmapString("Distance: " + ofToString(byteData), 10, 780); ofDrawBitmapString("FPS: " + ofToString(ofGetFrameRate()), 10, 790); }
//-------------------------------------------------------------- void testApp::draw() { ofEnableAlphaBlending(); cam.begin(); ofDrawAxis(100); ofFill(); // draw all markers set ofSetColor(255, 128); for (int i = 0; i < max(0, (int)natnet.getNumMarkersSet() - 1); i++) { for (int j = 0; j < natnet.getMarkersSetAt(i).size(); j++) { ofDrawBox(natnet.getMarkersSetAt(i)[j], 3); } } // draw all markers ofSetColor(255, 30); for (int i = 0; i < natnet.getNumMarker(); i++) { ofDrawBox(natnet.getMarker(i), 3); } ofNoFill(); // draw filtered markers ofSetColor(255); for (int i = 0; i < natnet.getNumFilterdMarker(); i++) { ofDrawBox(natnet.getFilterdMarker(i), 10); } // draw rigidbodies for (int i = 0; i < natnet.getNumRigidBody(); i++) { const ofxNatNet::RigidBody &RB = natnet.getRigidBodyAt(i); if (RB.isActive()) ofSetColor(0, 255, 0); else ofSetColor(255, 0, 0); ofPushMatrix(); glMultMatrixf(RB.getMatrix().getPtr()); ofDrawAxis(30); ofPopMatrix(); glBegin(GL_LINE_LOOP); for (int n = 0; n < RB.markers.size(); n++) { glVertex3fv(RB.markers[n].getPtr()); } glEnd(); for (int n = 0; n < RB.markers.size(); n++) { ofDrawBox(RB.markers[n], 5); } } // draw skeletons for (int j = 0; j < natnet.getNumSkeleton(); j++) { const ofxNatNet::Skeleton &S = natnet.getSkeletonAt(j); ofSetColor(0, 0, 255); for (int i = 0; i < S.joints.size(); i++) { const ofxNatNet::RigidBody &RB = S.joints[i]; ofPushMatrix(); glMultMatrixf(RB.getMatrix().getPtr()); ofDrawBox(5); ofPopMatrix(); } } cam.end(); string str; str += "frames: " + ofToString(natnet.getFrameNumber()) + "\n"; str += "data rate: " + ofToString(natnet.getDataRate()) + "\n"; str += string("connected: ") + (natnet.isConnected() ? "YES" : "NO") + "\n"; str += "num markers set: " + ofToString(natnet.getNumMarkersSet()) + "\n"; str += "num marker: " + ofToString(natnet.getNumMarker()) + "\n"; str += "num filtered (non regidbodies) marker: " + ofToString(natnet.getNumFilterdMarker()) + "\n"; str += "num rigidbody: " + ofToString(natnet.getNumRigidBody()) + "\n"; str += "num skeleton: " + ofToString(natnet.getNumSkeleton()) + "\n"; ofSetColor(255); ofDrawBitmapString(str, 10, 20); }
//-------------------------------------------------------------- void testApp::setup(){ ofBackground(0,0,0); ofSetFrameRate(24); int xMax = 1024, yMax = 768; fbo.allocate(xMax, yMax, GL_RGBA, 2); fbo.setType("line"); fbo.setColor(ofColor(40, 107, 119)); fbo.generateShapes(20); fbo.paintMe(); fbo1.allocate(xMax, yMax, GL_RGBA, 2); fbo1.setType("line"); fbo1.setColor(ofColor(123, 155, 160)); fbo1.generateShapes(35); fbo1.paintMe(); fbo2.allocate(xMax, yMax, GL_RGBA, 2); fbo2.setType("line"); fbo2.setColor(ofColor(67, 140, 142)); fbo2.generateShapes(15); fbo2.paintMe(); fbo3.allocate(xMax, yMax, GL_RGBA, 2); fbo3.setType("line"); fbo3.setColor(ofColor(73, 103, 104)); fbo3.generateShapes(10); fbo3.paintMe(); fbo4.allocate(xMax, yMax, GL_RGBA, 2); fbo4.setType("line"); fbo4.setColor(ofColor(3, 117, 165)); fbo4.generateShapes(20); fbo4.paintMe(); // STARS float x = 1, y = 1; for(int i = 0; i < 100; i++) { x = x + ofGetWindowWidth() / 9; if(i % 11 == 0) { y = y + ofGetWindowHeight() / 9; x = 10; } stars.push_back(ofVec3f(x, y, ofRandom(0.8, 1))); } vector<ofVec3f>::iterator it = stars.begin(), end = stars.end(); ofSetColor(245); int rounds = 1000; for(int i = 0; i < rounds; i++) { for(; it != end; ++it) { it->set(it->x + ofRandom(-1.,1.), it->y + ofRandom(-1.1,1.1), 0); ofCircle((*it), 1); } it = stars.begin(); } // Point lights emit light in all directions // // set the diffuse color, color reflected from the light source // sun.setDiffuseColor( ofColor(249, 245, 224)); sunPos = ofVec3f(215, 964, 1100); sun.setPosition(sunPos); // specular color, the highlight/shininess color // sun.setSpecularColor( ofColor(255.f, 255.f, 0.f)); sun.setPointLight(); ofDisableArbTex(); //needed for textures to work with gluSphere }
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); }
//-------------------------------------------------------------- void testApp::draw(){ ofEnableAlphaBlending(); ofEnableLighting(); sun.enable(); vector<ofVec3f>::iterator it = stars.begin(), end = stars.end(); ofSetColor(255); for(; it != end; ++it) { it->set(it->x + ofRandom(-0.01,0.01), it->y + ofRandom(-0.01,0.01), 0); ofCircle(it->x,it->y, 0.8); } ofTranslate(ofGetWidth()/2, ofGetHeight()/2, 0); //rotate sphere over time ofRotateY(ofGetFrameNum()*-0.3); // super idee das mached mir so :D glEnable(GL_DEPTH_TEST); //enable depth comparisons and update the depth buffer ofSetColor(28, 220, 255); ofSphere(70); //bind and draw texture glMatrixMode(GL_TEXTURE); glPushMatrix(); ofScale(fbo.getWidth(), fbo.getHeight()); glMatrixMode(GL_MODELVIEW); ofSetColor(255); // IMPORTANT!!! fbo.getTextureReference().bind(); ofRotateY(-20); ofSphere(71); fbo.getTextureReference().unbind(); fbo1.getTextureReference().bind(); ofRotateY(180); ofSphere(72); fbo1.getTextureReference().unbind(); fbo2.getTextureReference().bind(); ofRotateY(25); ofSphere(75); fbo2.getTextureReference().unbind(); fbo3.getTextureReference().bind(); ofRotateY(-10.2); ofSphere(77); fbo3.getTextureReference().unbind(); fbo4.getTextureReference().bind(); ofRotateY(-45); ofSphere(80); fbo4.getTextureReference().unbind(); glMatrixMode(GL_TEXTURE); glPopMatrix(); glMatrixMode(GL_MODELVIEW); glDisable(GL_DEPTH_TEST); ofDisableAlphaBlending(); ofDisableLighting(); ofImage screen; screen.grabScreen(0,0,ofGetWindowWidth(), ofGetWindowHeight()); string frame = ofToString(ofGetFrameNum()); if(frame.length() < 6) { int add = 6 - frame.length(); for(int i = 0; i < add; i++) { frame = ofToString(0) + frame; } } screen.saveImage("pod2_" + frame + ".png"); cout << "saved " << "pod2_" << frame << ".png" << endl; }
//------------------------------------------------------------------ void rectangle::draw() { ofFill(); ofSetRectMode(OF_RECTMODE_CENTER); // center around the position ofSetColor(198,246,55); ofRect(pos.x, pos.y, 20,200); }
//-------------------------------------------------------------- void testApp::draw(){ ofSetColor(primaries[0]); ofRect(420,0, 200, 100); ofSetColor(primaries[1]); ofRect(320,0, 100, 50); ofSetColor(primaries[2]); ofRect(620,50, 100, 50); ofSetColor(primaries[3]); ofRect(320,50, 100, 50); ofSetColor(primaries[4]); ofRect(620,0, 100, 50); if (mode == 1) { ofSetColor(complements[0]); ofRect(420,100, 200, 100); ofSetColor(complements[1]); ofRect(320,100, 100, 50); ofSetColor(complements[2]); ofRect(620,150, 100, 50); ofSetColor(complements[3]); ofRect(320,150, 100, 50); ofSetColor(complements[4]); ofRect(620,100, 100, 50); } if (mode == 2 || mode == 4 || mode == 5) { ofSetColor(seconds[0]); ofRect(420,100, 200, 100); ofSetColor(seconds[1]); ofRect(320,100, 100, 50); ofSetColor(seconds[2]); ofRect(620,150, 100, 50); ofSetColor(seconds[3]); ofRect(320,150, 100, 50); ofSetColor(seconds[4]); ofRect(620,100, 100, 50); ofSetColor(thirds[0]); ofRect(420,200, 200, 100); ofSetColor(thirds[1]); ofRect(320,200, 100, 50); ofSetColor(thirds[2]); ofRect(620,250, 100, 50); ofSetColor(thirds[3]); ofRect(320,250, 100, 50); ofSetColor(thirds[4]); ofRect(620,200, 100, 50); } if (mode == 3) { ofSetColor(seconds[0]); ofRect(420,100, 200, 100); ofSetColor(seconds[1]); ofRect(320,100, 100, 50); ofSetColor(seconds[2]); ofRect(620,150, 100, 50); ofSetColor(seconds[3]); ofRect(320,150, 100, 50); ofSetColor(seconds[4]); ofRect(620,100, 100, 50); ofSetColor(complements[0]); ofRect(420,200, 200, 100); ofSetColor(complements[1]); ofRect(320,200, 100, 50); ofSetColor(complements[2]); ofRect(620,250, 100, 50); ofSetColor(complements[3]); ofRect(320,250, 100, 50); ofSetColor(complements[4]); ofRect(620,200, 100, 50); ofSetColor(thirds[0]); ofRect(420,300, 200, 100); ofSetColor(thirds[1]); ofRect(320,300, 100, 50); ofSetColor(thirds[2]); ofRect(620,350, 100, 50); ofSetColor(thirds[3]); ofRect(320,350, 100, 50); ofSetColor(thirds[4]); ofRect(620,300, 100, 50); } if (mode == 5) { ofSetColor(complements[0]); ofRect(420,300, 200, 100); ofSetColor(complements[1]); ofRect(320,300, 100, 50); ofSetColor(complements[2]); ofRect(620,350, 100, 50); ofSetColor(complements[3]); ofRect(320,350, 100, 50); ofSetColor(complements[4]); ofRect(620,300, 100, 50); } }
void OpCirlce :: drawFBOToScreen() { ofSetColor( 255, 255, 255 ); fbo.draw( 0, 0 ); }
void ofxTextObject::drawJustified(float x, float y, bool drawFlag) { string strToDraw; int currentWordID; float drawX = 0; float drawY = 0; int spacesN; float nonSpaceWordWidth; float pixelsPerSpace; float currX = 0; if (words.size() > 0) { if(drawFlag){ glPushMatrix(); glScalef(scaleFactor, scaleFactor, 1.0); } for(int l=0;l < lines.size(); l++) { //Find number of spaces and width of other words. spacesN = 0; nonSpaceWordWidth = 0; for(int w=0;w < lines[l].wordsID.size(); w++) { currentWordID = lines[l].wordsID[w]; if (words[currentWordID].rawWord == " ") spacesN++; else nonSpaceWordWidth += words[currentWordID].width; } pixelsPerSpace = ((columnWidth/scaleFactor) - (x/scaleFactor) - nonSpaceWordWidth) / spacesN; for(int w=0;w < lines[l].wordsID.size(); w++) { currentWordID = lines[l].wordsID[w]; drawX = currX; drawY = y - (leading/scaleFactor * float(l)); words[currentWordID].pos.set(drawX, drawY); //Record word position. if (words[currentWordID].rawWord != " ") { if(drawFlag){ if (drawWordColor) ofSetColor(words[currentWordID].color.r, words[currentWordID].color.g, words[currentWordID].color.b, words[currentWordID].color.a * drawMaterial->color.w/255.0f); //soso - removed this functionality for now //LM13 added back in..eep? if(!drawAsShapes){ words[currentWordID].font->drawString(words[currentWordID].rawWord.c_str(), drawX, drawY); }else{ //Support for vector drawing words[currentWordID].font->drawStringAsShapes(words[currentWordID].rawWord.c_str(), drawX, drawY); } } words[currentWordID].charPositions = words[currentWordID].font->getCharPositions(words[currentWordID].rawWord.c_str()); //soso - store char positions for word (using word font) currX += words[currentWordID].width; } else { currX += pixelsPerSpace; } } currX = 0; lines[l].pos.set(currX, drawY); //soso - record line position } if(drawFlag) glPopMatrix(); } }
void OpCirlce :: draw() { ofEnableSmoothing(); int k = 0; glPushMatrix(); glTranslatef( x, y, 0 ); glRotatef( rotation, 0, 0, 1 ); for( int i=0; i<resolution; i++ ) { if( i % 2 == 0 ) { if( inverse ) { ofSetColor( 255, 255, 255 ); } else { ofSetColor( (int)( rScale * audioInValue * 255 ), (int)( gScale * audioInValue * 255 ), (int)( bScale * audioInValue * 255 ) ); } } else { if( inverse ) { ofSetColor( 0, 0, 0 ); } else { ofSetColor( 255, 255, 255 ); } } if( resolution > 3 ) { ofFill(); ofTriangle ( 0, 0, circlePts[ k + 0 ] * radius, circlePts[ k + 1 ] * radius, circlePts[ k + 2 ] * radius, circlePts[ k + 3 ] * radius ); ofNoFill(); ofTriangle ( 0, 0, circlePts[ k + 0 ] * radius, circlePts[ k + 1 ] * radius, circlePts[ k + 2 ] * radius, circlePts[ k + 3 ] * radius ); k += 2; } } glPopMatrix(); ofDisableSmoothing(); }
void testApp::overlays(int xint, int yint) { if(overlayCnt==0) { title.draw("Try to Trace the Lines", "Tratar de trazar las lineas",75); ofSetLineWidth(3); ofSetColor(255, 64, 64); for (int i=0; i< net.numdivs; i++) { ofLine(net.vertex(i, i),net.vertex(i+1, i)); ofLine(net.vertex(i+1, i),net.vertex(i+1, i+1)); } ofSetColor(128, 64, 64); ofPoint disp=net.vertex(numOctaves/2, numOctaves/2); string report="Unison"; ofRectangle g=arialLabel.getBoundingBox(report, 0, 0); ofSetColor(red); arialLabel.drawString(report, disp.x-g.width-50,disp.y-100); ofSetColor(blue); arialLabel.drawString("Unisono", disp.x-arialLabel.stringWidth("Unisono")-50,disp.y-100+g.height); ofSetLineWidth(1); ofEnableSmoothing(); ofLine(disp.x-48, disp.y-98, disp.x, disp.y); ofDisableSmoothing(); ofSetColor(128, 64, 64); disp=net.vertex(numOctaves/2, numOctaves/2-1); report="Octave Difference"; g=arialLabel.getBoundingBox(report, 0, 0); ofSetColor(red); arialLabel.drawString(report, disp.x+50,disp.y+g.height+50); ofSetColor(blue); arialLabel.drawString("Diferencia de octava", disp.x+50,disp.y+50+g.height*2); ofSetLineWidth(1); ofEnableSmoothing(); ofLine(disp.x+50, disp.y+50, disp.x, disp.y); ofDisableSmoothing(); //reducedRatios(xint, yint); } if(overlayCnt==1) { title.draw("Constant ratio", "Relacion constante",75); ofSetLineWidth(3); ofSetColor(255, 64, 64); ofLine(net.vertex(0,0),net.vertex(numOctaves/2, numOctaves)); ofLine(net.vertex(0,0),net.vertex(numOctaves, numOctaves/2)); //arialLabel.drawString("2:1", net.vertex(2,4).x, net.vertex(2,4).y); ofPushMatrix(); ofTranslate(net.vertex(2,4).x-10, net.vertex(2,4).y,0); ofRotate(-63, 0,0,1); ofSetColor(178, 64, 64); arialLabel.drawString("2:1 ratio", 0,0); ofPopMatrix(); ofPushMatrix(); ofTranslate(net.vertex(4,2).x-15, net.vertex(4,2).y,0); ofRotate(-27, 0,0,1); ofSetColor(178, 64, 64); arialLabel.drawString("1:2 ratio", 0,0); ofPopMatrix(); } if(overlayCnt==2) { title.draw("Constant ratio", "Diferencia constante",75); ofSetLineWidth(3); ofSetColor(255, 64, 64); ofLine(net.vertex(0,0),net.vertex(numOctaves, numOctaves)); ofLine(net.vertex(0,1),net.vertex(numOctaves-1, numOctaves)); //arialLabel.drawString("2:1", net.vertex(2,4).x, net.vertex(2,4).y); ofPushMatrix(); ofTranslate(net.vertex(3,4).x-10, net.vertex(3,4).y,0); ofRotate(-45, 0,0,1); ofSetColor(178, 64, 64); arialLabel.drawString("Octave Difference", 0,0); ofPopMatrix(); ofPushMatrix(); ofTranslate(net.vertex(3,3).x-15, net.vertex(3,3).y,0); ofRotate(-45, 0,0,1); ofSetColor(178, 64, 64); arialLabel.drawString("Unison", 0,0); ofPopMatrix(); } if(overlayCnt==3) { title.draw("Can you trace the circle?", "Se puede trazar el circulo?",75); ofSetLineWidth(3); ofSetColor(255, 64, 64); ofNoFill(); ofRect(net.vertex(1, 1),pixOctave*(numOctaves-2),-pixOctave*(numOctaves-2)); ofSetCircleResolution(60); ofCircle(net.vertex(numOctaves/2, numOctaves/2), pixOctave*(numOctaves-2)/2); ofSetCircleResolution(20); ofFill(); } if(overlayCnt==4) { //reducedRatios(xint,yint); title.draw("Ratios", "Ratios",75); if(dispLines) { int xm=xint-(width-sqWid)/2,ym=sqWid-(yint-yOffset); nearest_fraction(&xm, &ym,sqWid,numOctaves); for(int i=0; i<numOctaves+1; i++) { ofPoint k=net.vertex(xm*i, ym*i); if(abs(xint-k.x)<20&&abs(yint-k.y)<20) { double xp=xm,yp=ym; if(xp<8&&yp<8) { if(xp>yp) yp*=(8/xp), xp=8; else if(yp>xp) xp*=(8/yp), yp=8; else if(yp=xp) xp=yp=8; } ofEnableSmoothing(); ofSetColor(255, 64, 64); ofSetLineWidth(3); ofLine(net.vertex(0, 0),net.vertex(xp, yp)); ofDisableSmoothing(); } } } } }
//-------------------------------------------------------------- void ofApp::setup() { ofSetVerticalSync(true); //ofSetWindowShape(640, 640); ofSetFullscreen(true); // Box2d box2d.init(); box2d.setGravity(0, 10); box2d.createGround(); box2d.setFPS(30.0); box2d.createBounds(ofRectangle(0, 0, ofGetWidth(), ofGetHeight())); // mask ofShader shader; ofFbo mask; ofFbo final; ofPixels pixels; image.load("jobs.jpg"); //sigma: to smooth the image. //k: constant for treshold function. //min: minimum component size (enforced by post-processing stage). // segment the image segmentation.sigma = 1.0; segmentation.k = 300; // how small the chunks segmentation.min = 2000; segmentation.segment(image); segmentedImage.setFromPixels(segmentation.getSegmentedPixels()); segmentedImage.update(); // grab the contours of the individual segments contourFinder.setMinArea(1000); contourFinder.setMaxArea(image.getWidth() * image.getHeight()); int i = 0; // for each segment found, create a TexturedBox2dPolygon for (int c = 0; c < segmentation.numSegments; c++) { //cout << segmentation.getSegmentMask(c); contourFinder.findContours(segmentation.getSegmentMask(c)); if (contourFinder.getBoundingRect(0).width * contourFinder.getBoundingRect(0).height > image.getWidth()*image.getHeight()*0.15) { continue; } // get contour points ofPolyline points; for (auto p : contourFinder.getContour(0)) { points.addVertex(toOf(p)); } //points.simplify(2); // this seems to cause box2d to crash sometimes // get bounding box cv::Rect box = contourFinder.getBoundingRect(0); ofImage segmentImage; segmentImage.setFromPixels(image); segmentImage.crop(box.x, box.y, box.width, box.height); /* //Save the segmentImages std::string name = "test"; name += ofToString(i) + ".png"; //segmentImage.save(name) ; i++ ;*/ mask.allocate(box.width, box.height); final.allocate(box.width, box.height); shader.load("standard.vert", "alphamask.frag"); // make mask from contour points mask.begin(); ofClear(0,0); ofSetColor(255); ofBeginShape(); vector<ofPoint> & vertices = points.getVertices(); for (int i=0; i<vertices.size(); i++) { ofVertex(vertices[i].x - box.x, vertices[i].y - box.y); } ofEndShape(); mask.end(); // make final masked texture and read into pixels final.begin();
void SceneManager::drawDebug(Depth & depth) { if (player.isLoaded() && isPlayingSequence) { if (isDancerSilhouetteDebugVisible) { // Draw the video frame ofSetColor(255, 255, 255); ofPushMatrix(); ofTranslate(0, ofGetHeight() - srcH * vidScale); ofScale(vidScale, vidScale); player.draw(0, 0); ofPopMatrix(); // draw blurred ofPushMatrix(); ofTranslate(srcW * vidScale, ofGetHeight() - srcH * vidScale); ofScale(vidScale, vidScale); dancerFbo[currentVidFbo].draw(0, 0); ofPopMatrix(); // draw CV Grey image ofPushMatrix(); ofTranslate(srcW * 2 * vidScale, ofGetHeight() - srcH * vidScale); ofScale(vidScale, vidScale); dancerSilhouette.drawCvGreyImg(); ofPopMatrix(); // draw contour ofPushStyle(); ofSetColor(255, 0, 0); ofPushMatrix(); ofTranslate(srcW * 3 * vidScale, ofGetHeight() - srcH * vidScale); ofScale(vidScale, vidScale); dancerSilhouette.drawContour(); ofPopMatrix(); ofPopStyle(); } } if (isUserSilhouetteDebugVisible) { // draw blurred ofPushMatrix(); ofTranslate(srcW * vidScale, ofGetHeight() - srcH * vidScale * 2); ofScale(vidScale, vidScale); userFbo[currentVidFbo].draw(0, 0); ofPopMatrix(); // draw CV Grey image ofPushMatrix(); ofTranslate(srcW * 2 * vidScale, ofGetHeight() - srcH * vidScale * 2); ofScale(vidScale, vidScale); userSilhouette.drawCvGreyImg(); ofPopMatrix(); // draw contour ofPushStyle(); ofSetColor(255, 0, 0); ofPushMatrix(); ofTranslate(srcW * 3 * vidScale, ofGetHeight() - srcH * vidScale * 2); ofScale(vidScale, vidScale); userSilhouette.drawContour(); ofPopMatrix(); ofPopStyle(); } if (isDrawDepth) drawDepth(depth, 0, 480 * 0.5); if (isDrawClippedDepth) { ofPushMatrix(); ofTranslate(0, ofGetHeight() - srcH * vidScale * 2); ofScale(vidScale, vidScale); drawClippedDepth(0, 0); ofPopMatrix(); } if (isDrawLargeClippedDepth) { ofPushMatrix(); ofTranslate(640 * 0.5, 0); ofScale(largeClippingScale, largeClippingScale); depthFbo.draw(0, 0); ofPopMatrix(); } if (screenRecorder.getIsRecording()) { fastFboReader.readToPixels(depthFbo, pix); screenRecorder.addFrame(pix); } ofPushStyle(); ofSetColor(0); ofPushMatrix(); ofTranslate(ofGetWidth() - 100, 20); screenRecorder.draw(); ofPopMatrix(); ofPopStyle(); }
void Tracker :: draw () { int pad = 10; glPushMatrix(); glTranslatef( screenPos.x, screenPos.y, 0 ); ofSetColor( 0xFFFFFF ); videoSmlImage.draw( 0, 0 ); ofSetColor( 0x00FF00 ); ofDrawBitmapString( "1) original", 10, 20 ); glPushMatrix(); glTranslatef( videoSmlImage.width + pad, 0, 0 ); ofSetColor( 0xFFFFFF ); cvImageWarp.draw( 0, 0 ); ofSetColor( 0x00FF00 ); ofDrawBitmapString( "2) warped", 10, 20 ); glPushMatrix(); glTranslatef( videoSmlRect.width + pad, 0, 0 ); ofSetColor( 0xFFFFFF ); cvImageBg.draw( 0, 0 ); ofSetColor( 0x00FF00 ); ofDrawBitmapString( "3) background", 10, 20 ); glPopMatrix(); glPopMatrix(); glPushMatrix(); glTranslatef( 0, videoSmlRect.height + pad, 0 ); ofSetColor( 0xFFFFFF ); cvImageDiff.draw( 0, 0 ); ofSetColor( 0x00FF00 ); ofDrawBitmapString( "4) diff + blur", 10, 20 ); glPushMatrix(); glTranslatef( videoSmlRect.width + pad, 0, 0 ); ofSetColor( 0xFFFFFF ); cvImageThsh.draw( 0, 0 ); ofSetColor( 0x00FF00 ); ofDrawBitmapString( "5) threshold", 10, 20 ); glPushMatrix(); glTranslatef( videoSmlRect.width + pad, 0, 0 ); ofFill(); ofSetColor( 0x000000 ); ofRect( 0, 0, videoSmlRect.width, videoSmlRect.height ); contourFinder.draw(); ofSetColor( 0x00FF00 ); ofDrawBitmapString( "6) contours", 10, 20 ); glPopMatrix(); glPopMatrix(); glPopMatrix(); ofNoFill(); //-- camera position. ofSetColor( 255, 0, 0, 127 ); ofEnableAlphaBlending(); ofCircle( cameraPosition.x, cameraPosition.y, cameraRadius ); ofFill(); ofCircle( cameraPosition.x, cameraPosition.y, 3 ); ofDisableAlphaBlending(); glPopMatrix(); cvWarper.draw(); }
void Blob::draw() { ofPushStyle(); ofSetColor(0,0,0, 55); drawShape(); ofPopStyle(); }
//-------------------------------------------------------------- void testApp::draw(){ ofBackground(0); string s = string("") + "\n" + "Purple boxes (4 of them) are generic nodes with simple circular motion, linked in a hierarchy (with ofNode::setParent).\n" + "Yellow boxes (2 of them) are cameras. You are looking through one of them so can only see one box on screen.\n" + "\n" + "KEYS:\n" + "\n" + "z reset transforms\n" + "\n" + "v switch camera to view: " + ofToString(camToView) + "\n" + "\n" + "o toggle mouse orbit for cam\n" + "\n" + "c switch camera to configure: " + ofToString(camToConfigure) + "\n" + " t cycle lookat\n" + " p cycle parent\n" + " LEFT pan left\n" + " RIGHT pan right\n" + " UP tilt up\n" + " DOWN tilt down\n" + " , roll left\n" + " . roll right\n" + " a truck left\n" + " d truck right\n" + " w dolly forward\n" + " s dolly backward\n" + " r boom up\n" + " f boom down\n"; glDisable(GL_CULL_FACE); ofSetColor(255); ofDisableLighting(); ofDrawBitmapString(s, ofPoint(20, 20)); glEnable(GL_CULL_FACE); ofEnableLighting(); // update camera transforms for(int i=0; i<kNumCameras; i++) { // lookat node if it has one if(lookatIndex[i] >= 0) cam[i].lookAt(testNodes[lookatIndex[i]]); // mouse orbit camera if(doMouseOrbit[i] && ofGetMousePressed(0)) { static float lon = 0; static float lat = 0; lon = ofClamp(lon + mouseX - ofGetPreviousMouseX(), -180, 180); lat = ofClamp(lat + mouseY - ofGetPreviousMouseY(), -90, 90); if(lookatIndex[i] < 0) { cam[i].orbit(lon, lat, orbitRadius); } else { cam[i].orbit(lon, lat, orbitRadius, testNodes[lookatIndex[1]]); } } } // activate camera cam[camToView].begin(); // draw world axis ofDrawAxis(100); // draw testNodes for(int i=0; i<kNumTestNodes; i++) { ofSetColor(255, 128, 255); testNodes[i].draw(); } // draw cameras for(int i=0; i<kNumCameras; i++) { ofSetColor(255, 255, 0); cam[i].draw(); // draw line from cam to its lookat if(lookatIndex[i] >= 0) { ofSetColor(0, 255, 255); ofVec3f v1 = cam[i].getGlobalPosition(); ofVec3f v2 = testNodes[lookatIndex[i]].getGlobalPosition(); ofLine(v1,v2); } // draw line from cam to its parent if(parentIndex[i] >= 0) { ofSetColor(255, 255, 0); ofVec3f v1 = cam[i].getGlobalPosition(); ofVec3f v2 = testNodes[parentIndex[i]].getGlobalPosition(); ofLine(v1,v2); } } // restore view to previous state (default openFrameworks view) cam[camToView].end(); }
void PulseCircle::draw(){ ofSetColor(color,opac); ofCircle(loc,size); }
//-------------------------------------------------------------- void ofApp::setup(){ kinect.open(); kinect.initDepthSource(); kinect.initColorSource(); kinect.initInfraredSource(); kinect.initBodyIndexSource(); kinect.initBodySource(); gui.init(); //setup a gui panel for the widgets at top-left auto widgets = gui.addWidgets(); widgets->addTitle("ofxKinectForWindows2"); widgets->addFps(); widgets->addMemoryUsage(); //setup a gui panel for the 3D view auto worldView = gui.addWorld("World"); worldView->onDrawWorld += [this](ofCamera &) { this->kinect.drawWorld(); }; //setup a gui panel for every kinect source auto sources = kinect.getSources(); for(auto source : sources) { auto sourceWithTexture = dynamic_pointer_cast<ofBaseHasTexture>(source); if (sourceWithTexture) { auto panel = gui.add(sourceWithTexture->getTexture(), source->getTypeName()); //if it's the colour panel, let's do something special by writing some info on top auto colorSource = dynamic_pointer_cast<ofxKFW2::Source::Color>(source); if (colorSource) { panel->onDraw += [colorSource] (ofxCvGui::DrawArguments &) { stringstream message; message << "Exposure : " << colorSource->getExposure() << "us" << endl; message << "FrameInterval : " << colorSource->getFrameInterval() << "us" << endl; message << "Gain : " << colorSource->getGain() << endl; message << "Gamma : " << colorSource->getGamma() << endl; ofxCvGui::Utils::drawText(message.str(), 20, 60); }; } //if it's the depth panel, set some scaling auto depthSource = dynamic_pointer_cast<ofxKFW2::Source::Depth>(source); if (depthSource) { auto style = make_shared<ofxCvGui::Panels::Texture::Style>(); style->rangeMaximum = 0.25f; panel->setStyle(style); } //if it's the body index panel, let's draw the joints on top auto bodyIndexSource = dynamic_pointer_cast<ofxKFW2::Source::BodyIndex>(source); if(bodyIndexSource) { panel->onDrawImage += [this](ofxCvGui::DrawImageArguments & args) { auto bodySource = this->kinect.getBodySource(); const auto & bodies = bodySource->getBodies(); ofPushStyle(); { ofColor color(200, 100, 100); int index = 0; for (const auto & body : bodies) { color.setHueAngle((index * 50) % 360); ofSetColor(color); for (const auto & joint : body.joints) { ofDrawCircle(joint.second.getPositionInDepthMap(), 5); } index++; } } ofPopStyle(); }; } } //add an 'isFrameNew' widget to the panel widgets->addIndicatorBool(source->getTypeName() + " frame new", [source]() { return source->isFrameNew(); }); } //if we press the 'c' key on the World panel, then toggle the camera's cursor. This works best when you fullscreen that panel worldView->onKeyboard += [this, worldView] (ofxCvGui::KeyboardArguments & args) { if (args.action == ofxCvGui::KeyboardArguments::Action::Pressed && args.key =='c') { worldView->getCamera().toggleCursorDrawEnabled(); } }; }