Esempio n. 1
0
void ofApp::draw() {
  ofSetWindowTitle(ofToString(ofGetFrameRate(), 0) + "FPS");

  if (drawParticles) {
    for (int i = 0; i < particles.size(); i++) {
      particles[i]->draw();
    }
  }

  if (drawSprings) {
    for (int i = 0; i < springs.size(); i++) {
      springs[i]->draw();
    }
  }

  // have selected a Particle: draw temporary Spring from Particle to mouse position
  if (selectedFirstParticle) {
    ofSetColor(ofColor::white);
    ofDrawLine(firstParticle->position, ofPoint(mouseX, mouseY));
  }
}
Esempio n. 2
0
//--------------------------------------------------------------
void ofApp::drawBranch(float length, float theta){
    
    ofDrawLine(0, 0, 0, -length);
    ofTranslate(0, -length);

    length = length*0.4;
    
    if(length<2){
        
        ofPushMatrix();
        ofRotate(theta);
        drawBranch(length, theta);
        ofPopMatrix();
        
        ofPushMatrix();
        ofRotate(-theta);
        drawBranch(length, theta);
        ofPopMatrix();
        
    }
}
Esempio n. 3
0
void ofxAVUISlider::draw(){
//this is here so we dont need to call update() every cycle
//    if (clicking && (ofGetElapsedTimeMillis() - doubleClickTimer > DOUBLECLICK_MILLIS)) {
//        x = mouseArgs.x;
//        ofParameter<float>  p1 = soundProperties->getFloat(param1);
//        float horizVal = ofMap(x, shape.x, shape.x + shape.width, p1.getMin(), p1.getMax());
//        p1 = horizVal;
//        clicking = false;
//    }
    if (synced) update();
    ofPushStyle();
    ofSetColor(bgColor);
    ofDrawRectangle(0,0,shape.width,shape.height);
    ofSetColor(fgColor);
    ofNoFill();
    drawContour();
    drawTitle();
    ofDrawLine(x-shape.x, 0, x-shape.x, shape.height);  //cursor
    if(soundProperties->getBool(paramBoolToggle)) ofDrawCircle(x - shape.x, shape.height/2,10); //draw toggle
    ofPopStyle();
}
Esempio n. 4
0
void ofApp::draw(){

    // Translate the origin point to the center of the screen
    ofTranslate(ofGetWidth()/2, ofGetHeight()/2);
    
    // Convert polar to cartesian
    float x = r * cos(theta);
    float y = r * sin(theta);
    

    ofSetLineWidth(2);
    ofSetColor(0);
    ofDrawLine(0,0,x,y);

    ofSetColor(127);
    ofDrawCircle(x, y, 24, 24);
    
    // Increase the angle over time
    theta += 0.02;
    
}
Esempio n. 5
0
void Renderer::draw()
{
	ofEnableDepthTest();
	ofDrawLine(0, 0, 500, 500);
	ofPushMatrix();
	//ofSetColor(ofColor::wheat);
	// inverser l'axe Y pour qu'il pointe vers le haut
	ofScale(1, 1);
	ofTranslate(500, 700);
	ofPushMatrix();
	increment += 1.5;
	ofRotate(increment, 0, 1, 0);
	ofTranslate(0,0);
	ofScale(1, 1, -1);
	//ofSetColor(ofColor::orange);
	//this->wolfModel->disableTextures();
	this->wolfModel->setPosition(0, 0, 0);
	this->wolfModel->drawWireframe();
	ofPopMatrix();
	ofPopMatrix();
}
Esempio n. 6
0
void ofApp::drawMousePosition(ofEventArgs&){

	ofPoint mPos(ofGetMouseX(), ofGetMouseY());

	std::string info;
	if(!dragging){
		info = "x: " + ofToString(mPos.x) + " y: " + ofToString(mPos.y);
	}else{
		ofSetColor(255,0,0);
		ofSetLineWidth(1);
		ofDrawLine(mPos, dragStart);
		info = ofToString((mPos-dragStart).length());
	}

	ofSetColor(255);
	ofFill();
	ofDrawRectangle(font.getBoundingBox(info, mPos.x +12, mPos.y + 30));

	ofSetColor(0);
	ofDrawBitmapString(info, mPos.x +12, mPos.y + 30);
}
Esempio n. 7
0
//--------------------------------------------------------------
void ofApp::audioSpecturmRight(){
    
    if ( bPlaying ) {
        ofPushStyle();
        ofSetColor(0, 255, 0, 255);
        for(int n=0; n<BIT; n++){
            int _yRatioLeft = (int)ofMap(n, 0, BIT - 1, 0, heightOnePixel);
            int _yRatioRight = (int)ofMap(n, 0, BIT - 1, 0, heightOnePixel);
            ofDrawRectangle( 0, _yRatioLeft, -ampNormalRight[n] * 30.0, 1 );
            ofDrawRectangle( 0, _yRatioRight, ampNormalRight[n] * 30.0, 1 );
        }
        ofPopStyle();
    }
    
    ofPushStyle();
    ofSetColor(0, 255, 0, 255);
    ofDrawLine( 0, 0, 0, heightOnePixel );
    ofPopStyle();
    
    
}
Esempio n. 8
0
//--------------------------------------------------------------
void ofApp::draw(){
    
    //draw the image
    myImage.draw(0,0);
//    count = 0;
    

    ofColor currentCol = myImage.getColor(ofGetMouseX(), ofGetMouseY());
    red = currentCol.r;
    green = currentCol.g;
    blue = currentCol.b;

    
    int width = myImage.getWidth();
    int height = myImage.getHeight();
    
    for(int i = 0; i < width; i++){
        for(int j = 0; j < height; j++){
                //checks all pixels color values
            ofColor pixColor = myImage.getColor(i,j);
             checkRed = pixColor.r;
             checkBlue = pixColor.b;
             checkGreen = pixColor.g;
             samePixelPosX = width;
             samePixelPosY = height;
            
            
            if(red == checkRed && green == checkGreen && blue == checkBlue){
                //cout << "1" << endl;
               // count++;
                //ofSetColor(checkRed,checkGreen,checkBlue);
                ofDrawLine(i,j,samePixelPosX,samePixelPosY);
                ofSetColor(checkRed,checkGreen,checkBlue);
            }
        }
    }
    cout << "count :"<<count << endl;
    ofSetBackgroundColor(currentCol);
}
Esempio n. 9
0
void ImageSynth::drawWireframe(){
    if (inputImage.getWidth() > 0) {
        ofPushMatrix();
        {
            ofTranslate(pos);
            ofRotateX(rot.x);
            ofRotateY(rot.y);
            ofRotateZ(rot.z);
            rot += rotSpeed;
            
            ofScale(1.0, 1.0, zscale);
            ofSetColor(255, 190);
            //inputImage.getTexture().bind();
            mesh.drawWireframe();
            //inputImage.getTexture().unbind();
            
            ofSetColor(255);
            float x = (ofGetFrameNum() - startFrame) % int(inputImage.getWidth()) - inputImage.getWidth()/2.0;
            ofDrawLine(x, -inputImage.getHeight()*1000, x, inputImage.getHeight()*1000);
        }
        ofPopMatrix();
    }
}
Esempio n. 10
0
void Node::draw(){
    if (ofGetElapsedTimef() > initTime) {
        ofPushMatrix();
        ofTranslate(location);
        for (int i = 0; i < nodeNum; i++) {
            float alpha = ofMap(generation, 0, 6, 255, 63);
            ofSetColor(255, alpha);
            ofDrawLine(ofVec3f(0, 0, 0), curLoc[i]);
            ofPushMatrix();
            ofTranslate(curLoc[i]);
            float size = ofMap(generation, 0, 6, 20, 1);
            billboardBegin();
            ofSetColor(0, 127, 255);
            ofDrawEllipse(0, 0, size, size);
            billboardEnd();
            ofPopMatrix();
        }
        for (int i = 0; i < nodes.size(); i++) {
            nodes[i].draw();
        }
        ofPopMatrix();
        
    }
}
Esempio n. 11
0
//--------------------------------------------------------------
void DroneAttack::drawAttackPosition(){

    
    cam.begin();

    ofEnableAlphaBlending();
    
    ofPushStyle();
    ofSetColor( ofColor(colorAttack) );
    for (int i=0; i<dronData.size(); i++) {
        ofVec3f _v = dronData[i].coord;
        
        float _ratio = ofMap(dronData[i].deathMax, 1, 30, 1.1, 1.2);
        
        ofDrawLine( _v, _v * _ratio );
    }
    
    ofPopStyle();
    
    ofDisableAlphaBlending();
    
    cam.end();

}
Esempio n. 12
0
	void draw()
	{
		// A sequence of lines can each drawn one by one.
		// ofLine(0, 0, 0, ofGetHeight());
		// ofLine(5, 0, 5, ofGetHeight());
		// ofLine(10, 0, 10, ofGetHeight());
		// ofLine(15, 0, 15, ofGetHeight());
		// ofLine(20, 0, 20, ofGetHeight());
		// ofLine(25, 0, 25, ofGetHeight());
		// ofLine(30, 0, 30, ofGetHeight());
		// ofLine(35, 0, 35, ofGetHeight());

		// ... and so on.

		// OR ... we can use a loop.

		ofSetColor(255);

		// Draw lines every 5 pixels while 'x' is less than the window width.
		for (int x = 0; x < ofGetWidth(); x += 5)
		{
			ofDrawLine(x, 0, x, ofGetHeight());
		}
	}
