void ofApp::draw(){ ofEnableLighting(); ofPushMatrix(); ofTranslate(ofGetWidth() / 2, ofGetHeight() / 2 , 0); // get the most recent data ConnexionData& data = ofxConnexion::connexionData; int colval = (data.rotation[2] + 180)*(255/180); //ofSetColor(data.rotation[0]*255/180, data.rotation[1]*255/180, data.rotation[2]*255/180); ofSetColor(colval, abs(127 - colval), abs(colval - 255), 255-data.position[0]); //ofDrawSphere(data.rotation[1]* 3, data.rotation[0]*3, (data.position[0] + data.position[1]), data.position[2]); //ofDrawCircle(data.rotation[1]* 2, data.rotation[0]*2, 2 + data.position[2]/2); ofNoFill(); ofDrawTriangle(data.rotation[1]* 3, data.rotation[0]*3, (data.position[0] + data.position[1]), (data.rotation[1]* 3)+data.position[2] , (data.rotation[0]*3) - data.position[2], (data.position[0] + data.position[1]) ); ofBeginShape(); //Begin shape ofVertex( data.rotation[0], data.rotation[1], data.rotation[2] ); //The first vertex ofVertex( data.rotation[0], data.rotation[1], data.rotation[2] ); //The second vertex//... ofVertex( data.rotation[0], data.rotation[1], data.rotation[2] ); //The last vertex ofEndShape(); ofPopMatrix(); //- //ofDisableLighting(); ofPushStyle(); ofSetColor(255); stringstream ss; ss << endl; ss << "POSITION" << endl; ss << "data.position[0] : " << data.position[0] << endl; ss << "data.position[2] : " << data.position[2] << endl; ss << "data.position[1] : " << data.position[1] << endl; ss << endl; ss << "ROTATION" << endl; ss << "data.rotation[0] : " << data.rotation[0] << endl; ss << "data.rotation[2] : " << data.rotation[2] << endl; ss << "data.rotation[1] : " << data.rotation[1] << endl; ss << endl; ofDrawBitmapString(ss.str().c_str(), 10, 20); ofPopStyle(); }
void mover::draw(){ ofSetColor(cor, 125); float angle = ofRadToDeg(atan2(velocity.y,velocity.x)) + 90; ofPushMatrix(); ofTranslate(location.x, location.y); ofRotate(angle); ofDrawTriangle(-size+5, size, size-5, size, 0, -size); ofPopMatrix(); }
//---------------------------------------------------------- void ofxVectorGraphics::triangle(float x1,float y1, float x2, float y2, float x3, float y3){ if(bDraw){ ofDrawTriangle(x1, y1, x2, y2, x3, y3); } if(bRecord){ creeps.startPath(x1, y1); creeps.addLine(x2, y2); creeps.addLine(x3, y3); creeps.closeSubpath(); if(bFill)creeps.endPath(CreEPS::FILL); else creeps.endPath(CreEPS::STROKE); } }
// fonction invoquée lors d'une mise à jour du rendu de la fenêtre de l'application void ofApp::draw() { ofClear(191); ofFill(); ofSetColor(255); ofDrawTriangle( vertex1_X, vertex1_Y, vertex2_X, vertex2_Y, vertex3_X, vertex3_Y); ofSetColor(0); ofDrawEllipse(vertex1_X, vertex1_Y, pointRadius, pointRadius); ofDrawEllipse(vertex2_X, vertex2_Y, pointRadius, pointRadius); ofDrawEllipse(vertex3_X, vertex3_Y, pointRadius, pointRadius); }
void ofxImageTS::pixelate(ofPixels pixels, int pixelRatio, int X, int Y, int W, int H, int form) { if(pixelRatio > 4 || pixelRatio < 0) { ofLogNotice("Pixel Ratio must be between 0 and 5"); } else { ofPixels R,G,B, copy; pixels.resize(W,H); copy.allocate(pixels.getWidth(), pixels.getHeight(), OF_PIXELS_RGBA); copy = pixels; R = copy.getChannel(0); G = copy.getChannel(1); B = copy.getChannel(2); int camWidth = pixels.getWidth(); int camHeight = pixels.getHeight(); int boxWidth = pixels.getWidth()/(pow(2,pixelRatio)*10); int boxHeight = pixels.getHeight()/(pow(2,pixelRatio)*10); float tot = boxWidth*boxHeight; for (int x = 0; x < camWidth; x += boxWidth) { for (int y = 0; y < camHeight; y += boxHeight) { float Red = 0, Green = 0, Blue = 0; for (int k = 0; k < boxWidth; k++) { for (int l = 0; l < boxHeight; l++) { int index = (x + k) + (y + l) * camWidth; Red += R[index]; Green += G[index]; Blue += B[index]; } ofSetColor(Red/tot,Green/tot,Blue/tot); ofFill(); if(form == 1) ofDrawRectangle(x+X, y+Y, boxWidth, boxHeight); if(form == 2) ofDrawBox(x+X, y+Y, boxWidth, boxHeight); if(form == 3) ofDrawCircle(x+X, y+Y, boxWidth, boxHeight); if(form == 4) ofDrawTriangle(x+X, y+Y, X+x+boxHeight, y+Y, x+X, y+Y+boxWidth); } } } } }
void triangleScene::draw(){ ofSetColor(255,255,255,80); for (int i = 0; i < numTriangles; i++){ ofDrawTriangle( ofRandom(0, dimensions.width), ofRandom(0, dimensions.height), ofRandom(0, dimensions.width), ofRandom(0, dimensions.height), ofRandom(0, dimensions.width), ofRandom(0, dimensions.height)); } ofSetColor(255,255,255); }
void flagLayer::drawPrimitives() { switch (type) { case 0: //SQUARE ofSetColor(strokeWeight > 0 ? strokeColor : colors[0]); ofRect(center.x - scale*.5f, center.y - (scale + height)*.5f, scale, scale + height); if (strokeWeight > 0) { ofSetColor(colors[0]); ofRect(center.x - scale*.5f + strokeWeight, center.y - (scale + height)*.5f + strokeWeight, scale - strokeWeight * 2, scale + height - strokeWeight * 2); } break; case 1: //TRIANGLE { ofPoint v1 = ofPoint(0, 1).normalize(); float angle = (float)TWO_PI / 3; //120 ofPoint v2 = ofPoint(v1.x*cos(angle) - v1.y*sin(angle), v1.x*sin(angle) + v1.y*cos(angle)); angle = (float)(TWO_PI / 3) * 2; //240 ofPoint v3 = ofPoint(v1.x*cos(angle) - v1.y*sin(angle), v1.x*sin(angle) + v1.y*cos(angle)); ofPoint p1, p2, p3; p1 = v1; p2 = v2; p3 = v3; p1 *= scale + height; p2 *= scale; p3 *= scale; p1 += center; p2 += center; p3 += center; ofSetColor(strokeWeight > 0 ? strokeColor : colors[0]); ofDrawTriangle(p1.x, p1.y, p2.x, p2.y, p3.x, p3.y); if (strokeWeight > 0) { ofSetColor(colors[0]); v1 = ofPoint(0, (float)(1-(float)strokeWeight/500)); angle = (float)TWO_PI / 3; //120 v2 = ofPoint(v1.x*cos(angle) - v1.y*sin(angle), v1.x*sin(angle) + v1.y*cos(angle)); angle = (float)(TWO_PI / 3) * 2; v3 = ofPoint(v1.x*cos(angle) - v1.y*sin(angle), v1.x*sin(angle) + v1.y*cos(angle)); p1 = v1; p2 = v2; p3 = v3; p1 *= scale + height; p2 *= scale; p3 *= scale; p1 += center; p2 += center; p3 += center; ofDrawTriangle(p1.x, p1.y, p2.x, p2.y, p3.x, p3.y); } break; } case 2: //CIRCLE ofSetColor(strokeWeight > 0 ? strokeColor : colors[0]); ofEllipse(center, scale, scale + height); if (strokeWeight > 0) { ofSetColor(colors[0]); ofEllipse(center, scale-strokeWeight, scale + height-strokeWeight); } break; case 3: //CROSS ofSetColor(strokeWeight > 0 ? strokeColor : colors[0]); ofRect(center.x - scale*.5f, center.y - (scale + height)*.5f, scale, scale + height); ofPushMatrix(); ofTranslate(center.x, center.y, 0); ofRotate(90); ofPushMatrix(); ofTranslate(-center.x, -center.y, 0); ofSetColor(strokeWeight > 0 ? strokeColor : colors[0]); ofRect(center.x - scale*.5f, center.y - (scale + height)*.5f, scale, scale + height); ofPopMatrix(); ofPopMatrix(); if (strokeWeight > 0) { ofSetColor(colors[0]); ofRect(center.x - scale*.5f + strokeWeight, center.y - (scale + height)*.5f + strokeWeight, scale - strokeWeight * 2, scale + height - strokeWeight * 2); } ofPushMatrix(); ofTranslate(center.x, center.y, 0); ofRotate(90); ofPushMatrix(); ofTranslate(-center.x, -center.y, 0); if (strokeWeight > 0) { ofSetColor(colors[0]); ofRect(center.x - scale*.5f + strokeWeight, center.y - (scale + height)*.5f + strokeWeight, scale - strokeWeight * 2, scale + height - strokeWeight * 2); } ofPopMatrix(); ofPopMatrix(); break; } }
void ofxTimeMeasurements::draw(int x, int y) { if (!enabled){ //drawString(ofToString(fr, msPrecision), 10, fontSize); return; } float fr = ofGetFrameRate(); uint64_t timeNow; if(internalBenchmark){ timeNow = TM_GET_MICROS(); } currentFrameNum = ofGetFrameNum(); drawLines.clear(); float percentTotal = 0.0f; float timePerFrame = 1000.0f / desiredFrameRate; mutex.lock(); vector<TimeMeasurement*> toResetUpdatedLastFrameFlag; //update time stuff, build draw lists for( unordered_map<string,TimeMeasurement*>::iterator ii = times.begin(); ii != times.end(); ++ii ){ TimeMeasurement* t = ii->second; string key = ii->first; if(!t->measuring){ if (t->life > 0.01){ t->life *= idleTimeColorDecay; //decrease life }else{ //life decays very slow when very low t->life *= deadThreadExtendedLifeDecSpeed; //decrease life very slowly } } // if (!t->updatedLastFrame && averaging){ // if we didnt update that time, make it tend to zero slowly // t->avgDuration = (1.0f - timeAveragePercent) * t->avgDuration; // } toResetUpdatedLastFrameFlag.push_back(t); } unordered_map<ThreadId, ThreadInfo>::iterator ii; vector<ThreadId> expiredThreads; //lets make sure the Main Thread is always on top vector< ThreadContainer > sortedThreadList; for( ii = threadInfo.begin(); ii != threadInfo.end(); ++ii ){ //walk all thread trees ThreadContainer cont; cont.id = ii->first; cont.info = &ii->second; if (isMainThread(ii->first)){ //is main thread sortedThreadList.insert(sortedThreadList.begin(), cont); }else{ sortedThreadList.push_back(cont); } } std::sort(sortedThreadList.begin(), sortedThreadList.end(), compareThreadPairs); #if defined(USE_OFX_HISTORYPLOT) vector<ofxHistoryPlot*> plotsToDraw; #endif for( int k = 0; k < sortedThreadList.size(); k++ ){ //walk all thread trees ThreadId thread = sortedThreadList[k].id; core::tree<string> &tr = sortedThreadList[k].info->tree; ThreadInfo & tinfo = threadInfo[thread]; PrintedLine header; header.formattedKey = "+ " + *tr; header.color = tinfo.color; header.lineBgColor = ofColor(header.color, dimColorA * 2); //header twice as alpha header.key = *tr; //key for selection, is thread name drawLines.push_back(header); //add header to drawLines int numAlive = 0; int numAdded = 0; core::tree<string>::iterator wholeTreeWalker = tr.in(); bool finishedWalking = false; float winW = ofGetWidth(); while( !finishedWalking ){ string key = *wholeTreeWalker; TimeMeasurement * t = times[*wholeTreeWalker]; if(t->thread == thread){ #if defined(USE_OFX_HISTORYPLOT) bool plotActive = false; ofxHistoryPlot* plot = plots[key]; if(plot){ if(t->settings.plotting){ if(t->updatedLastFrame){ //update plot res every now and then if(currentFrameNum%120 == 1) plot->setMaxHistory(MIN(maxPlotSamples, winW * plotResolution)); if (!freeze) { if (t->accumulating) { plot->update(t->microsecondsAccum / 1000.0f); } else { plot->update(t->avgDuration / 1000.0f); } } } plotsToDraw.push_back(plot); plotActive = true; } } #endif bool visible = t->settings.visible; bool alive = t->life > 0.0001; if(alive){ numAlive++; } if (visible && (removeExpiredTimings ? alive : true)){ PrintedLine l; l.key = key; l.tm = t; l.lineBgColor = ofColor(tinfo.color, dimColorA); int depth = wholeTreeWalker.level(); for(int i = 0; i < depth; ++i) l.formattedKey += " "; if (wholeTreeWalker.size() == 0){ l.formattedKey += "-"; }else{ l.formattedKey += "+"; } l.formattedKey += key + string(t->accumulating ? "[" + ofToString(t->numAccumulations)+ "]" : "" ); l.isAccum = t->accumulating; l.time = getTimeStringForTM(t); if(drawPercentageAsGraph){ l.percentGraph = getPctForTM(t); } l.color = tinfo.color * ((1.0 - idleTimeColorFadePercent) + idleTimeColorFadePercent * t->life); if (!t->settings.enabled){ if(t->ifClause){ l.color = disabledTextColor; }else{ l.color = disabledTextColor.getInverted(); } } #if defined(USE_OFX_HISTORYPLOT) if(plotActive){ l.plotColor = ofColor(plots[key]->getColor(), 200); } #endif if (menuActive && t->key == selection){ if(currentFrameNum%5 < 4){ l.color.invert(); l.lineBgColor = ofColor(tinfo.color, dimColorA * 1.5); } } drawLines.push_back(l); numAdded++; } //only update() and draw() count to the final % if(key == TIME_MEASUREMENTS_DRAW_KEY || key == TIME_MEASUREMENTS_UPDATE_KEY){ percentTotal += (t->avgDuration * 0.1f) / timePerFrame; } //reset accumulator t->accumulating = false; t->numAccumulations = 0; t->microsecondsAccum = 0; } //control the iterator to walk the tree "recursively" without doing so. if(wholeTreeWalker.size()){ wholeTreeWalker = wholeTreeWalker.in(); }else{ if ( wholeTreeWalker.next() == wholeTreeWalker.end() ){ wholeTreeWalker = wholeTreeWalker.out(); while( wholeTreeWalker.next() == wholeTreeWalker.end() && wholeTreeWalker != tr){ wholeTreeWalker = wholeTreeWalker.out(); } if(wholeTreeWalker == tr){ finishedWalking = true; }else{ wholeTreeWalker++; } }else{ ++wholeTreeWalker; } } } #if defined(USE_OFX_HISTORYPLOT) numActivePlots = plotsToDraw.size(); #endif if (numAlive == 0 && removeExpiredThreads){ //drop that whole section if all entries in it are not alive for(int i = 0; i < numAdded + 1; i++){ if(drawLines.size() > 0){ int delID = drawLines.size() - 1; //clear selection if needed if (selection == drawLines[delID].key){ selection = TIME_MEASUREMENTS_UPDATE_KEY; } drawLines.erase(drawLines.begin() + delID); } } expiredThreads.push_back(thread); } } //delete expired threads for(int i = 0; i < expiredThreads.size(); i++){ unordered_map<ThreadId, ThreadInfo>::iterator treeIt = threadInfo.find(expiredThreads[i]); if (treeIt != threadInfo.end()) threadInfo.erase(treeIt); } mutex.unlock(); updateLongestLabel(); //find headers int tempMaxW = -1; vector<int> headerLocations; for( int i = 0; i < drawLines.size(); i++ ){ if (drawLines[i].tm){ //its a measurement //add padding to draw in columns for(int j = drawLines[i].formattedKey.length(); j < longestLabel; j++){ drawLines[i].formattedKey += " "; } if (!drawLines[i].tm->error){ drawLines[i].shouldDrawPctGraph = true; drawLines[i].fullLine = drawLines[i].formattedKey + " " + drawLines[i].time; }else{ drawLines[i].shouldDrawPctGraph = true; drawLines[i].fullLine = drawLines[i].formattedKey + " Error!" ; } int len = drawLines[i].fullLine.length(); if(len > tempMaxW) tempMaxW = len; if(drawLines[i].tm->measuring) drawLines[i].shouldDrawPctGraph = false; }else{ //its a header drawLines[i].fullLine = drawLines[i].formattedKey; drawLines[i].shouldDrawPctGraph = false; headerLocations.push_back(i); } } int numInstructionLines = 0; if(menuActive){ //add instructions line if menu active PrintedLine l; //title line l.color = hilightColor; l.lineBgColor = ofColor(hilightColor, dimColorA * 2); l.fullLine = " KEYBOARD COMMANDS "; //len = 23 int numPad = 2 + ceil((getWidth() - charW * (23)) / charW); for(int i = 0; i < floor(numPad/2.0); i++ ) l.fullLine = "#" + l.fullLine; for(int i = 0; i < ceil(numPad/2.0); i++ ) l.fullLine += "#"; l.fullLine = " " + l.fullLine; drawLines.push_back(l); numInstructionLines++; //key command lines l.lineBgColor = ofColor(hilightColor, dimColorA); l.fullLine = " 'UP/DOWN' select measur."; drawLines.push_back(l); numInstructionLines++; l.fullLine = " 'LFT/RGHT' expand/collaps"; drawLines.push_back(l); numInstructionLines++; l.fullLine = " 'RET' toggle code section"; drawLines.push_back(l); numInstructionLines++; l.fullLine = " 'A' average measurements"; drawLines.push_back(l); numInstructionLines++; l.fullLine = " 'F' freeze measurements"; drawLines.push_back(l); numInstructionLines++; l.fullLine = " 'L' cycle widget location"; drawLines.push_back(l); numInstructionLines++; l.fullLine = " 'PG_DWN' en/disable addon"; drawLines.push_back(l); numInstructionLines++; l.fullLine = " 'B' internal benchmark"; drawLines.push_back(l); numInstructionLines++; l.fullLine = " 'V' expand all"; drawLines.push_back(l); numInstructionLines++; #if defined USE_OFX_HISTORYPLOT l.fullLine = " 'P' plot selectd measur."; drawLines.push_back(l); numInstructionLines++; #endif } maxW = tempMaxW; ofSetupScreen(); //mmmm---- ofPushStyle(); ofSetRectMode(OF_RECTMODE_CORNER); ofSetDrawBitmapMode(OF_BITMAPMODE_SIMPLE); ofEnableAlphaBlending(); ofPushMatrix(); ofScale(uiScale,uiScale); ofFill(); //draw all plots #if defined(USE_OFX_HISTORYPLOT) //int numCols = plotsToDraw.size() float highest = FLT_MIN; for(auto plot : plotsToDraw){ if(allPlotsTogether){ //lets find the range that covers all the plots float high = plot->getHigerRange(); if (high > highest) highest = high; plot->setDrawTitle(false); plot->setDrawBackground(false); plot->setShowSmoothedCurve(false); }else{ plot->setDrawTitle(true); plot->setDrawBackground(true); plot->setLowerRange(0); plot->setShowSmoothedCurve(true); } } float canvasW = ofGetWidth(); float canvasH = ofGetHeight(); if(allPlotsTogether && plotsToDraw.size()){ ofSetColor(0, 230); ofDrawRectangle(0, canvasH - plotHeight, canvasW / uiScale, plotHeight); } for(int i = 0; i < plotsToDraw.size(); i++){ int y = (plotBaseY == 0 ? canvasH : plotBaseY) / uiScale - plotHeight * (i + 1); if(allPlotsTogether){ plotsToDraw[i]->setRange(0, highest); y = ((plotBaseY == 0 ? canvasH : plotBaseY) - plotHeight) / uiScale; } plotsToDraw[i]->draw(0, y, canvasW / uiScale, plotHeight); if(!allPlotsTogether){ ofSetColor(99); if(i != plotsToDraw.size() -1){ ofLine(0, y, canvasW / uiScale, y ); } } if(allPlotsTogether){ ofSetColor(plotsToDraw[i]->getColor()); deque<float>& vals = plotsToDraw[i]->getValues(); float val = 0.0f; if(!vals.empty()) val = vals.back(); string msg = plotsToDraw[i]->getVariableName() + " " + ofToString(val, 2); drawString(msg, canvasW - charW * msg.size() - 2, ofGetHeight() - plotHeight - 4 - charH * (plotsToDraw.size() -1 - i)); } } #endif float totalW = getWidth(); float totalH = getHeight(); //draw bg rect ofSetColor(bgColor); ofDrawRectangle(x, y + 1, totalW, totalH); //draw all lines for(int i = 0; i < drawLines.size(); i++){ ofSetColor(drawLines[i].lineBgColor); ofRectangle lineRect = ofRectangle(x, y + 2 + i * charH, totalW, charH + (drawLines[i].tm ? 0 : 1)); ofDrawRectangle(lineRect); if(drawLines[i].isAccum && drawLines[i].tm != NULL){ ofSetColor(drawLines[i].color, 128); ofDrawRectangle(x + totalW, y + 3 + i * charH, -5, charH - 1 ); } ofSetColor(drawLines[i].color); drawString(drawLines[i].fullLine, x , y + (i + 1) * charH); if(drawLines[i].plotColor.a > 0){ //plot highlight on the sides ofSetColor(drawLines[i].plotColor); float y1 = y + 2.4f + i * charH; ofDrawTriangle( x, y1, x, y1 + charH, x + charW * 0.7f, y1 + charH * 0.5f); } if(drawPercentageAsGraph && drawLines[i].shouldDrawPctGraph && drawLines[i].percentGraph > 0.02f){ float ww = charW * 5.5; float xx = lineRect.x + lineRect.width - charW * 7; float pct = MIN(drawLines[i].percentGraph, 1.0); unsigned char a = 64; ofColor gC; if(drawLines[i].percentGraph > 1.0){ gC = ofColor(255,0,0, (currentFrameNum%4 > 2) ? 1.5 * a : a); }else{ gC = ofColor(drawLines[i].lineBgColor, a) * (1.0f - pct) + ofColor(255,0,0,a) * pct; } ofSetColor(gC); ofDrawRectangle( xx, lineRect.y + 0.2 * lineRect.height , ww * pct, lineRect.height * 0.65 ); } } if(internalBenchmark){ float offset = 0; if(drawLocation == TIME_MEASUREMENTS_TOP_LEFT || drawLocation == TIME_MEASUREMENTS_TOP_RIGHT || drawLocation == TIME_MEASUREMENTS_CUSTOM_LOCATION ){ offset = (drawLines.size() + 2.5) * charH; } ofSetColor(0); ofDrawRectangle(x, offset + y - charH, totalW, charH); ofSetColor(currentFrameNum%3 ? 255 : 64); drawString(" Meas: " + ofToString(wastedTimeAvg / 1000.f, 2) + "ms " + " Draw: " + ofToString(wastedTimeDrawingAvg / 1000.f, 2) + "ms ", x, offset + y - charH * 0.12); } if (freeze) { if(currentFrameNum%5 < 4) ofSetColor(frozenColor); else ofSetColor(ofColor::white); drawString("Frozen! 'F'", x + totalW - 13 * charW, y + charH ); } {//lines ofSetColor(hilightColor); ofMesh lines; ofSetLineWidth(0.1); lines.setMode(OF_PRIMITIVE_LINES); float fuzzyFix = 0.5; float yy = y+1 + fuzzyFix; lines.addVertex(ofVec2f(x, yy)); lines.addVertex(ofVec2f(x + totalW, yy)); yy = y + totalH - charH - 3 + fuzzyFix; lines.addVertex(ofVec2f(x, yy)); lines.addVertex(ofVec2f(x + totalW, yy)); yy = y + totalH + fuzzyFix; lines.addVertex(ofVec2f(x, yy)); lines.addVertex(ofVec2f(x + totalW, yy)); if(menuActive){ yy = y + totalH + fuzzyFix - (numInstructionLines + 1) * charH - 3; lines.addVertex(ofVec2f(x, yy)); lines.addVertex(ofVec2f(x + totalW, yy)); yy = y + totalH + fuzzyFix - (numInstructionLines) * charH - 3; lines.addVertex(ofVec2f(x, yy)); lines.addVertex(ofVec2f(x + totalW, yy)); } lines.draw(); }//lines //print bottom line, fps and stuff bool missingFrames = ( fr < desiredFrameRate - 1.0 ); // tolerance of 1 fps TODO! static char msg[128]; sprintf(msg, "%2.1f fps % 5.1f%%", fr, percentTotal ); if(missingFrames){ ofSetColor(170,33,33); //reddish fps below desired fps }else{ ofSetColor(hilightColor); } int len = strlen(msg); string pad = " "; int diff = (maxW - len) - 1; for(int i = 0; i < diff; i++) pad += " "; int lastLine = ( drawLines.size() + 1 ) * charH + 2; drawString( pad + msg, x, y + lastLine ); //show activate menu key if(menuActive ) ofSetColor(hilightColor.getInverted()); else ofSetColor(hilightColor); drawString(" '" + ofToString(char(activateKey)) + "'", x, y + lastLine); //show averaging warning if (averaging) { if (currentFrameNum % 5 < 2) ofSetColor(hilightColor); else ofSetColor(ofColor::limeGreen); drawString(" avg!", x + charW * 3.5, y + lastLine); } for(int i = 0; i < toResetUpdatedLastFrameFlag.size(); i++){ toResetUpdatedLastFrameFlag[i]->updatedLastFrame = false; } ofPopMatrix(); ofPopStyle(); if(internalBenchmark){ wastedTimeDrawingThisFrame += TM_GET_MICROS() - timeNow; wastedTimeAvg = wastedTimeThisFrame * 0.025f + 0.975f * wastedTimeAvg; wastedTimeDrawingAvg = wastedTimeDrawingThisFrame * 0.025f + 0.975f * wastedTimeDrawingAvg; wastedTimeThisFrame = wastedTimeDrawingThisFrame = 0; } }
void scoreDraw::draw(){ //ofPushMatrix(); // ofTranslate(ofGetWidth()*.66, -ofGetHeight()*.4); // ofRotate(90,0,0,1); if(letter == "a" || letter == "A"){ for(int i = 0;i < path.size();i++){ ofFill(); ofSetColor(randomValues[i+4]*255,100); ofDrawTriangle( path[i].x, path[i].y+(100.0*randomValues[i+4]*randomValues[30]), path[i].x+(100.0*randomValues[i]), path[i].y+(200.0*randomValues[i+1]*randomValues[30]), path[i].x, path[i].y+(600.0*randomValues[i+2]*randomValues[30])); } //ofDrawEllipse(x, y, dim,dim); } else if(letter == "r" || letter == "R"){ float accumTri = 0; for(int i = 0;i < path.size();i++){ ofFill(); ofSetColor(randomValues[i]*255,randomValues[i+10]*255); float triSize = randomValues[i]*50; ofDrawTriangle( path[i].x, path[i].y+accumTri, path[i].x+(400.0*randomValues[i]*randomValues[30]), path[i].y+(triSize/2)+accumTri, path[i].x, path[i].y+(triSize)+accumTri); ofNoFill(); ofSetLineWidth(2); ofSetColor(255,200); ofDrawTriangle( path[i].x, path[i].y+accumTri, path[i].x+(400.0*randomValues[i]*randomValues[30]), path[i].y+(triSize/2)+accumTri, path[i].x, path[i].y+(triSize)+accumTri); accumTri+=triSize; } //ofDrawEllipse(x, y, dim,dim); }else if(letter == "v" || letter == "V"){ for(int i = 0;i < path.size();i++){ ofSetColor(255,(randomValues[70-i]*200)); float xNoise = randomValues[20]*300 * ofSignedNoise(ofGetFrameNum()*0.005+randomValues[i]*400); float yNoise = randomValues[29]*300 * ofSignedNoise(ofGetFrameNum()*0.0037+randomValues[i+10]*400); ofDrawEllipse(path[i].x+xNoise, path[i].y+yNoise, randomValues[90-i]*20, randomValues[90-i]*20); } }else if(letter == "t" || letter == "T"){ for(int i = 0;i < path.size();i++){ ofSetColor(255,(randomValues[70-i]*200)); float xNoise = randomValues[20]*300 * ofSignedNoise(ofGetFrameNum()*0.0003+randomValues[i]*400); float yNoise = randomValues[29]*300 * ofSignedNoise(ofGetFrameNum()*0.00357+randomValues[i+10]*400); ofDrawRectangle(path[i].x+xNoise+(i*100*randomValues[3]), path[i].y+yNoise, randomValues[90-i]*10, randomValues[90-i]*100); } }else if(letter == "s" || letter == "S"){ ofPushStyle(); ofSetLineWidth(2); ofNoFill(); ofSetColor(255,200); ofBeginShape(); for(int i = 0;i < path.size();i++){ ofSetColor(255,(randomValues[70-i]*200)); float xNoise = randomValues[20]*300 * ofSignedNoise(ofGetFrameNum()*0.0003+randomValues[i]*400); float yNoise = randomValues[29]*300 * ofSignedNoise(ofGetFrameNum()*0.00357+randomValues[i+10]*400); ofVertex(path[i].x+xNoise, path[i].y+yNoise); } ofEndShape(); ofPopStyle(); }else if(letter == "c" || letter == "C"){ ofPolyline quickU; ofPushStyle(); ofSetLineWidth(2); ofNoFill(); ofSetColor(255,200); for(int i = 0;i < path.size();i++){ ofSetColor(255,(randomValues[70-i]*200)); float xNoise = randomValues[20]*100 * ofSignedNoise(ofGetFrameNum()*0.053+randomValues[i]*400); float yNoise = randomValues[29]*100 * ofSignedNoise(ofGetFrameNum()*0.07+randomValues[i+10]*400); quickU.curveTo(path[i].x+xNoise, path[i].y+yNoise); } for(int i = 0;i < path.size();i++){ ofSetColor(255,(randomValues[70-i]*200)); float xNoise = randomValues[07]*200 * ofSignedNoise(ofGetFrameNum()*0.33+randomValues[i+9]*400); float yNoise = randomValues[9]*200 * ofSignedNoise(ofGetFrameNum()*0.51+randomValues[i+15]*400); quickU.curveTo(path[i].x+xNoise, path[i].y+yNoise); } quickU.draw(); ofPopStyle(); quickU.clear(); }else if(letter == "u" || letter == "U"){ ofPolyline quickU; ofPushStyle(); ofSetLineWidth(2); ofNoFill(); ofSetColor(255,200); for(int i = 0;i < path.size();i++){ ofSetColor(255,(randomValues[70-i]*200)); float xNoise = randomValues[20]*300 * ofSignedNoise(ofGetFrameNum()*0.0053+randomValues[i]*400); float yNoise = randomValues[29]*300 * ofSignedNoise(ofGetFrameNum()*0.007+randomValues[i+10]*400); quickU.curveTo(path[i].x+xNoise, path[i].y+yNoise); } for(int i = 0;i < path.size();i++){ ofSetColor(255,(randomValues[70-i]*200)); float xNoise = randomValues[20]*500 * ofSignedNoise(ofGetFrameNum()*0.0033+randomValues[i+9]*400); float yNoise = randomValues[29]*500 * ofSignedNoise(ofGetFrameNum()*0.0051+randomValues[i+15]*400); quickU.curveTo(path[i].x+xNoise, path[i].y+yNoise); } quickU.draw(); ofPopStyle(); quickU.clear(); }else if(letter == "g" || letter == "G"){ for(int j = 0;j < randomValues[3]*40;j++){ for(int i = 0;i < path.size();i++){ ofSetColor(255,(randomValues[70-i]*200)); ofDrawEllipse(path[i].x+(i*10.0*randomValues[9]), path[i].y+(j*40.0*randomValues[3]), randomValues[90]*20, randomValues[90]*20); } } }else if(letter == "i" || letter == "i"){ for(int j = 0;j < randomValues[3]*40;j++){ for(int i = 0;i < path.size();i++){ ofSetColor(255,(randomValues[70-i]*200)); ofDrawEllipse(path[i].x+(i*100.0*randomValues[9]), path[i].y+(j*400.0*randomValues[3]), randomValues[90]*5, randomValues[90]*5); } } }else if(letter == "o" || letter == "O"){ ofPushStyle(); ofSetCircleResolution(30); for(int i = 0;i < path.size();i++){ ofNoFill(); ofSetColor(255,(randomValues[70-i]*200)); float tempLineWidth = ofRandom(0,5); ofSetLineWidth(tempLineWidth); float tempRad = ofRandom(0,randomValues[60]*300); ofDrawCircle(x, y, tempRad); } ofPopStyle(); }else if(letter == "h" || letter == "H"){ for(int j = 0;j < randomValues[3]*10;j++){ for(int i = 0;i < path.size();i++){ ofSetColor(255,(randomValues[70-i]*200)); ofDrawEllipse(path[i].x+(i*40.0*randomValues[9]), path[i].y+(j*10.0*randomValues[3]), randomValues[90]*10, randomValues[90]*10); } } }else if(letter == "y" || letter == "Y"){ ofNoFill(); //ofSetLineWidth(ofRandom(1,9)); ofSetColor(255,200); ofBeginShape(); for(int i = 0;i < path.size();i++){ ofSetColor(255,(randomValues[70-i]*200)); ofCurveVertex((path[i].x)+ofRandom(-5,5)+(i*50*randomValues[21]),path[i].y+ofRandom(-30*randomValues[20],30*randomValues[6])); } for(int i = 0;i < path.size();i++){ ofSetColor(255,(randomValues[70-i]*200)); ofCurveVertex((path[i].x)+ofRandom(-5,5)+(i*20*randomValues[20]),path[i].y+ofRandom(-20*randomValues[9],20*randomValues[7])); } ofEndShape(); }else if(letter == "n" || letter == "N"){ for(int i = 0;i < path.size();i++){ ofSetColor(255,(randomValues[70-i]*200)); ofSetLineWidth(randomValues[i]*4); ofDrawLine(path[i].x+ofRandom(-5,5), path[i].y+(i*10*randomValues[5])+ofRandom(-5,5), path[i].x+((randomValues[50-i])*500+100)+ofRandom(-5,5), path[i].y+(i*10*randomValues[5])+ofRandom(-5,5)); } }else if(letter == "f" || letter == "F"){ for(int i = 0;i < path.size();i++){ ofSetColor(255,(randomValues[70-i]*200)); ofSetLineWidth(randomValues[i]*4); ofDrawLine(path[i].x, path[i].y+(i*10*randomValues[5]), path[i].x+((randomValues[50-i])*500+100), path[i].y+(i*10*randomValues[5])); } }else if(letter == "e" || letter == "E"){ for(int i = 0;i < path.size();i++){ ofSetColor(255,(randomValues[70-i]*200)); ofSetLineWidth(randomValues[i]*20); ofDrawLine(path[i].x, path[i].y+((randomValues[60-i]-0.5)*300), path[i].x+((randomValues[50-i])*500), path[i].y+((randomValues[60-i]-0.5)*300)); } }else{ ofSetColor(randomValues[0]*255,100); ofDrawEllipse(x, y, dim,dim); } //ofPopMatrix(); }
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 ofApp::draw(){ ofBackground(107,96,136); ofSetColor(255); ofSetLineWidth(1); //Hair (in retrospect I would have done it with a shape) ofDrawTriangle(50,270, 110,180, 90,340); ofDrawTriangle(110,180, 125,95, 175,100); ofDrawTriangle(175,100, 390,25, 450,75); ofDrawTriangle(450,75, 550,85, 565,220); ofDrawTriangle(565,220, 600,275, 575,275); ofDrawTriangle(600,275, 665,302, 620,325); ofDrawTriangle(620,325, 655,375, 600,350); ofDrawTriangle(600,350, 625,410, 580,395); ofDrawTriangle(580,395, 600,475, 565,445); ofDrawTriangle(565,445, 575,475, 525,455); ofDrawTriangle(525,455, 530,485, 505,465); ofDrawTriangle(505,465, 475,525, 475,445); ofDrawTriangle(475,445, 435,485, 450,400); ofDrawTriangle(450,400, 425,445, 437,417); ofDrawTriangle(437,417, 410,325, 420,325); ofDrawTriangle(410,325,//Start of bangs 420,405, 325,335); ofDrawTriangle(325,335, 360,415, 260,360); ofDrawTriangle(260,360, 295,427, 228,380); ofDrawTriangle(228,380, 225,430, 215,375); ofDrawTriangle(215,375, 140,330, 145,330); ofDrawTriangle(90,340,//END OF BANGS 90,485, 110,440); ofDrawTriangle(110,440, 160,535, 150,465); ofDrawTriangle(150,465, 178,510, 168,455); ofDrawTriangle(168,455, 175,585, 250,525); ofDrawTriangle(250,525, 250,610, 290,560); //hair coloring ofBeginShape(); ofVertex(90,340); ofVertex(140,330); ofVertex(145,330); ofVertex(215,375); ofVertex(228,380); ofVertex(260,360); ofVertex(325,335); ofVertex(410,325); ofVertex(420,325); ofVertex(437,417); ofVertex(450,400); ofVertex(475,445); ofVertex(505,465); ofVertex(525,455); ofVertex(565,445); ofVertex(580,395); ofVertex(600,350); ofVertex(620,325); ofVertex(600,275); ofVertex(565,220); ofVertex(450,75); ofVertex(175,100); ofVertex(110,180); ofVertex(50,270); ofEndShape(); ofBeginShape(); ofVertex(90,340); ofVertex(110,440); ofVertex(150,465); ofVertex(168,455); ofVertex(250,525); ofVertex(290,560); ofVertex(350,250); ofEndShape(); //face ofSetColor(255,254,227); ofBeginShape(); ofVertex(140,330); ofVertex(145,365); ofVertex(151,375); ofVertex(151,385); ofVertex(178,425); ofVertex(187,450); ofVertex(210,485); ofVertex(310,565); //TIP OF CHIN ofVertex(327,555); ofVertex(425,445); ofVertex(437,417); ofVertex(410,325); ofVertex(420,405); ofVertex(325,335); ofVertex(360,415); ofVertex(260,360); ofVertex(295,427); ofVertex(228,380); ofVertex(225,430); ofVertex(215,375); ofVertex(140,330); ofEndShape(); //Face lines ofSetColor(0); ofNoFill(); ofSetLineWidth(2); ofBeginShape(); ofVertex(140,330); ofVertex(145,365); ofVertex(151,375); ofVertex(151,385); ofVertex(178,425); ofVertex(187,450); ofVertex(210,485); ofVertex(310,565); //TIP OF CHIN ofVertex(327,555); ofVertex(425,445); ofVertex(437,417); ofVertex(410,325); ofVertex(420,405); ofVertex(325,335); ofVertex(360,415); ofVertex(260,360); ofVertex(295,427); ofVertex(228,380); ofVertex(225,430); ofVertex(215,375); ofVertex(140,330); ofEndShape(); ofFill(); //Eyelashes ofDrawTriangle(151,385, 142,395, 190,385); //Eye ofSetCurveResolution(50); ofSetColor(174,73,77); ofBeginShape(); ofCurveVertex(155,385); ofCurveVertex(155,385); ofCurveVertex(155,390); ofCurveVertex(173,415); ofCurveVertex(175,405); ofCurveVertex(173,392); ofCurveVertex(168,390); ofCurveVertex(168,390); ofEndShape(); //Eye lines ofSetColor(0); ofNoFill(); ofSetLineWidth(2); ofBeginShape(); ofCurveVertex(155,385); ofCurveVertex(155,385); ofCurveVertex(155,390); ofCurveVertex(173,415); ofCurveVertex(175,405); ofCurveVertex(173,392); ofCurveVertex(168,390); ofCurveVertex(168,390); ofEndShape(); ofFill(); //Pupil ofBeginShape(); ofCurveVertex(159,385); ofCurveVertex(159,385); ofCurveVertex(158,390); ofCurveVertex(168,405); ofCurveVertex(170,395); ofCurveVertex(170,395); ofEndShape(); //Eyelashes ofSetColor(0); ofDrawTriangle(151,385, 142,395, 210,380); //Eyebrow ofDrawTriangle(143,360, 185,355, 180,352); //Detail Eye Lines ofSetLineWidth(1); ofNoFill(); ofDrawCurve(140,400, 151,375, 200,372, 225,377); ofFill(); //Nose ofNoFill(); ofSetLineWidth(2); ofDrawCurve(185,325, 210,375, 185,450, 135,425); ofDrawCurve(150,445, 185,450, 215,465, 225,450); ofFill(); //Smile ofDrawCurve(225,475, 260,505, 275,500, 300,475); ofNoFill(); ofDrawCurve(300,475, 285,496, 330,465, 400,410); ofFill(); }