Esempio n. 13
0
void ofApp::draw_bg(){

    ofSetColor(0, 0, 0);
    float yy = canvas.height/2*0.8;
    ofDrawLine(indicator.x, +yy+10, indicator.x, +yy);
    ofDrawLine(indicator.x, -yy-10, indicator.x, -yy);
    ofDrawLine(0, +yy+10, 0, +yy);
    ofDrawLine(0, -yy-10, 0, -yy);

    ofDrawLine(          0,    -5,         0,      +5);
    ofDrawLine(  track_len,    -5, track_len,      +5);

    ofSetRectMode(OF_RECTMODE_CORNER);
    ofSetColor(255,255,0,255);
    ofFill();
    ofDrawRectangle(0, -yy, indicator.x, yy*2);

    // text sec
    ofSetColor(0);
    ofDrawBitmapString(ofToString(ofGetElapsedTimef()), indicator.x, yy+40);

}
Esempio n. 14
0
//--------------------------------------------------------------
void ofApp::drawPlayer(){
	
	
	// draw the (warped) player
	ofSetColor(255, 255, 255);
	playerScaleFactor = (float)(ofGetHeight() - unwarpedH)/(float)warpedH;
	player.draw(0, 0, playerScaleFactor*warpedW, playerScaleFactor*warpedH);
	
	// draw the center point, as a red cross
	ofSetColor(255,0,0);
	glEnable(GL_LINE_SMOOTH);
	ofEnableAlphaBlending();
	float f = playerScaleFactor;
	ofDrawLine((f*(warpedCx))-5, (f*(warpedCy)),   (f*(warpedCx))+5, (f*(warpedCy)));
	ofDrawLine((f*(warpedCx))  , (f*(warpedCy))-5, (f*(warpedCx)),   (f*(warpedCy))+5);
	ofDisableAlphaBlending();
	glDisable(GL_LINE_SMOOTH);
	
	
	// draw informational text about the app.
	ofSetColor(255,255,255);
	float ty = 10;
	float dy = 11;
	ofDrawBitmapString("BLOGGIE UNWARPER (OSX)",    10,ty+=dy);file://localhost/Users/golan/Desktop/OF61_106/apps/golan_of61_osx63/BloggieUnwarp/BloggieUnwarp.xcodeproj/
	ofDrawBitmapString("Made in OpenFrameworks",    10,ty+=dy);
	ofDrawBitmapString("By G.Levin & S.Bisker",     10,ty+=dy);
	ty+=dy;
	
	ofSetColor(255,0,0);
	ofDrawBitmapString("Drag cross or use",                  10, ty+=dy);
	ofDrawBitmapString("arrow keys to recenter.",            10, ty+=dy);
	ofDrawBitmapString("Other key commands:",                 10, ty+=dy);
	ofDrawBitmapString("'s' to Save settings.",                 10, ty+=dy);
	ofDrawBitmapString("'r' to Restore settings.",              10, ty+=dy);
	ofDrawBitmapString("'v' to export Video.",                  10, ty+=dy);
	ofDrawBitmapString("cx: "   + ofToString((warpedCx)),    10, ty+=dy);
	ofDrawBitmapString("cy: "   + ofToString((warpedCy)),    10, ty+=dy);
	ofDrawBitmapString("rot:"   + ofToString((angularOffset)), 10, ty+=dy);
	
	
	/*
	if (bSavingOutVideo){
		ofSetColor(255,255,100);
		
		float pos = player.getPosition(); // nWrittenFrames
		ofDrawBitmapString("SAVING VIDEO to:",				10, playerScaleFactor*warpedH - 20);
		int currF = player.getCurrentFrame();
		int nF    = player.getTotalNumFrames();
		sprintf(handyString, "data/%s (%d/%dF / %1.1f%c)...", outputFileName.c_str(), currF,nF, (pos*100.0), '%');
		ofDrawBitmapString(handyString,						10, playerScaleFactor*warpedH - 10);
	} else {
		ofSetColor(200,200,200);
		
		sprintf(handyString, "Codec (-/+): %s", (videoRecorder->getCodecName(currentCodecId)).c_str());
		ofDrawBitmapString("Press 'v' to export video.",	10, playerScaleFactor*warpedH - 10);
		ofDrawBitmapString(handyString,			            10, playerScaleFactor*warpedH - 20);
	}
	 */
	
	
}
void Spring::draw() {
	ofSetColor(ofColor::white);
	ofDrawLine(first->position, second->position);
}
Esempio n. 16
0
void CalendarWidget::draw()
{
    ofFill();
    ofSetColor(0, 200);

    ofDrawRectangle(_window);

    std::string formatStringHourMin = "%h:%M %A";
    std::string formatStringHour = "%h:%M";
    std::string formatStringHourMinSec = "%h:%M:%S %A";

    Poco::LocalDateTime minTime(_windowInterval.getStart());
    Poco::LocalDateTime maxTime(_windowInterval.getEnd());

    Poco::LocalDateTime startQuarter = Utils::ceiling(minTime, Poco::Timespan::MINUTES * 5);

    ofPushMatrix();
    ofTranslate(_window.getPosition());

    std::vector<Poco::Timestamp> hours = Utils::getInstances(startQuarter.utc().timestamp(),
                                                             maxTime.utc().timestamp(),
                                                             Period(Period::MINUTE, 5));

    std::vector<Poco::Timestamp>::const_iterator hourIter = hours.begin();

    while (hourIter != hours.end())
    {
        Poco::DateTime time = Poco::DateTime(*hourIter);

        int y = _window.getHeight() * _windowInterval.map(time.timestamp());

        int minute = time.minute();

        float alpha = ofMap(std::abs(_windowInterval.map(time.timestamp()) - 0.5), 0, .2, .25, 1, true);

        if (0 == minute)
        {
            ofSetColor(255, 80 * alpha);
            ofDrawLine(0, y, _window.getWidth(), y);
        }
        else if (0 == minute % 15)
        {
            ofSetColor(255, 255, 0, 80 * alpha);
            ofDrawLine(0, y, _window.getWidth(), y);
        }
        else
        {
            ofSetColor(127, 80 * alpha);
            ofDrawLine(0, y, _window.getWidth(), y);
        }

        std::string label = Utils::format(Poco::LocalDateTime(time), formatStringHourMinSec);

        int width = _font.stringWidth(label);
        int height = _font.stringHeight(label);

        if (y - height - 4 > 0)
        {
            _font.drawString(label, _window.getWidth() - width - 4, y - 4);
        }

        ++hourIter;
    }

    int y = _window.getHeight() * _windowInterval.map(_now);

    ofSetColor(255);
    ofDrawLine(0, y, _window.getWidth(), y);

    std::string label = Utils::format(Poco::LocalDateTime(_now), formatStringHourMinSec);

    int width = _font.stringWidth(label);

    _font.drawString(label, _window.getWidth() - width - 4, y - 4);

    std::sort(_currentEvents.begin(), _currentEvents.end());


    ICalendar::EventInstances::const_iterator iter = _currentEvents.begin();

    int x = 0;

    while (iter != _currentEvents.end())
    {
        const ICalendarEvent& event = (*iter).getEvent();
        const Interval& interval = (*iter).getInterval();

        if (_windowInterval.intersects(interval))
        {
            int y0 = _window.getHeight() * _windowInterval.map(interval.getStart());
            int y1 = _window.getHeight() * _windowInterval.map(interval.getEnd());

            ofFill();
            ofSetColor(255, 50);

            if (interval.contains(_now))
            {
                ofSetColor(255, 255, 0, 50);
            }
            else
            {
                ofSetColor(255, 50);
            }


            ofDrawRectRounded(x, y0, 80, y1 - y0, 5);

            ofNoFill();
            ofSetColor(127);
            ofDrawRectRounded(x, y0, 80, y1 - y0, 5);

            ofSetColor(255);
            ofDrawRectRounded(x-1, y0-1, 80+2, y1 - y0+2, 5);


            std::string startLabel = Utils::format(Poco::LocalDateTime(interval.getStart()), formatStringHour);
            std::string endLabel = Utils::format(Poco::LocalDateTime(interval.getEnd()), formatStringHour);

            ofFill();
            ofSetColor(255);
            _font.drawString(event.getSummary(), x + 5, y0 + 10);
            _font.drawString(startLabel,         x + 5, y0 + 20);
            _font.drawString(endLabel,           x + 5, y0 + 30);
            
            x+= 84;
            
            if (x > _window.getWidth() - 160) x = 0;
            
        }
        
        ++iter;
    }
    
    ofPopMatrix();
}
Esempio n. 17
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();
}
Esempio n. 18
0
//--------------------------------------------------------------
void ofApp::draw(){
    
    ofSetColor(255);
    
    
    
    mCam.begin();
    
    
    ofPushStyle();
    ofEnableDepthTest();
    earthTexture.bind();
    mSphereMesh.draw();
    earthTexture.unbind();

    
    ofSetColor(tokyoCl);
    ofDrawSphere(tokyoPos.x, tokyoPos.y, tokyoPos.z, 1.0);
    ofSetColor(sydneyCl);
    ofDrawSphere(sydneyPos.x, sydneyPos.y, sydneyPos.z, 1.0);
    
    ofDisableDepthTest();
    ofPopStyle();
    
    ofVec3f upVec = ofVec3f(0,1,1);
    
    ofVec3f camVec = ofVec3f(0,0,0)-mCam.getGlobalPosition();
    
    mCam.end();
    
    
    
    gui.draw();
    
    ofVec3f gPos = mCam.getGlobalPosition();
    ofVec3f upDir = mCam.getUpDir()*20.0;
    ofVec3f lookAtDir = mCam.getLookAtDir()*20.0;
    
    ofPushStyle();
    ofPushMatrix();
    
    
    //draw y-z plane
    
    {
        float scale = 0.4;
        float sRadius = earth_radius*scale;
        ofVec2f panelCenter;
        ofVec2f panelLeftTop;
        float panelWidh, panelHeight;
        panelCenter.x = ofGetWindowWidth()*0.85;
        panelCenter.y = ofGetWindowHeight()*0.85;
        panelLeftTop.x = 0-(sRadius*4.0);
        panelLeftTop.y = -(sRadius*4.0);
        panelWidh = panelHeight= sRadius*8.0;
        
        
        //draw base
        ofTranslate(panelCenter.x,panelCenter.y);
        ofSetColor(64, 64, 64,64);
        ofDrawRectangle(panelLeftTop.x,panelLeftTop.y,panelWidh,panelHeight);
        
        //draw earth
        ofSetColor(255, 255, 255);
        ofNoFill();
        ofDrawCircle(0, 0, sRadius);
        
        //draw camera
        ofFill();
        ofDrawCircle(camPos.z*scale, -1*camPos.y*scale, 3.0);
        
        //draw tokyo and sydney
        ofSetColor(tokyoCl);
        ofDrawCircle(tokyoPos.z*scale, -1*tokyoPos.y*scale, 3.0);
        ofSetColor(sydneyCl);
        ofDrawCircle(sydneyPos.z*scale, -1*sydneyPos.y*scale, 3.0);
        
        //draw upDir
        ofPushMatrix();
        ofTranslate(camPos.z*scale, -1*camPos.y*scale);
        ofSetColor(255,0, 0);
        ofDrawLine(0, 0, upDir.z,-1*upDir.y);
        //draw lookAtDir
        ofSetColor(255);
        ofDrawLine(0,0,lookAtDir.z, -1*lookAtDir.y);
        ofPopMatrix();
        
        //draw Euler
        ofVec3f camEuler = mCam.getOrientationEuler();
        float rectwScale = 0.5;
        float barHeight = 5.0;
        ofPushMatrix();
        ofTranslate(panelLeftTop.x,panelLeftTop.y);
        ofSetColor(255);
        ofDrawBitmapString("cam eulerX:" + ofToString(camEuler.x),2,10);
        ofDrawRectangle(panelWidh*0.5, 12, camEuler.x*rectwScale , barHeight);
        ofDrawBitmapString("cam eulerY:" + ofToString(camEuler.y),2,30);
        ofDrawRectangle(panelWidh*0.5, 32, camEuler.y*rectwScale , barHeight);
        ofDrawBitmapString("cam eulerZ:" + ofToString(camEuler.z),2,50);
        ofDrawRectangle(panelWidh*0.5, 52, camEuler.z*rectwScale , barHeight);
        ofPopMatrix();
        
    }
    ofPopMatrix();
    ofPopStyle();


    
    ofDrawBitmapStringHighlight("x,y,z: " + ofToString(gPos.x)+","+ofToString(gPos.y)+","+ofToString(gPos.z), 10, ofGetWindowHeight()-20);
    ofDrawBitmapStringHighlight("upDir x,y,z: " + ofToString(mCam.getUpDir().x)+","+ofToString(mCam.getUpDir().y)+","+ofToString(mCam.getUpDir().z), 10, ofGetWindowHeight()-40);
    ofDrawBitmapStringHighlight("mCam orientation x,y,z: " + ofToString(mCam.getOrientationEuler().x)+","+ofToString(mCam.getOrientationEuler().y)+","+ofToString(mCam.getOrientationEuler().z), 10, ofGetWindowHeight()-60);

}
Esempio n. 19
0
void Path::drawLine() {
    ofSetColor(0, 0, 0);
    ofSetLineWidth(4);
    ofDrawLine(x1, y1, x2, y2);

}
Esempio n. 20
0
void veraFscene::drawf2()
{
    ofDrawLine(0, 0, 0, sizeOfF - margin);
    ofDrawLine(0, sizeOfF - margin, sizeOfF - margin, sizeOfF - margin);
    ofDrawLine(0, (sizeOfF - margin)/2.0, sizeOfF - margin, (sizeOfF - margin)/2.0);
}
Esempio n. 21
0
//--------------------------------------------------------------
void ofApp::draw(){
    
    ofBackground(0);
    ofSetColor(255); // white color for saved polylines
    for (int i = 0; i < polylines.size(); i++) {
        ofPolyline polyline = polylines[i];
        polyline.draw();
        
//        // draw a circle at each vertex
//        vector<ofVec3f> vertices = polyline.getVertices();
//        for (int vertexIndex = 0; vertexIndex < vertices.size(); vertexIndex++) {
//            ofVec3f vertex = vertices[vertexIndex];
//            ofDrawCircle(vertex, 5);
//        }
        
//        // draw evenly spaced circles (10% distance between)
//        for (int i = 0; i < 100; i += 10) {
//            ofVec3f point = polyline.getPointAtPercent(i / 100.0); // Returns a point at a percentage along the polyline
//            ofDrawCircle(point, 5);
//        }
        
//        // draw normals at each vertex
//        vector<ofVec3f> vertices = polyline.getVertices();
//        float normalLength = 50;
//        for (int vertexIndex = 0; vertexIndex < vertices.size(); vertexIndex++) {
//            ofVec3f vertex = vertices[vertexIndex];
//            ofVec3f normal = polyline.getNormalAtIndex(vertexIndex) * normalLength; // scale the normal
//            ofDrawLine(vertex - normal / 2, vertex + normal / 2); // center the scaled normal around the vertex
//        }
        
//        // draw a lot of evenly spaced normals
//        float numPoints = polyline.size();
//        float normalLength = 50;
//        ofSetColor(255, 100);
//        for (int i = 0; i < 500; i += 1) {
//            ofVec3f point = polyline.getPointAtPercent(i / 500.0);
//            float floatIndex = i / 500.0 * (numPoints - 1);
//            ofVec3f normal = polyline.getNormalAtIndexInterpolated(floatIndex) * normalLength;
//            ofDrawLine(point - normal / 2, point + normal / 2);
//        }
        
//        // draw a tangent at each vertex
//        vector<ofVec3f> vertices = polyline.getVertices();
//        float tangentLength = 80;
//        for (int vertexIndex = 0; vertexIndex < vertices.size(); vertexIndex++) {
//            ofVec3f vertex = vertices[vertexIndex];
//            ofVec3f tangent = polyline.getTangentAtIndex(vertexIndex) * tangentLength;
//            ofDrawLine(vertex - tangent / 2, vertex + tangent / 2);
//        }
        
        int numPoints = polyline.size();
        float plLength = polyline.getPerimeter();
        cout << "plLength: " << plLength << endl;
        cout << "numPoints: " << numPoints << endl;
        float tangentLength = 300;
        ofSetColor(255, 100);
        for (int i = 0; i < floor(plLength); i += 10) {
            ofVec3f point = polyline.getPointAtPercent(i / plLength);
            float floatIndex = i / plLength * (numPoints - 1);
            ofVec3f tangent = polyline.getTangentAtIndexInterpolated(floatIndex) * tangentLength;
            ofDrawLine(point - tangent / 2, point + tangent / 2);
        }
    }
    ofSetColor(255, 100, 0); // orange color for active polyline
    currentPolyline.draw();

}
Esempio n. 22
0
//--------------------------------------------------------------
void ofApp::draw(){
	ofBackgroundGradient(ofColor(245), ofColor(200));
	//ofSetLineWidth(1);
	
	//The following is just to print the instructions to the screen.
	ofSetColor(80);
	ofDrawBitmapString("Click here to add horizontal oscillators.", LEFT_MARGIN +100, TOP_MARGIN-5 );
	
	ofDrawBitmapString("Click and drag\nover an\noscillator to\nmodify it's\nspeed and\namplitude", 15,25);
	ofDrawBitmapString("Click in this area and drag upwards/downwards to scale up/down.\nPress spacebar to delete all the oscillators.", LEFT_MARGIN + 200, ofGetHeight()-40);
	
	//All this bunch is to print the vertical text
	ofPushMatrix();
	ofTranslate(LEFT_MARGIN -5,  ofGetHeight() - 100, 0);
	ofRotate(-90, 0, 0, 1);
	ofDrawBitmapString("Click here to add vertical oscillators.",  0, 0 );
	ofPopMatrix();
	
	
	
	
	ofEnableSmoothing();
	
	//This are just the reference lines draw in the screen.
	ofSetColor(0, 0, 0, 150);
	ofDrawLine(LEFT_MARGIN, 0, LEFT_MARGIN, ofGetHeight());
	ofDrawLine(0, TOP_MARGIN, ofGetWidth(), TOP_MARGIN);
	
	ofSetColor(0, 0, 0, 80);
	ofDrawLine(LEFT_MARGIN, center.y, ofGetWidth(), center.y);
	ofDrawLine(center.x, TOP_MARGIN, center.x, ofGetHeight());
	
	//ofSetLineWidth(2);
	
	
	float horWave = 0;
	float vertWave = 0;
	
	//here we go through all the horizontal oscillators
	for (unsigned int i=0; i<horizontalOscilators.size(); i++) {
		ofSetColor(255, 127+i, 0,150);
		horizontalOscilators[i].draw(); //we draw each oscillator
		horWave += horizontalOscilators[i].waveSin;
		//THIS IS IMPORTANT. Here we are adding together all the current sine values of each oscillator.
		// This is what is creates all the crazy motion that we get.
	}
	//the same as above but for vertical oscillators
	for (unsigned int i=0; i<verticalOscilators.size(); i++) {
		ofSetColor(0, 127+i, 255, 150);
		verticalOscilators[i].draw();
		vertWave += verticalOscilators[i].waveSin;
	}
	//here we move all the elements of the array one position forward so to make space for a new value.
	for (int i=1; i<TAIL_LENGTH; i++) {
		waveHistory[i-1] = waveHistory[i];
	} 
	for (int i=1; i<WAVEFORM_HISTORY; i++) {
		horWaveHistory[i-1] = horWaveHistory[i];
		vertWaveHistory[i-1]= vertWaveHistory[i];
	}
	// here we save into our history
	horWaveHistory[WAVEFORM_HISTORY-1] = horWave;
	vertWaveHistory[WAVEFORM_HISTORY-1] = vertWave;
	waveHistory[TAIL_LENGTH-1] = ofVec3f(horWave, vertWave,0);
	
	
	
	ofMesh wave; // declaring a new ofMesh object with which we're drawing the motion path created by summing the vertical and horizontal oscillators
	wave.setMode(OF_PRIMITIVE_LINE_STRIP);
	for (int i=0; i<TAIL_LENGTH; i++) {
		wave.addColor(ofFloatColor(0.1f,0.1f,0.1f, 0.5f + 0.5f * i/float(TAIL_LENGTH) ));
		wave.addVertex(waveHistory[i]);
	}
	
	//all the following is to create and populate the horizontal and vertical waveforms.
	ofMesh hWave;
	hWave.setMode(OF_PRIMITIVE_LINE_STRIP);
	ofMesh vWave;
	vWave.setMode(OF_PRIMITIVE_LINE_STRIP);
	for (int i=0; i<WAVEFORM_HISTORY; i++) {
		hWave.addColor(ofFloatColor(255, 240,10, 255));
		hWave.addVertex(ofVec3f(i*hWaveMult, horWaveHistory[i]*0.1f*scale, 0));
		vWave.addColor(ofFloatColor(255, 240,10, 255));
		vWave.addVertex(ofVec3f(vertWaveHistory[i]*0.1f*scale, i*vWaveMult, 0));
	}
	
	//draw the vertical and horizontal wave.
	ofPushMatrix();
	ofTranslate(LEFT_MARGIN, TOP_MARGIN, 0);
	hWave.draw();
	vWave.draw();
	ofPopMatrix();
	
	//draw the composite wave.
	ofPushMatrix();
	ofTranslate(center.x, center.y, 0);
	ofScale(scale, scale, 0);
	wave.draw();
	ofSetColor(0,10, 255),
	ofDrawCircle(horWave, vertWave, 10);
	ofPopMatrix();
	
}
Esempio n. 23
0
void ofApp::draw() {
    
    ofBackground(0.0, 0.0, 0.0);
    
    ofSetColor(255.0,255.0,255.0);
    ofFill();
    for (int i = 0; i < 10; i++) {
        ofDrawBitmapString(verbalInstructions[i], 10, (i*20)+600);
    }
    
    if (cameraInfoIsOn) {
        ofSetColor(255.0, 255.0, 255.0);
        ofFill();
        
        /* drawing cameras */
        ofSetColor(255.0,0.0,0.0);
        ofDrawBitmapString("Active column", 10, 30+10);
        ofSetColor(0.0,0.0,255.0);
        ofDrawBitmapString("Active camera #", 10, 50+10);
        ofSetColor(255,105,180);
        ofDrawBitmapString("# of Pedestrians", 10, 60+20);
        ofSetColor(255.0, 255.0, 255.0);
        int cnt = 0;
        for (int i = 300-70; i <= 300+700; i+=70) {
            if (cnt == 4 || cnt == 5 ) {
                ofSetColor(cameraColor1);
                ofDrawBitmapString("["+ofToString(cnt+1)+"]", i+22, 50+10);
                ofSetColor(255,105,180);
                ofDrawBitmapString((int)micLevelsTopNew[cnt], i+35, 60+10);
                cout << i+35 << endl;
                ofSetColor(255.0, 255.0, 255.0);
            } else {
                if (simulationIsOn) {
                    ofSetColor(255,105,180);
                } else {
                    ofSetColor(100,100,100);
                }
                ofDrawBitmapString((int)micLevelsTopNew[cnt], i+35, 60+10);
                cout << i+35 << endl;
                ofSetColor(255.0, 255.0, 255.0);
                ofDrawBitmapString("["+ofToString(cnt+1)+"]", i+22, 50+10);
            }
            cnt++;
        }
        cout << "" << endl;
        
        /* Draw Columns */
        cnt = 0;
        ofFill();
        ofSetColor(100.0, 100.0, 100.0);
        for (int i = 300; i <= 300+700; i+=70) {
            if (cnt == 4) {
                ofSetColor(columnColor);
                ofDrawCircle(i, 45, 7);
                ofSetColor(100.0, 100.0, 100.0);
            } else {
                ofDrawCircle(i, 45, 7);
            }
            cnt++;
        }
        int max_pos = 0;
        int max_element = -1000;
        for (int i = 0; i < 12; i++) {
            if (micLevelsTopNew[i] > max_element) {
                max_pos = i;
                max_element = micLevelsTopNew[i];
            }
        }
        //ofVec2f btm = absColumnPositionTop[max_pos];
        ofVec2f btm = cameraPositionsTop[max_pos];
        ofVec2f desired =  btm - swarmPosition;
        float d = sqrt((desired.x*desired.x) + (desired.y+desired.y));
        float r = ofMap(ofClamp(d, 0.0, 700.0), 0.0, 700.0, 25.0, 76.5);
        ofColor swarmColor = ofColor(255.0, 0.0, 255.0);
        ofSetColor(swarmColor);
        ofDrawRectangle(swarmPosition.x, 45, 10, 50);
        ofSetColor(columnColor);
        ofFill();
        ofDrawCircle(578, 270, 14);
    
        
        for (int i = 0; i < contourFinder.nBlobs; i++){
            contourFinder.blobs[i].draw(238, 150);
            
            ofSetColor(255);
            if(contourFinder.blobs[i].hole){
                ofDrawBitmapString("hole",
                                   contourFinder.blobs[i].boundingRect.getCenter().x + 360,
                                   contourFinder.blobs[i].boundingRect.getCenter().y + 540);
            }
        }
        ofNoFill();
        ofSetColor(cameraColor1);
        ofDrawBitmapString("Camera 5", 238, 140);
        ofDrawRectangle(238, 150, 340, 240);
        ofSetColor(255,255,255,50.0);
        colorImg.draw(238, 150);

        
        for (int i = 0; i < contourFinder1.nBlobs; i++){
            contourFinder1.blobs[i].draw(578, 150);
            
            // draw over the centroid if the blob is a hole
            ofSetColor(255);
            if(contourFinder1.blobs[i].hole){
                ofDrawBitmapString("hole",
                                   contourFinder1.blobs[i].boundingRect.getCenter().x + 360,
                                   contourFinder1.blobs[i].boundingRect.getCenter().y + 540);
            }
        }
        ofNoFill();
        ofSetColor(cameraColor2);
        ofDrawBitmapString("Camera 6", 578, 140);
        ofDrawRectangle(578, 150, 340, 240);
        ofSetColor(255,255,255,50.0);
        colorImg1.draw(578, 150);
    }
    
    ofEnableLighting();
    pointLight.enable();
    material.begin();
    ofPushMatrix();
    cam.begin();
    peopleMaterial.begin();
    if (simulationIsOn) {
        for (int i = 0; i < 20; i++) {
            ofSpherePrimitive cyl;
            cyl.setPosition(spheresXPos[i]+=ofRandom(1.5), spheresZPos[i], 10.9297);
            cyl.set(10, 10);
            cyl.draw();
            if (spheresXPos[i] >= 0.0) {
                spheresXPos[i] = ofRandom(result["region0"]["ring0"]["point0"][0].asFloat()-500, result["region0"]["ring0"]["point0"][0].asFloat()+500.0);
            }
        }
    }
    peopleMaterial.end();
    ofSetColor(100.0);
    ofFill();
    
    int ct = 0;
    for (int region = 0; region < 3; region++) {
        string reg = "region" + ofToString(region);
        for (int pointPos = 0; pointPos < 4; pointPos++) {
            if (region == 1 && pointPos == 3) {
            } else {
                string point = "point" + ofToString(pointPos);
                ofCylinderPrimitive cyl;
                cyl.setPosition(columnGeometry[reg][point][0].asFloat(), columnGeometry[reg][point][1].asFloat(), columnGeometry[reg][point][2].asFloat()-90);
                cyl.set(2.0, 130.0);
                cyl.rotate(90, ofVec3f(1.0, 0.0, 0.0));
                if (ct == 4) {
                    columnMaterial.begin();
                    cyl.draw();
                    columnMaterial.end();
                } else {
                    cyl.draw();
                }
                ct++;
            }
        }
    }
    material.end();
    ofDisableLighting();


    newDrawRegion(gaussianBottom, 0, 3, false);
    
    ofSetColor(155.0, 155.0, 155.0);
    ofFill();
    for (int face = 0; face < 5; face++) {
        string fac = "face" + ofToString(face);
        ofPoint p1;
        ofPoint p2;
        ofPoint p3;
        ofPoint p4;
        p1.set(ofVec3f(faceGeometry[fac]["point0"][0].asFloat(),faceGeometry[fac]["point0"][1].asFloat(),faceGeometry[fac]["point0"][2].asFloat()));
        p2.set(ofVec3f(faceGeometry[fac]["point1"][0].asFloat(),faceGeometry[fac]["point1"][1].asFloat(),faceGeometry[fac]["point1"][2].asFloat()));
        p3.set(ofVec3f(faceGeometry[fac]["point2"][0].asFloat(),faceGeometry[fac]["point2"][1].asFloat(),faceGeometry[fac]["point2"][2].asFloat()));
        p4.set(ofVec3f(faceGeometry[fac]["point3"][0].asFloat(),faceGeometry[fac]["point3"][1].asFloat(),faceGeometry[fac]["point3"][2].asFloat()));
        ofDrawLine(p1, p2);
        ofDrawLine(p2, p3);
        ofDrawLine(p3, p4);
        ofDrawLine(p4, p1);
    }
    cam.end();
    ofPopMatrix();

    sendToDMX();
    
    vector<ofVideoDevice> devices = vidGrabber.listDevices();

    
    //ofDrawBitmapString(pcCams[0], 400, 50);
    //ofDrawBitmapString(pcCams[1], 400, 100);
}
Esempio n. 24
0
//--------------------------------------------------------------
void ofApp::draw(){
    
    ofPushStyle();
    ofSetColor(255, 255);
    domPanorama.draw(0, 0);
    ofSetColor(0, 255, 255, 180);
    panorama360_line.draw(0, 0);
    ofPopStyle();
    //    panoramaLineDraw();
    
    ofPushStyle();
    ofSetColor(0, 255, 0, 255);
    ofDrawLine(movXRight, 0, movXRight, heightForLandscape);
    ofDrawLine(movXLeft, 0, movXLeft, heightForLandscape);
    ofPopStyle();
    
    
    ofPushMatrix();
    
    ofPushMatrix();
    ofTranslate( movXLeft - widthOnePixel * 0, ofGetHeight() - heightOnePixel );
    audioSpecturmLeft();
    ofPopMatrix();
    
    ofPushMatrix();
    ofTranslate( movXLeft - widthOnePixel * 2, ofGetHeight() - heightOnePixel );
    onePixelDrawLeft();
    ofPopMatrix();

    
    
    ofPushMatrix();
    ofTranslate( movXRight + widthOnePixel * 0, ofGetHeight() - heightOnePixel );
    audioSpecturmRight();
    ofPopMatrix();
    
    ofPushMatrix();
    ofTranslate( movXRight + widthOnePixel * 1, ofGetHeight() - heightOnePixel );
    onePixelDrawRight();
    ofPopMatrix();
    
//    ofPushMatrix();
//    ofTranslate( movXRight + widthOnePixel * 2, ofGetHeight() - heightOnePixel );
//    onePixelSortDrawRight();
//    ofPopMatrix();
    
    ofPopMatrix();
    
    
    //    ofPushMatrix();
    //    ofTranslate(ofGetWidth() * 0.5 + widthOnePixel*2, ofGetHeight()-heightOnePixel );
    //    lineonePixelDrawRight();
    //    ofPopMatrix();
    
    
    ofDrawBitmapString( ofToString(ofGetFrameRate(),1), 10, ofGetHeight() - 10 );
    
    //    connectionLineDraw();
    
    
}
Esempio n. 25
0
void nebulaEye::draw()
{
  int w=ofGetWidth(), h=ofGetHeight();
  if ( ( ofGetHeight() > 0 && img.getHeight() > 0 ) ) {
    if ( ofGetWidth()/ofGetHeight() > img.getWidth()/img.getHeight()){
      h = ofGetHeight();
      w = h * img.getWidth()/img.getHeight();
    } else if (img.getWidth()>0){
      w = ofGetWidth();
      h = w * img.getHeight()/img.getWidth();
    }
  }
    
  ofSetColor(255,255,255);
  if(showVideo){
    if (mouseTest){
      ofxCv::drawMat(testimg,0,0);
    } else {
      video.draw(0,0,w,h);
    }
  }
  if(showBgSub){
    ofSetColor(255,255,255,bgSubIntensity);
    bgSub.draw(0,0,w,h);
  }

  if(showFlow){
    ofSetColor(0,255,0,255);
    flow.draw(0,0,w, h);
  }

  if(showContour){
    ofSetColor(255,255,255);
    contour.draw(0,0,w,h);
  }

  if(showZone){
    ofSetColor(255,0,0,64);
    zone.draw();
  }

  if (showDebug){
    ofSetColor(255);
    int i = showDebug.get()-1;
    if ( i < zone.mask.size() ){
      ofRectangle rect = ofRectangle(zone.mask[i].cols/2,zone.mask[i].rows/2, zone.mask[i].cols, zone.mask[i].rows);
      ofxCv::drawMat(zone.mask[i],rect.x, rect.y);
      cv::Mat m_flow;
      double zoneFlow = flow.getFlowInMask(zone.mask[i], &m_flow);
      ofVec2f offset(rect.x,rect.y);
      ofVec2f scale(rect.width/m_flow.cols, rect.height/m_flow.rows);
      int stepSize = 4;
      ofPopStyle();
      ofSetColor(0,255,0);
      for(int y = 0; y < m_flow.rows; y += stepSize) {
        for(int x = 0; x < m_flow.cols; x += stepSize) {
          ofVec2f cur = ofVec2f(x, y) * scale + offset;
          const cv::Vec2f& vec = m_flow.at<cv::Vec2f>(y, x);
          ofDrawLine(cur, ofVec2f(x + vec[0], y + vec[1]) * scale + offset);
        }
      }
      ofPushStyle();
      stringstream ss;
      ss << "zone flow : " << zoneFlow;
      ofDrawBitmapString(ss.str(), ofPoint(rect.x+10,rect.y-10));
    } else {
      ofRectangle rect = ofRectangle(bgSub.m_fgmask.cols/2,bgSub.m_fgmask.rows/2, bgSub.m_fgmask.cols, bgSub.m_fgmask.rows);
      ofxCv::drawMat(contour.blurred,rect.x, rect.y);
    }
  }

  if (showGui){
    gui.draw();
  }

  recordPanel.draw();
}
Esempio n. 26
0
void drawTo(WaveBreak other) {
    
    ofStroke(color(255, 255, 255));
    ofDrawLine(other.posX, other.y, xPos, y);
}
Esempio n. 27
0
void manfredMohrP196A::drawComposition(int rowNum, int columnNum){
	float screenSpaceWidth = scale * spacing;
	int screenSpaceBottom = -(int)(rowNum * screenSpaceWidth + screenSpaceWidth/2 - dimensions.height/2.);
	int screenSpaceRight = (int)(columnNum * screenSpaceWidth - screenSpaceWidth/2 + dimensions.width/2.);
	int indexA = getIndexA(rowNum, columnNum);
	int indexB = indexA + 1;
	ofVec4f rotationA, rotationB;
	
	ofVec4f rotationCenterA =
		zeroVector * (1. - cubeARotationPercent) +
		rotations[0] * cubeARotationPercent;
	ofVec4f rotationCenterB =
		rotationCenterA * (1. - cubeBRotationDiffPercent) +
		rotations[1] * cubeBRotationDiffPercent;
	if (rowNum == 0 && columnNum == 0){
		rotationA = rotationCenterA;
		rotationB = rotationCenterB;
	} else {
		rotationA =
			rotationCenterA * (1. - cubeOthersRotationDiffPercent) +
			rotations[indexA] * cubeOthersRotationDiffPercent;
		rotationB =
			rotationCenterB * (1. - cubeOthersRotationDiffPercent) +
			rotations[indexB] * cubeOthersRotationDiffPercent;
	}

	ofPushMatrix();
	{
		ofTranslate(spacing * columnNum, spacing * rowNum, 0);
		ofSetColor(foregroundColor, rearLineOpacity);
		ofDrawLine(0, -spacing/2, 0, spacing/2);
		glEnable(GL_SCISSOR_TEST);  
		{
			//draw cube A
			glScissor(
				screenSpaceRight, 
				screenSpaceBottom, 
				screenSpaceWidth, 
				screenSpaceWidth/2);
			ofSetColor(backgroundColor);
			ofFill();
			drawCube(rotationA);
			ofSetColor(foregroundColor);
			ofNoFill();
			drawCube(rotationA);
	
			//draw cube B
			glScissor(
				screenSpaceRight, 
				screenSpaceBottom + screenSpaceWidth/2, 
				screenSpaceWidth, 
				screenSpaceWidth/2);
			ofSetColor(backgroundColor);
			ofFill();
			drawCube(rotationB);
			ofSetColor(foregroundColor);
			ofNoFill();
			drawCube(rotationB);

			
			//draw inner bg
			glScissor(
				screenSpaceRight + (int)((screenSpaceWidth - scale)/2),
				screenSpaceBottom + (int)((screenSpaceWidth - scale)/2),
				scale,
				scale);
			ofSetColor(backgroundHighlightColor);
			ofFill();
			drawCube(zeroVector);
			
			ofSetColor(foregroundColor);
			ofSetLineWidth(highlightLineWidth);
			ofNoFill();
			//draw inner cube A
			glScissor(
				screenSpaceRight + (int)((screenSpaceWidth - scale)/2),
				screenSpaceBottom + (int)((screenSpaceWidth - scale)/2),
				scale,
				scale/2);
			drawCube(rotationA);
	
			//draw inner cube B
			glScissor(
				screenSpaceRight + (int)((screenSpaceWidth - scale)/2),
				screenSpaceBottom + (int)(screenSpaceWidth/2),
				scale,
				scale/2);
			drawCube(rotationB);

		}
		glDisable(GL_SCISSOR_TEST);  
		
		//draw dividing line
		ofSetLineWidth(1);
		ofDrawLine(-spacing/2, 0, spacing/2, 0);
	}
	ofPopMatrix();
}
Esempio n. 28
0
void ofxGuiInputField<Type>::drawFocusedBB(){
	ofPushStyle();
	ofSetColor(textColor);
	ofDrawLine( selectStartX, 0, selectStartX, getShape().getHeight() );
	ofPopStyle();
}
void StSyncopationMonitorColor::draw() {
	ofPushMatrix();
	ofTranslate(top, left);
	drawGrid();
	ofDisableAlphaBlending();

	float LH_weight[16] = { 0, -4, -3, -4, -2, -4, -3, -4, -1, -4, -3, -4, -2, -4, -3, -4 };

	//draw matrix
	ofDisableSmoothing();
	if (app->tidal->instNumMax > 0) {
		for (int i = 0; i < app->tidal->notes.size(); i++) {
			instNames[app->tidal->notes[i].instNum] = app->tidal->notes[i].instName;
		}
		for (int i = 0; i < app->tidal->instNumMax; i++) {
			float x, y, h;
			for (int j = 0; j < app->tidal->max2; j++) {
				if (app->tidal->noteMatrix[i][j] == 1) {
					x = ofMap(j, 0, app->tidal->max2, 0, width);
					h = height / (app->tidal->instNumMax);
					float y = h * i;
					int count = j % 16;
					int weight = LH_weight[count];
					ofColor col;
					float hue = ofMap(weight, 0, -4, 64, 0);
					float saturation = ofMap(weight, 0, -4, 20, 200);
					float brightness = 255;
					col.setHsb(hue, saturation, brightness);
					ofSetColor(col);
					ofDrawRectangle(x, y, ofGetWidth()/256.0, h);
				}
			}
			ofDrawBitmapStringHighlight(instNames[i], 4, height / (app->tidal->instNumMax) * i + 14, ofColor(63));
			if (i > 0) {
				ofSetColor(127);
				ofDrawLine(0, height / (app->tidal->instNumMax) * i, width, height / (app->tidal->instNumMax) * i);
			}
		}
	}
	ofEnableSmoothing();
	ofPopMatrix();

	//draw graph
	float x, y, gwidth, gheight, graphX;
	float graphWidth;
	x = 20;
	y = ofGetHeight() / 2 + 20;
	graphX = 70;
	gwidth = ofGetWidth() - 40 - graphX;
	gheight = 10;

	ofTranslate(x, y);
	ofPushMatrix();
	ofSetColor(255);
	ofDrawBitmapString("Syncopation Degree", 0, 0);
	ofTranslate(0, -8);
	for (int i = 0; i < app->tidal->instNumMax; i++) {
		ofTranslate(0, 14);
		graphWidth = ofMap(app->tidal->syncopation[i], 0, 20, 0, gwidth);
		ofSetColor(63);
		ofDrawRectangle(graphX, 0, gwidth, gheight);
		ofSetColor(63, 127, 255);
		ofDrawRectangle(graphX, 0, graphWidth, gheight);
		ofSetColor(255);
		//ofDrawBitmapString("S"
		//                   + ofToString(i) + ":"
		//                   + ofToString(app->tidal->syncopation[i]), 0, 12);
		ofDrawBitmapString(instNames[i], 0, 10);
		ofDrawBitmapString(ofToString(app->tidal->syncopation[i]), graphX + 5, 10);
	}
	ofTranslate(0, 40);
	ofDrawBitmapString("Note Number", 0, 0);
	ofTranslate(0, -8);
	for (int i = 0; i < app->tidal->instNumMax; i++) {
		ofTranslate(0, 14);
		graphWidth = ofMap(app->tidal->noteNum[i], 0, 32, 0, gwidth);
		ofSetColor(63);
		ofDrawRectangle(graphX, 0, gwidth, gheight);
		ofSetColor(63, 127, 255);
		ofDrawRectangle(graphX, 0, graphWidth, gheight);
		ofSetColor(255);
		//ofDrawBitmapString("E"
		//                   + ofToString(i) + ":"
		//                   + ofToString(app->tidal->entropy[i], 2), 0, 10);
		ofDrawBitmapString(instNames[i], 0, 10);
		ofDrawBitmapString(ofToString(app->tidal->noteNum[i]), graphX + 5, 10);
	}
	/*
	ofTranslate(0, 40);
	ofDrawBitmapString("Entropy", 0, 0);
	ofTranslate(0, -8);
	for (int i = 0; i < app->tidal->instNumMax; i++) {
	ofTranslate(0, 14);
	graphWidth = ofMap(powf(app->tidal->entropy[i], 10), 0, 1, 0, gwidth);
	ofSetColor(63);
	ofDrawRectangle(graphX, 0, gwidth, gheight);
	ofSetColor(63, 127, 255);
	ofDrawRectangle(graphX, 0, graphWidth, gheight);
	ofSetColor(255);
	//ofDrawBitmapString("E"
	//                   + ofToString(i) + ":"
	//                   + ofToString(app->tidal->entropy[i], 2), 0, 10);
	ofDrawBitmapString(instNames[i], 0, 10);
	ofDrawBitmapString(ofToString(app->tidal->entropy[i]), graphX + 5, 10);
	}
	*/
	ofPopMatrix();
}
Esempio n. 30
0
void Voro::draw(){
    if( 1 ){
        voronoi_diagram<double>::const_cell_iterator it = vD.cells().begin();
        for (int i=0; it!= vD.cells().end(); ++it, i++) {
            
            const cell_type& cell = *it;
            const edge_type* edge = cell.incident_edge();
            
            do{
                if(edge->is_primary()){
                    if( edge->is_finite() ){
                        if (edge->cell()->source_index() < edge->twin()->cell()->source_index()){
                            float x0 = edge->vertex0()->x();
                            float y0 = edge->vertex0()->y();
                            float x1 = edge->vertex1()->x();
                            float y1 = edge->vertex1()->y();
                            
                            if(1){
                                glm::vec2 v0(x0, y0);
                                glm::vec2 v1(x1, y1);
                                glm::vec2 d = v1 - v0;
                                float length = glm::length(d);
                                float space = ofGetWidth() * 0.01;
                                if(length>space*2){
                                    v0 += d*(space/length);
                                    v1 -= d*(space/length);
                                    
                                    x0 = v0.x;
                                    y0 = v0.y;
                                    x1 = v1.x;
                                    y1 = v1.y;
                                }
                            }
                            float limity = ofGetHeight()/2;
                            float limitx = ofGetWidth()/2;
                            bool xOver = ( abs(x0)>limitx || abs(x1)>limitx );
                            bool yOver = ( abs(y0)>limity || abs(y1)>limity );
                            
                            bool draw = !xOver && !yOver;
                            
                            if(1){
                                ofFill();
                                ofSetColor(0,0,0, 150);
                                ofSetLineWidth(1);
                                ofDrawLine(x0,y0,0,x1,y1,0);
                                ofDrawCircle(x0,y0,2);
                                ofDrawCircle(x1,y1,2);
                            }
                        }
                    }else{
                        if( 1 ){
                            const vertex_type * v0 = edge->vertex0();
                            if( v0 ){
                                vPoint p1 = vPs[edge->cell()->source_index()];
                                vPoint p2 = vPs[edge->twin()->cell()->source_index()];
                                float x0 = edge->vertex0()->x();
                                float y0 = edge->vertex0()->y();
                                float end_x = (p1.y() - p2.y()) * ofGetWidth();
                                float end_y = (p1.x() - p2.x()) * -ofGetWidth();
                                
                                glm::vec2 v0(x0, y0);
                                glm::vec2 v1(end_x, end_y);
                                glm::vec2 dir = v1 - v0;
                                float rate = (ofGetWidth()*0.1)/glm::length(dir);
                                glm::vec2 v3 = v0 + dir*(rate);
                                
                                ofSetLineWidth(1);
                                ofDrawLine(x0,y0,0,v3.x, v3.y, 0);
                            }
                        }
                    }
                }
                edge = edge->next();
            }while (edge != cell.incident_edge());
        }
    }
    
    // draw Point
    if( 0 ){
        glPointSize(3);
        ofSetColor(255, 0,0);
        for( auto v : vPs ){
            ofDrawCircle(v.x(), v.y(), 2);
        }
    }
    
}