Ejemplo n.º 1
0
void testApp::AudioDebug(){
    
    //debug view
    ofPushStyle();
    ofPushMatrix();
    ofTranslate((ofGetWindowWidth()/2)-250, ofGetWindowHeight()-200);
    ofPushMatrix();
    ofTranslate(100, 0);
    
    ofFill();
    ofDrawBitmapString("Channel01", -90,0);
    ofSetColor(255,40);
    ofDrawBitmapString("FFT: "+ ofToString(Channel01_FFT_size) + " freq", 0,15);
    
    ofDrawBitmapString("Frequency: " + ofToString(Channel01_Pitch,0), 0,30);
    ofDrawBitmapString("Linear Pitch: " + ofToString(Channel01_LinearPitch,0), 0,45);
    ofDrawBitmapString("Amplitude: " + ofToString(Channel01_Amplitude,4), 0,60);
    ofDrawBitmapString("Attack: " + ofToString(Channel01_Attack,4), 0,75);
    
    
    for (int i = 0; i < Channel01_FFT_size; i++){
        ofSetColor(255,20);
        ofRect((i*6),0,5,-Channel01_FFT[i] * 3);
        ofSetColor(255);
        ofLine((i*6), -Channel01_FFT[i] * 3, ((i+1)*6), -Channel01_FFT[i+1] * 3);
    }
    ofSetColor(255, 255*Channel01_Amplitude);
    ofCircle(-50,50, Channel01_Attack*3);
    ofSetColor(255);
    ofNoFill();
    ofCircle(-50, 50, Channel01_Attack*3);
    
    ofPopMatrix();
    
    ofPushMatrix();
    ofTranslate(350, 0);
    
    ofFill();
    ofDrawBitmapString("Channel02", -90,0);
    ofSetColor(255,40);
    ofDrawBitmapString("FFT: "+ ofToString(Channel02_FFT_size) + " freq", 0,15);
    
    ofDrawBitmapString("Frequency: " + ofToString(Channel02_Pitch,0), 0,30);
    ofDrawBitmapString("Linear Pitch: " + ofToString(Channel02_LinearPitch,0), 0,45);
    ofDrawBitmapString("Amplitude: " + ofToString(Channel02_Amplitude,4), 0,60);
    ofDrawBitmapString("Attack: " + ofToString(Channel02_Attack,4), 0,75);
    
    
    for (int i = 0; i < Channel02_FFT_size; i++){
        ofSetColor(255,20);
        ofRect((i*6),0,5,-Channel02_FFT[i] * 3);
        ofSetColor(255);
        ofLine((i*6), -Channel02_FFT[i] * 3, ((i+1)*6), -Channel02_FFT[i+1] * 3);
    }
    ofSetColor(255, 255*Channel02_Amplitude);
    ofCircle(-50,50, Channel02_Attack*3);
    ofSetColor(255);
    ofNoFill();
    ofCircle(-50, 50, Channel02_Attack*3);
    ofPopMatrix();
    ofPopMatrix();
    ofPopStyle();
    
    
}
Ejemplo n.º 2
0
//--------------------------------------------------------------
void testApp::draw(){
	
	// Main image
	ofSetColor(0xffffff);
	grayImage.draw(0, 0);
	ofSetColor(0x666666);	
	ofDrawBitmapString(ofToString(artk.getNumDetectedMarkers()) + " marker(s) found", 10, 20);

	// Threshold image
	ofSetColor(0xffffff);
	grayThres.draw(640, 0);
	ofSetColor(0x666666);	
	ofDrawBitmapString("Threshold: " + ofToString(threshold), 650, 20);
	ofDrawBitmapString("Use the Up/Down keys to adjust the threshold", 650, 40);

	// ARTK draw
	// An easy was to see what is going on
	// Draws the marker location and id number
	artk.draw(640, 0);
	
	// ARTK 2D stuff
	// See if marker ID '64' was detected
	// and draw blue corners on that marker only
	int myIndex = artk.getMarkerIndex(64);
	
	if(myIndex >= 0) {	
		// Get the corners
		vector<ofPoint> corners;
		artk.getDetectedMarkerBorderCorners(myIndex, corners);
		// Can also get the center like this:
		// ofPoint center = artk.getDetectedMarkerCenter(myIndex);
		ofSetHexColor(0x0000ff);
		for(int i=0;i<corners.size();i++) {
			ofCircle(corners[i].x, corners[i].y, 10);
		}
	}
	
	// Homography
	// Here we feed in the corners of an image and get back a homography matrix
	ofMatrix4x4 Homography = artk.getHomography(myIndex, displayImageCorners);
	// We apply the matrix and then can draw the image distorted on to the marker
	ofPushMatrix();
	glMultMatrixf(Homography.getPtr());
	ofSetHexColor(0xffffff);
	colorImage.draw(0, 0);
	ofPopMatrix();
	
	
	// ARTK 3D stuff
	// This is another way of drawing objects aligned with the marker
	// First apply the projection matrix once
	
	ofPushMatrix();

		artk.applyProjectionMatrix();
		// Find out how many markers have been detected
		int numDetected = artk.getNumDetectedMarkers();
		ofEnableAlphaBlending();
		// Draw for each marker discovered
		for(int i=0; i<numDetected; i++) {
			
			// Set the matrix to the perspective of this marker
			// The origin is in the middle of the marker	
			artk.applyModelMatrix(i);		
			
			// Draw a stack of rectangles by offseting on the z axis
			ofNoFill();
			ofEnableSmoothing();
			ofSetColor(255, 255, 0, 50);	

			for(int i=0; i<10; i++) {		
				ofRect(-25, -25, 50, 50);
				ofTranslate(0, 0, i*1);
			}
			
		}
	ofPopMatrix();

}
Ejemplo n.º 3
0
void Particle::draw(){
    ofCircle(*this, size);
}
Ejemplo n.º 4
0
//--------------------------------------------------------------
void testApp::drawAssociation(ofPoint& botCenter, ofPoint& pt){
    ofVec2f p1(pt.x, pt.y-5);
    ofSetLineWidth(2);
    ofLine(p1, botCenter);
    ofCircle(botCenter, 10);
}
Ejemplo n.º 5
0
//--------------------------------------------------------------
void testApp::draw() {

    //set background to pretty gray gradient
    ofBackgroundGradient(ofColor::black, ofColor::gray);

    //Update the GUI elements
    guiUpdate();

    ofSetColor(255);  // Set color to white

    //onscreen instructions
    if(camMode) {
        string msg;
        msg += "Instructions:\n";
        msg += "Press up and down arrow keys to adjust contour contrast level\n";
        msg += "Press the space bar to reset the background\n";
        myFont.drawString(msg, 210, 20);
    }
    else if (ILDAmode) {
        string msg;
        msg += "Instructions:\n";
        msg += "Press \"n\" or right arrow to go to next file, \"b\" or left arrow to go to previous file\n";
        msg += "Toggle \"Draw ILDA\" off to make the framerate faster\n";
        msg += "ILDA files are in \"data/ildaFiles\"";
        myFont.drawString(msg, 210, 20);
    }
    else if (manualControl) {
        string msg;
        msg += "Instructions:\n";
        msg += "Turn laser on and off with \"Laser\" toggle\n";
        msg += "Click and drag within 2D pad to control laser point\n";
        myFont.drawString(msg, 210, 20);
    }
    else {
        string msg;
        msg += "Instructions:\n";
        msg += "Click on the \"Serial Devices\" dropdown to select your serial comm port\n";
        msg += "To rescan serial ports, click refresh\n";
        myFont.drawString(msg, 210, 20);
    }

    /* -------- DRAW CURRENT ILDA GRAPHIC ----------- */
    if(ILDAmode && drawILDA && fileLoaded && !manualControl && !camMode ) {

        ofSetLineWidth(1);

        // Draw the current idla file in the center of the CUI
        for(int i = 0; i < (nPts-1); i++) {

            // Draw circle around "Point" currently selected in point inspector
            if(point == (i+1)) {
                ofSetColor(0,255,255);
                ofNoFill(); //draw circle outline, thus nofill
                ofCircle(gui_ctr.x+x_grd[i],gui_ctr.y-y_grd[i],10);
            }

            // If laser if on, draw red line, otherwise white line
            if(l_state[i]) {
                ofSetColor(153,0,0);
                ofLine(gui_ctr.x+x_grd[i],gui_ctr.y-y_grd[i], \
                       gui_ctr.x+x_grd[i+1],gui_ctr.y-y_grd[i+1]);
            }
            else if(!l_state[i]) {
                ofSetColor(150,150,150);
                ofLine(gui_ctr.x+x_grd[i],gui_ctr.y-y_grd[i], \
                       gui_ctr.x+x_grd[i+1],gui_ctr.y-y_grd[i+1]);
            }
        }

    }

    /* ------- DRAW MANUAL POINT POSITION ----------- */
    if(manualControl) {

        ofPushStyle();
        ofEnableBlendMode(OF_BLENDMODE_ALPHA);

        //draw laser cursor on screen
        ofSetColor(255, 100, 100, 150);
        ofFill();
        ofCircle(positionDraw.x,positionDraw.y, radius);
        ofPopStyle();
    }

    /* --------- DRAW EDGE CONTOUR -------------------- */
    if(camMode) {

        // Set coordinate for CV video feed
        int x_max = 320;
        int y_max = 240;
        int xCam_ctr = gui_ctr.x - (x_max/2);
        int yCam_ctr = gui_ctr.y;

        // Draw Color Image, All blob contours
        colorImg.draw(xCam_ctr,(yCam_ctr-1.15*y_max));
        contourFinder.draw(xCam_ctr - 0.6*x_max,yCam_ctr);

        //label webcam images
        myFont.drawString("Webcam Image", xCam_ctr+110, yCam_ctr-1.15*y_max-5 );
        myFont.drawString("Blobs", xCam_ctr - 0.6*x_max + 135, yCam_ctr - 5 );
        myFont.drawString("Contours", xCam_ctr + 0.6*x_max + 125, yCam_ctr -5 );

        // Draw first blob
        if(contourFinder.nBlobs) {

            if(multiContours) {
                //draw multiple blobs
                // Iterate through each blob
                for(int i = 0; i < contourFinder.nBlobs; i++) {

                    int edg_pts = contourFinder.blobs[i].nPts;  // Number of points in contour

                    // Iterate through each point in each blob
                    for(int j = 0; j < (edg_pts-1); j++) {
                        // Draw contour lines
                        ofLine( xCam_ctr + 0.6*x_max + contourFinder.blobs[i].pts[j].x,     \
                                yCam_ctr + contourFinder.blobs[i].pts[j].y,    \
                                xCam_ctr + 0.6*x_max + contourFinder.blobs[i].pts[j+1].x,  \
                                yCam_ctr + contourFinder.blobs[i].pts[j+1].y);      // Draw connecting lines
                    }

                }

                // Draw border lines
                ofLine( xCam_ctr + 0.6*x_max + 0,      \
                        yCam_ctr + 0,      \
                        xCam_ctr + 0.6*x_max + x_max,    \
                        yCam_ctr + 0);

                ofLine( xCam_ctr + 0.6*x_max + x_max,    \
                        yCam_ctr + 0,      \
                        xCam_ctr + 0.6*x_max + x_max,    \
                        yCam_ctr + y_max);

                ofLine( xCam_ctr + 0.6*x_max + x_max,    \
                        yCam_ctr + y_max,    \
                        xCam_ctr + 0.6*x_max + 0,      \
                        yCam_ctr + y_max);

                ofLine( xCam_ctr + 0.6*x_max + 0,      \
                        yCam_ctr + y_max,    \
                        xCam_ctr + 0.6*x_max + 0,      \
                        yCam_ctr + 0);
            }
            else {
                //draw only the first blob
                int n = contourFinder.blobs[0].nPts;
                for(int i = 0; i < (n-1); i++) {

                    // Draw contour lines
                    ofLine( xCam_ctr + 0.6*x_max + contourFinder.blobs[0].pts[i].x,     \
                            yCam_ctr + contourFinder.blobs[0].pts[i].y,    \
                            xCam_ctr + 0.6*x_max + contourFinder.blobs[0].pts[i+1].x,  \
                            yCam_ctr + contourFinder.blobs[0].pts[i+1].y);      // Draw connecting lines
                }

                // Draw border lines
                ofLine( xCam_ctr + 0.6*x_max + 0,      \
                        yCam_ctr + 0,      \
                        xCam_ctr + 0.6*x_max + x_max,    \
                        yCam_ctr + 0);

                ofLine( xCam_ctr + 0.6*x_max + x_max,    \
                        yCam_ctr + 0,      \
                        xCam_ctr + 0.6*x_max + x_max,    \
                        yCam_ctr + y_max);

                ofLine( xCam_ctr + 0.6*x_max + x_max,    \
                        yCam_ctr + y_max,    \
                        xCam_ctr + 0.6*x_max + 0,      \
                        yCam_ctr + y_max);

                ofLine( xCam_ctr + 0.6*x_max + 0,      \
                        yCam_ctr + y_max,    \
                        xCam_ctr + 0.6*x_max + 0,      \
                        yCam_ctr + 0);
            }

        }
    }
}
Ejemplo n.º 6
0
	void draw() {
		ofCircle(pos.x, pos.y, size);
	}
Ejemplo n.º 7
0
//--------------------------------------------------------------
void testApp::draw(){
    for (int i=0; i<NUM_CIRCLES; i++) {
        ofCircle(xpos[i], ypos[i], radii[i]);
        ofSetColor(red[i], green[i], blue[i]);
        }
    }
Ejemplo n.º 8
0
void ParticleVec2::draw(){
    ofCircle(position.x, position.y, radius);
    
}
Ejemplo n.º 9
0
	//draw the circles
	void display(){
		ofFill();
		ofSetColor(255,10,50);
		ofCircle(location, 10);
	}
Ejemplo n.º 10
0
//--------------------------------------------------------------
void HandJesture::draw() {
	
	ofSetColor(255, 255, 255);
	
	if (showConfigUI) {
		kinect.drawDepth(400, 0, 400, 300);
		gui.draw();
		
		msgFont.drawString("Press Space Key to start.", 20, ofGetHeight()-60);
		
		ofPushMatrix();
		ofTranslate(400, 300, 0);
		glScalef(0.6, 0.6, 1.0f); 
        for (int i = 0; i < contourFinder.nBlobs; i++){
            ofPushMatrix();
            contourFinder.blobs[i].draw(0,0);
			ofSetColor(255, 0, 0);
            ofFill();
            ofEllipse(contourFinder.blobs[i].centroid.x, contourFinder.blobs[i].centroid.y, 4, 4);
			
			float centroidX = 0;
			float centroidY = 0;
			float addCount = 0;
			for (int j = 0; j < contourFinder.blobs[i].nPts; j+=5){
				addCount++;
				centroidX += contourFinder.blobs[i].pts[j].x;
				centroidY += contourFinder.blobs[i].pts[j].y;
			}
			centroidX = centroidX/addCount;
			centroidY = centroidY/addCount;
			ofCircle(centroidX, centroidY, 10);
			
            ofPopMatrix();
        }
		ofPopMatrix();
	} else {
		grayImage.draw(0, 0, 400, 300);
	}
	
		
	ofSetColor(255, 255, 255);
    
    
    
    std::ostringstream osstream,stream2;
    
    int x [contourFinder.nBlobs];
    int y [contourFinder.nBlobs];
    double length;
    
    for (int i = 0; i < contourFinder.nBlobs; i++){
        x[i] = contourFinder.blobs[i].centroid.x;
        osstream << "x";
        osstream << i;
        osstream << " = ";
        osstream << x[i];
        osstream << " ";
        //cout<<"x"<<i<<" = "<< x[i];
        y[i] = contourFinder.blobs[i].centroid.y;
        osstream << "y";
        osstream << i;
        osstream << " = ";
        osstream << y[i];
        osstream << " ";
        //cout<<"y"<<i<<" = "<< y[i];
    }
    
    if (contourFinder.nBlobs == 2){
        int dx = contourFinder.blobs[1].centroid.x-contourFinder.blobs[0].centroid.x;
        int dy = contourFinder.blobs[1].centroid.y-contourFinder.blobs[0].centroid.y;
        length = sqrt((dx*dx)-(dy*dy));
        stream2<< "length = ";
        stream2<< length;
        stream2<< " dx = ";
        stream2<< dx;
        stream2<< " dy = ";
        stream2<< dy;
    }
    
    std::string string_x = osstream.str();
    std::string string_y = stream2.str();
    
    msgFont.drawString("distance: " +string_y, 20, ofGetHeight()-40);
    msgFont.drawString("locations: " +string_x, 20, ofGetHeight()-20);
    
    
    
	//msgFont.drawString("fps: "+ ofToString(ofGetFrameRate()), 20, ofGetHeight()-40);

		
	ofNoFill();
};
Ejemplo n.º 11
0
//--------------------------------------------------------------
void testApp::draw() {
	if (ofGetKeyPressed('v')) {
		ofSetLineWidth(1.0);
		ofSetColor(80, 80, 80);
		ofPushMatrix();
		ofScale(ofGetWidth() / (float)vectorField.getWidth(), ofGetHeight() / (float)vectorField.getHeight());
		for (int y = 0; y < vectorField.getHeight(); y++)
			for (int x = 0; x< vectorField.getWidth(); x++) {
				ofColor_<float> c = vectorField.getColor(x, y);
				ofVec2f dir(c.r, c.g);

				ofLine(x, y, x + dir.x, y + dir.y);
			}
		ofPopMatrix();
	}



	cam.begin();
	ofPushMatrix();
	ofScale(300, 300, 300);
	shader.begin();
	shader.setUniform1i("uWidth", kinect.getBodyIndexSource()->getWidth());
	//shader.setUniformTexture("uBodyIndexTex", kinect.getBodyIndexSource()->getTexture(), 1);
	shader.setUniform1i("uBodyIndexTex", 1);
	kinect.getBodyIndexSource()->getTexture().bind(1);
	//shader.setUniformTexture("uColorTex", kinect.getColorSource()->getTexture(), 2);
	shader.setUniform1i("uColorTex", 2);
	kinect.getColorSource()->getTexture().bind(2);
	
	ofSetColor(255);
	ofMesh mesh = kinect.getDepthSource()->getMesh(false, ofxKFW2::Source::Depth::PointCloudOptions::ColorCamera);
	mesh.draw();

	kinect.getColorSource()->getTexture().unbind(2);
	kinect.getBodyIndexSource()->getTexture().unbind(1);
	shader.end();

	ofPopMatrix();
	cam.end();


	ofNoFill();
	ofSetCircleResolution(180);
	ofSetColor(255, 102, 159, 255);
	//ofCircle(ofGetWidth() / 2, ofGetHeight() / 2, sqrt(gravAcc));
	ofSetColor(0, 0, 180, 255);

	//ofCircle(ofGetWidth() / 2, ofGetHeight() / 2, sqrt(rotAcc));

	ofSetLineWidth(2.0);
	for (int i = 0; i < BODY_COUNT; i++) {
		if (displayMode == 1) {
			particleSystems[i].draw(pTex);
		}
		else if (displayMode == 2) {
			particleSystems[i].draw(p1Tex, p2Tex);
		}
		else {
			particleSystems[i].draw();
		}
	}
	
	ofSetLineWidth(8.0);
	ofSetColor(101, 66, 138, 255);
	
	for (int i = 0; i < BODY_COUNT; i++) {
		if ((lastChestPositions[i].x > 0 && lastChestPositions[i].y > 0)) {
			ofCircle(lastChestPositions[i].x, lastChestPositions[i].y, 60);
		}
	}

	// TODO: make this work with everything else too
	gravAcc = gravityAnimate();

	ofSetLineWidth(2.0);

	ofSetColor(255, 255, 255);
	int totalNumOfParticles = 0;
	for (int i = 0; i < BODY_COUNT; i++) {
		totalNumOfParticles += particleSystems[i].getNumParticles();
	}
	ofDrawBitmapString(ofToString(totalNumOfParticles) + "\n" + ofToString(ofGetFrameRate()) +
		"\n(G/g) gravitation: " + ofToString(gravAcc) +
		"\n(R/r) rotational acceleration: " + ofToString(rotAcc) +
		"\n(F/f) vector field multiplier: " + ofToString(fieldMult) +
		"\n(D/d) drag constant: " + ofToString(drag) +
		"\n(v) show vector field" +
		"\n(1-3) particle display modes", 20, 20);





}
Ejemplo n.º 12
0
void testApp::draw(){
	ofSetMinMagFilters(GL_NEAREST, GL_NEAREST);
		
	ofBackground(0);
	ofSetColor(255);
	
	if(playerCount == 0) {
		float rescale = ofMap(sin(ofGetElapsedTimef() * 5), -1, 1, .8, 1.2);
		ofSetColor(magenta);
		drawTitle("WAITING FOR PLAYER", rescale);
	} else if(playerCount == 1) {
		ofVec2f offset(ofRandomf(), ofRandomf());
		offset *= 5;
		ofSetColor(cyan);
		ofPushMatrix();
		ofTranslate(offset.x, offset.y);
		drawTitle("AWAITING CHALLENGER");
		ofPopMatrix();
	} else if(playerCount == 2) {
		for(int i = 0; i < projectiles.size(); i++) {
			projectiles[i].draw();
		}
		
		ofSetColor(255);
		for(int i = 0; i < players.size(); i++) {
			if(players[i].life > 0) {
				ofPushMatrix();
				ofTranslate((int) players[i].position.x, (int) players[i].position.y);
				ofScale(2, 2);
				if(players[i].position.x > ofGetWidth() / 2) {
					ofScale(-1, 1);
				}
				if(i == 0) {
					maskedDraw(ryu);
				} else {
					maskedDraw(ken);
				}
				ofPopMatrix();
			}
		}
	}
	
	int winner = 0;
	if(playerCount == 2) {
		bool done = false;
		for(int i = 0; i < players.size(); i++) {
			drawLife(i);
			if(players[i].life <= 0) {
				done = true;
			} else {
				winner = i;
			}
		}
		if(done && !lastDone) {
			youWin.play();
		}
		lastDone = done;
	}
	
	if(playerCount == 2 && lastDone) {
		bool flash = sin(2. * ofGetElapsedTimef() * TWO_PI) > 0;
		ofSetColor(flash ? yellow : 0);
		drawTitle("PLAYER " + ofToString(winner + 1) + " WINS");
	}
	
	if(panel.getValueB("debug")) {
		ofSetColor(255);
		for(int i = 0; i < players.size(); i++) {
			ofCircle(players[i].position, 32);
		}
	}
}
Ejemplo n.º 13
0
//------------------------------------------------------------
void particle::draw(){
    ofCircle(pos.x, pos.y, 3);
}
Ejemplo n.º 14
0
//--------------------------------------------------------------
void testApp::draw(){
	ofCircle(x, ofGetHeight()/2, 5);
}
Ejemplo n.º 15
0
//--------------------------------------------------------------
void testApp::draw(){

	//--------------------------- circles
	//let's draw a circle:
	ofSetColor(255,130,0);
	float radius = 50 + 10 * sin(counter);
	ofFill();		// draw "filled shapes"
	ofCircle(100,400,radius);

	// now just an outline
	ofNoFill();
	ofSetHexColor(0xCCCCCC);
	ofCircle(100,400,80);

	// use the bitMap type
	// note, this can be slow on some graphics cards
	// because it is using glDrawPixels which varies in
	// speed from system to system.  try using ofTrueTypeFont
	// if this bitMap type slows you down.
	ofSetHexColor(0x000000);
	ofDrawBitmapString("circle", 75,500);


	//--------------------------- rectangles
	ofFill();
	for (int i = 0; i < 200; i++){
		ofSetColor((int)ofRandom(0,255),(int)ofRandom(0,255),(int)ofRandom(0,255));
		ofRect(ofRandom(250,350),ofRandom(350,450),ofRandom(10,20),ofRandom(10,20));
	}
	ofSetHexColor(0x000000);
	ofDrawBitmapString("rectangles", 275,500);

	//---------------------------  transparency
	ofSetHexColor(0x00FF33);
	ofRect(400,350,100,100);
	// alpha is usually turned off - for speed puposes.  let's turn it on!
	ofEnableAlphaBlending();
	ofSetColor(255,0,0,127);   // red, 50% transparent
	ofRect(450,430,100,33);
	ofSetColor(255,0,0,(int)(counter * 10.0f) % 255);   // red, variable transparent
	ofRect(450,370,100,33);
	ofDisableAlphaBlending();

	ofSetHexColor(0x000000);
	ofDrawBitmapString("transparency", 410,500);

	//---------------------------  lines
	// a bunch of red lines, make them smooth if the flag is set

	if (bSmooth){
		ofEnableSmoothing();
	}

	ofSetHexColor(0xFF0000);
	for (int i = 0; i < 20; i++){
		ofLine(600,300 + (i*5),800, 250 + (i*10));
	}

	if (bSmooth){
		ofDisableSmoothing();
	}

	ofSetHexColor(0x000000);
	ofDrawBitmapString("lines\npress 's' to toggle smoothness", 600,500);

}
Ejemplo n.º 16
0
//--------------------------------------------------------------
void testApp::draw() {
    
    //draw sequencer needle
    
    /*ofPushMatrix();
    
    ofTranslate(circle.x, circle.y);
    ofSetColor(255);
    ofRotate(rotation);
    ofLine(0, 0, 0, radius);
    
    ofPopMatrix();
     */
    
    //ofSetColor(255, 128);
    //ofCircle(x, y, 20);
    
    //Create an iterator to cycle through the vector
    vector<Particle>::iterator p ;
    
    for ( p = particles.begin() ; p != particles.end() ; p++ )
    //for ( int i = 0 ; i < particles.size() ; i++ )
    {
        
        //playing the notes
        
        play = false;
        
        if (prevRotation <= int(p->angle) && rotation >= int(p->angle) && abs(rotation - prevRotation) < abs (inc*2)) play = true;
        
        if (prevRotation >= int(p->angle) && rotation <= int(p->angle) && abs(rotation - prevRotation) < abs(inc*2)) play =true;
        
        
        p->color.setHue(hue);
        
        if (play == true) {
            
            p->color.a = 255;
            p->color.setBrightness(255);
            p->color.setSaturation(255);
            p->size = 30;
            
            ofxOscMessage message;
            message.setAddress("/playtone");
            message.addIntArg( p->note );
            sender.sendMessage(message);
            
        } else {
            
            p->color.setBrightness(p->color.getBrightness()-10);
            p->color.setSaturation(p->color.getSaturation()+10);
            p->size -= 0.5;
            p->color.a -= 10;

            
        }
        
        if (p->color.a < 80) p->color.a = 80;
        if (p->color.getBrightness() < 150) p->color.setBrightness(150);
        if (p->color.getSaturation() > 200) p->color.setSaturation(200);
        if (p->size < 10) p->size=10;
        
         
        // draw the particles
        ofSetColor((unsigned char)p->color.r,(unsigned char)p->color.g,(unsigned char)p->color.b, (unsigned char)p->color.a);
        img.draw(p->position.x, p->position.y, p->size, p->size);
        
    }
    
    ofSetColor ( 255 , 255 , 255 ) ;
    
    string output = "S :: Springs on/off : " + ofToString(springEnabled) +
    
    "\n C :: CursorMode repel/attract " + ofToString( cursorMode ) +
    
    "\n # of particles : " + ofToString( numParticles ) +
    
    " \n fps:" +ofToString( ofGetFrameRate() );
    
    
    if (debugtext)ofDrawBitmapString(output ,20,666);
    
    ofSetColor(255, 100);
    ofCircle (mouseX, mouseY, 5, 5);

}
//------------------------------------------------------------
void particle::draw(float c){
    
    //ofSetColor(255-(c*(255/200)),255-(c*(255/200)),255,10);
    ofSetColor(255-(c*(255/200)),255,255,10);
    ofCircle(pos.x, pos.y, 30);
}
Ejemplo n.º 18
0
void HexSequencer::draw(){
    
    if (!viewFullscreen){
        op1->draw();
    }
    
    ofPushStyle();
    
//    metro.draw();
    
    ofTranslate(posX, posY); //delete this when inserting into op1
    
    ofPushStyle();
    
//    cout << "rectmode is "<<ofGetRectMode()<<endl;
    ofSetRectMode(OF_RECTMODE_CORNER);
    
    ofSetHexColor(0x111111);
    ofRect(0, 0, width, height);
    
    ofPushMatrix();
    
    ofTranslate(width-(scale/3), 0);
//    ofScale(scale/10, scale/10);
    ofScale(scale/70, scale/70);
    ofSetHexColor(orange, ((sin((1-beatIndicatorScale*2)*PI))+1)/2*255); //custom hex function in of
//    cout << sin((1-beatIndicatorScale*2)*PI)<<endl;
    ofCircle(0, 30, 10);
    ofSetHexColor(black);
    ofCircle(0, 30, 6);
    
    ofSetHexColor(orange);
    
    ofScale(0.2, 0.2);
    verdana.drawString(ofToString(bpm), -60, 75);
    int stringLength = noteLengthName.length();
    //    cout << stringLength <<endl;
    verdana.drawString(noteLengthName, -(stringLength*20), 255);
    
    ofSetHexColor(0xaaaaaa);
    string prefix = (transposition>0)?"+":"";
    verdana.drawString(prefix+ofToString(transposition), -1530, 800);
    
    ofPopMatrix();
    
    ofTranslate(width/2, height/2); //move origin to centre
    ofTranslate(-trackLength*2, -trackLength*sin(PI/3)); //centre gates on origin
    
    for (int i=0; i<gates.size();i++){
        gates[i].draw();
    }
    
    for (int i=0; i<gates.size(); i++){ //process all the notes
        for (int j=0; j<gates[i].notesIncoming.size();j++){
            
//            float distanceAlong = trackLength*currentBeatProgression;
//            gates[i].notesIncoming[j].update(distanceAlong);
            gates[i].notesIncoming[j].draw();
        }
    }
    
    ofPopStyle();
    
    ofPopStyle();
}
Ejemplo n.º 19
0
void medical::draw()
{
//	ofSetColor(0, 0, 255);
//	verdana.drawString("Framerate: " + ofToString(ofGetFrameRate()), 20, 50);
	ofDrawBitmapString(buf, 20, 50);
//	kinect.drawDepth(10, 10, 400, 300);
//	kinect.draw(420, 10, 400, 300);

	int x;
	int y;
	
	if (gestureFinder.blobs.size() == 1)
	{
//		ofSetColor(0, 0, 255);
		ofFill();
		ofxCvBlob &blob = gestureFinder.blobs[0];
		x = blob.centroid.x;
		y = blob.centroid.y;
		if (!isActivated)
			hoverWidget(x, y);
		else
		{
			if (HW_FIRST_LEG == DIRECTION_UP && HW_SECOND_LEG == DIRECTION_RIGHT)
			{
				X_STATE = x;
				Y_STATE = y;
				sender.send_stack(x, y, ZOOM, STACK);
				ofSetColor(255, 0, 255);
			}
			if (HW_FIRST_LEG == DIRECTION_DOWN && HW_SECOND_LEG == DIRECTION_LEFT)
			{
				sender.send_pen(sender.PEN_UNDO, x, y, 1, 1);
				ofSetColor(0, 255, 0);
			}
			if (HW_FIRST_LEG == DIRECTION_LEFT && HW_SECOND_LEG == DIRECTION_DOWN)
			{
				if (HW_CURRENT_DIRECTION != -1)
				{
					HW_FIRST_Y = y;
					HW_CURRENT_DIRECTION = -1;
				}
				int distance = y - HW_FIRST_Y;
//				cout << "Raw distance: " << distance << endl;
				distance = distance / 10;
//				cout << "Divided Distance: " << distance << endl;
				int speed = 0;
				if (distance < -4)
				{
//					cout << "Scroll speed -2" << endl;
					speed = -4;
				}
				else if (distance < -2)
				{
//					cout << "Scroll speed -1" << endl;
					speed = -1;
				}
				else if (distance > 4)
				{
//					cout << "Scroll speed 2" << endl;
					speed = 4;
				}
				else if (distance > 2)
				{
//					cout << "Scroll speed 1" << endl;
					speed = 1;
				}
				else
				{
//					cout << "Scroll speed 0" << endl;
					speed = 0;
				}
				STACK += speed;
				if (STACK >= 25)
					STACK = 25;
				else if (STACK <= 0)
					STACK = 0;
				cout << "STACK: " << STACK << endl;
				sender.send_stack(X_STATE, Y_STATE, ZOOM, STACK);
			}
		}
		ofCircle(x, y, 10);
	}
	else if (gestureFinder.blobs.size() == 2)
	{
		float euclidean;
		ofxCvBlob &first = gestureFinder.blobs[0];
		ofxCvBlob &second = gestureFinder.blobs[1];
		int x1 = first.centroid.x;
		int y1 = first.centroid.y;
		int x2 = second.centroid.x;
		int y2 = second.centroid.y;
		ofCircle(x1, y1, 10);
		ofCircle(x2, y2, 10);
		euclidean = ofDist(x1, y1, x2, y2);
//		cout << "Distance (Raw): " << euclidean << endl;
		float zoom = ofMap(euclidean, 0, 800, 0, 1);
//		cout << "Zoom (Mapped: " << zoom << endl;
		ZOOM = zoom;
		sender.send_stack(X_STATE, Y_STATE, ZOOM, STACK);
	}
	else if (isActivated)
	{
		isActivated = false;
		HW_FIRST_LEG = -1;
		HW_SECOND_LEG = -1;
		HW_CURRENT_DIRECTION = -1;
	}
	else
	{
		HW_FIRST_LEG = -1;
		HW_SECOND_LEG = -1;
		HW_CURRENT_DIRECTION = -1;
		HW_FIRST_Y = -1;
		HW_FIRST_X = -1;
	}
	switch (imageDisplayNumber)
	{
		case 1:
			image1.draw(10, 320, 400, 300);
			break;
		case 2:
			image2.draw(10, 320, 400, 300);
			break;
		default:
			break;
	}
	ofNoFill();
	ofSetColor(255, 255, 255);
	gestureImage.draw(700, 20, 400, 300);
	gestureFinder.draw(700, 20, 400, 300);
}
Ejemplo n.º 20
0
//--------------------------------------------------------------
void Particle::draw()
{
	ofSetColor( r, g, b );
	ofCircle( getPosition().x, getPosition().y, getRadius() );
}
Ejemplo n.º 21
0
//--------------------------------------------------------------
void Particle::draw() {
    ofEnableAlphaBlending();
    ofFill();
    ofSetColor(color, alpha*255.0);
    ofCircle(pos, radius);
}
Ejemplo n.º 22
0
void State::draw(){
	cout <<"State::draw"<<endl;
	ofSetColor(0xFF, 0xFF, 0xFF);
	ofCircle(150,150,100);
}
Ejemplo n.º 23
0
//--------------------------------------------------------------
void testApp::draw()
{
    //Quick way to get a nice cycling number between 0 and 1.
    //sin ( ofGetElapsedTimef() ) cycles between -1 and 1 .
    float amount = ( sin ( ofGetElapsedTimef() ) + 1.0f ) / 2.0f ;
    
    //Translate
    ofDrawBitmapStringHighlight("Translate", 25 , 20 ) ;
    ofPushMatrix();
        //Move it away from the edge a bit
        ofTranslate( 25 , 125 ) ;
       
        ofSetColor( ofColor::red ) ;
        ofCircle( 0 , 0 , 15 ) ;
    
        ofTranslate( 100 * amount , 100 * amount ) ;
        ofSetColor( 0 , 255 , 0 ) ;
        ofCircle( 0 , 0 , 15 ) ;
    
        ofTranslate( 100 * amount , 100 * amount ) ;
        ofSetHexColor( 0x0000FF ) ;
        ofCircle( 0 , 0 , 15 ) ;
    
    ofPopMatrix() ;
    
    //Rotation
    ofDrawBitmapStringHighlight("Rotate", 350 , 20 ) ;
    ofPushMatrix() ;
        ofTranslate( 350 , 125 ) ;
    
        ofSetColor( 255 ) ;
        ofCircle( 0 , 0, 15 ) ;
    
        int numItems = 12 ;
        float anglePer = 360.0f / (float) numItems ;
        
        for ( int i = 0 ; i < numItems ; i++ )
        {
            ofSetColor( ofColor::fromHsb( i * 35.0f , 255.0f , 255.0f ) ) ;
            ofPushMatrix() ;
                ofRotate( anglePer * (float)i * amount ) ;
            
                ofRect( -10 , 0 , 20 , 60 ) ; 
            ofPopMatrix() ;
        }
    ofPopMatrix() ;
    
    //Scale
    ofPushMatrix() ;
        ofDrawBitmapStringHighlight("Scale", 550 , 20 ) ;
        ofTranslate( 550 , 125 ) ;
        int triSize = 75 ;
        ofSetColor( ofColor::red ) ;
        ofTriangle( -triSize , triSize , 0 , -triSize , triSize , triSize ) ;
    
        //Make everything half as big
        ofScale( 0.5 * amount , 0.5 * amount ) ;
        ofSetColor( ofColor::green ) ;
        ofTriangle( -triSize , triSize , 0 , -triSize , triSize , triSize ) ;
    
        //Shrink it down again
        ofScale( 0.5 * amount , 0.5 * amount ) ;
        ofSetColor( ofColor::magenta ) ;
        ofTriangle( -triSize , triSize , 0 , -triSize , triSize , triSize ) ;
    
    ofPopMatrix() ;
}
Ejemplo n.º 24
0
void Star::draw(void)
{
    ofFill();
    ofSetColor(255, 255, 255, alpha);
    ofCircle(x,y, rad);
}
Ejemplo n.º 25
0
//--------------------------------------------------------------
void testApp::draw(){

	ofFill();
	ofSetColor(0xe0be21);

	//------(a)--------------------------------------
	// 
	// 		draw a star
	//
	// 		use poly winding odd, the default rule
	//
	// 		info about the winding rules is here:
	//		http://glprogramming.com/red/images/Image128.gif
	// 
	ofSetPolyMode(OF_POLY_WINDING_ODD);	// this is the normal mode
	ofBeginShape();
		ofVertex(200,135);
		ofVertex(15,135);
		ofVertex(165,25);
		ofVertex(105,200);
		ofVertex(50,25);
	ofEndShape();
	
	
	//------(b)--------------------------------------
	// 
	// 		draw a star
	//
	// 		use poly winding nonzero
	//
	// 		info about the winding rules is here:
	//		http://glprogramming.com/red/images/Image128.gif
	// 
	ofSetColor(0xb5de10);
	ofSetPolyMode(OF_POLY_WINDING_NONZERO);
	ofBeginShape();
		ofVertex(400,135);
		ofVertex(215,135);
		ofVertex(365,25);
		ofVertex(305,200);
		ofVertex(250,25);
	ofEndShape();
	//-------------------------------------
	
	
	
	//------(c)--------------------------------------
	// 
	// 		draw a star dynamically
	//
	// 		use the mouse position as a pct
	//		to calc nPoints and internal point radius
	//
	float xPct = (float)(mouseX) / (float)(ofGetWidth());
	float yPct = (float)(mouseY) / (float)(ofGetHeight());
	int nTips = 5 + xPct * 60;
	int nStarPts = nTips * 2;
	float angleChangePerPt = TWO_PI / (float)nStarPts;
	float innerRadius = 0 + yPct*80;
	float outerRadius = 80;
	float origx = 525;
	float origy = 100;
	float angle = 0;
	
	ofSetColor(0xa16bca);
	ofBeginShape();
	for (int i = 0; i < nStarPts; i++){
		if (i % 2 == 0) {
			// inside point:
			float x = origx + innerRadius * cos(angle);
			float y = origy + innerRadius * sin(angle);
			ofVertex(x,y);
		} else {
			// outside point
			float x = origx + outerRadius * cos(angle);
			float y = origy + outerRadius * sin(angle);
			ofVertex(x,y);
		}
		angle += angleChangePerPt;
	}
	ofEndShape();
	//-------------------------------------
	
	//------(d)--------------------------------------
	// 
	// 		poylgon of random points
	//
	// 		lots of self intersection, 500 pts is a good stress test
	// 
	// 
	ofSetColor(0x0cb0b6);
	ofSetPolyMode(OF_POLY_WINDING_ODD);
	ofBeginShape();
	for (int i = 0; i < 10; i++){
		ofVertex(ofRandom(650,850), ofRandom(20,200));
	}
	ofEndShape();
	//-------------------------------------
	
	
	//------(e)--------------------------------------
	// 
	// 		use sin cos and time to make some spirally shape
	//
	glPushMatrix();
		glTranslatef(100,300,0);
		ofSetColor(0xff2220);
		ofFill();
		ofSetPolyMode(OF_POLY_WINDING_ODD);
		ofBeginShape();
		float angleStep 	= TWO_PI/(100.0f + sin(ofGetElapsedTimef()/5.0f) * 60); 
		float radiusAdder 	= 0.5f;
		float radius 		= 0;
		for (int i = 0; i < 200; i++){
			float anglef = (i) * angleStep;
			float x = radius * cos(anglef);
			float y = radius * sin(anglef); 
			ofVertex(x,y);
			radius 	+= radiusAdder; 
		}
		ofEndShape(OF_CLOSE);
	glPopMatrix();
	//-------------------------------------
	
	//------(f)--------------------------------------
	// 
	// 		ofCurveVertex
	// 
	// 		because it uses catmul rom splines, we need to repeat the first and last 
	// 		items so the curve actually goes through those points
	//

	ofSetColor(0x2bdbe6);
	ofBeginShape();
	
		for (int i = 0; i < nCurveVertexes; i++){
			
			
			// sorry about all the if/states here, but to do catmull rom curves
			// we need to duplicate the start and end points so the curve acutally 
			// goes through them.
			
			// for i == 0, we just call the vertex twice
			// for i == nCurveVertexes-1 (last point) we call vertex 0 twice
			// otherwise just normal ofCurveVertex call
			
			if (i == 0){
				ofCurveVertex(curveVertices[0].x, curveVertices[0].y); // we need to duplicate 0 for the curve to start at point 0
				ofCurveVertex(curveVertices[0].x, curveVertices[0].y); // we need to duplicate 0 for the curve to start at point 0
			} else if (i == nCurveVertexes-1){
				ofCurveVertex(curveVertices[i].x, curveVertices[i].y);
				ofCurveVertex(curveVertices[0].x, curveVertices[0].y);	// to draw a curve from pt 6 to pt 0
				ofCurveVertex(curveVertices[0].x, curveVertices[0].y);	// we duplicate the first point twice
			} else {
				ofCurveVertex(curveVertices[i].x, curveVertices[i].y);
			}
		}
		
	ofEndShape();
	
	
	// show a faint the non-curve version of the same polygon:
	ofEnableAlphaBlending();
		ofNoFill();
		ofSetColor(0,0,0,40);
		ofBeginShape();
			for (int i = 0; i < nCurveVertexes; i++){
				ofVertex(curveVertices[i].x, curveVertices[i].y);
			}
		ofEndShape(true);
		
		
		ofSetColor(0,0,0,80);
		for (int i = 0; i < nCurveVertexes; i++){
			if (curveVertices[i].bOver == true) ofFill();
			else ofNoFill();
			ofCircle(curveVertices[i].x, curveVertices[i].y,4);
		}
	ofDisableAlphaBlending();
	//-------------------------------------
	
	
	//------(g)--------------------------------------
	// 
	// 		ofBezierVertex
	// 
	// 		with ofBezierVertex we can draw a curve from the current vertex
	//		through the the next three vertexes we pass in.
	//		(two control points and the final bezier point)
	//		
	
	float x0 = 500;
	float y0 = 300;
	float x1 = 550+50*cos(ofGetElapsedTimef()*1.0f);
	float y1 = 300+100*sin(ofGetElapsedTimef()/3.5f);
	float x2 = 600+30*cos(ofGetElapsedTimef()*2.0f);
	float y2 = 300+100*sin(ofGetElapsedTimef());
	float x3 = 650;
	float y3 = 300;
	
	
	
	ofFill();
	ofSetColor(0xFF9933);
	ofBeginShape();
	ofVertex(x0,y0);
	ofBezierVertex(x1,y1,x2,y2,x3,y3);
	ofEndShape();
	
	
	ofEnableAlphaBlending();
		ofFill();
		ofSetColor(0,0,0,40);
		ofCircle(x0,y0,4);
		ofCircle(x1,y1,4);
		ofCircle(x2,y2,4);
		ofCircle(x3,y3,4);
	ofDisableAlphaBlending();
	
	
	
	//------(h)--------------------------------------
	// 
	// 		holes / ofNextContour
	// 
	// 		with ofNextContour we can create multi-contour shapes
	// 		this allows us to draw holes, for example... 
	//
	ofFill();
	ofSetColor(0xd3ffd3);
	ofRect(80,480,140,70);
	ofSetColor(0xff00ff);
	
	ofBeginShape();
		
		ofVertex(100,500);
		ofVertex(180,550);
		ofVertex(100,600);
		
		ofNextContour(true);
		
		ofVertex(120,520);
		ofVertex(160,550);
		ofVertex(120,580);
		
	ofEndShape(true);
	//-------------------------------------
	
	
	//------(i)--------------------------------------
	// 
	// 		CSG / ofNextContour
	// 
	// 		with different winding rules, you can even use ofNextContour to 
	// 		perform constructive solid geometry 
	// 		
	// 		be careful, the clockwiseness or counter clockwisenss of your multiple
	// 		contours matters with these winding rules.
	//
	// 		for csg ideas, see : http://glprogramming.com/red/chapter11.html
	// 
	// 		info about the winding rules is here:
	//		http://glprogramming.com/red/images/Image128.gif
	// 
	ofNoFill();
	
	
	glPushMatrix();
	
	ofSetPolyMode(OF_POLY_WINDING_ODD);
	
	ofBeginShape();
		
		ofVertex(300,500);
		ofVertex(380,550);
		ofVertex(300,600);
		
		ofNextContour(true);
		
		for (int i = 0; i < 20; i++){
			float anglef = ((float)i / 19.0f) * TWO_PI;
			float x = 340 + 30 * cos(anglef);
			float y = 550 + 30 * sin(anglef); 
			ofVertex(x,y);
			radius 	+= radiusAdder; 
		}
		

	ofEndShape(true);
	
	glTranslatef(100,0,0);
	
	ofSetPolyMode(OF_POLY_WINDING_NONZERO);	
	ofBeginShape();
		
		ofVertex(300,500);
		ofVertex(380,550);
		ofVertex(300,600);
		
		ofNextContour(true);
		
		for (int i = 0; i < 20; i++){
			float anglef = ((float)i / 19.0f) * TWO_PI;
			float x = 340 + 30 * cos(anglef);
			float y = 550 + 30 * sin(anglef); 
			ofVertex(x,y);
			radius 	+= radiusAdder; 
		}
		
	ofEndShape(true);
	
	glTranslatef(100,0,0);
	ofSetPolyMode(OF_POLY_WINDING_ABS_GEQ_TWO);
	ofBeginShape();
		ofVertex(300,500);
		ofVertex(380,550);
		ofVertex(300,600);
		ofNextContour(true);
		
		for (int i = 0; i < 20; i++){
			float anglef = ((float)i / 19.0f) * TWO_PI;
			float x = 340 + 30 * cos(anglef);
			float y = 550 + 30 * sin(anglef); 
			ofVertex(x,y);
			radius 	+= radiusAdder; 
		}
		
		
	ofEndShape(true);
	
	glPopMatrix();
	//-------------------------------------
	
	
	ofSetColor(0x000000);
	ofDrawBitmapString("(a) star\nwinding rule odd", 20,210);
	
	ofSetColor(0x000000);
	ofDrawBitmapString("(b) star\nwinding rule nonzero", 220,210);
	
	ofSetColor(0x000000);
	ofDrawBitmapString("(c) dynamically\ncreated shape", 420,210);
	
	ofSetColor(0x000000);
	ofDrawBitmapString("(d) random points\npoly", 670,210);
	
	ofSetColor(0x000000);
	ofDrawBitmapString("(e) fun with sin/cos", 20,410);
	
	ofSetColor(0x000000);
	ofDrawBitmapString("(f) ofCurveVertex\nuses catmull rom\nto make curved shapes", 220,410);
	
	ofSetColor(0x000000);
	ofDrawBitmapString("(g) ofBezierVertex\nuses bezier to draw curves", 460,410);
	
	
	ofSetColor(0x000000);
	ofDrawBitmapString("(h) ofNextContour\nallows for holes", 20,610);
	
	ofSetColor(0x000000);
	ofDrawBitmapString("(i) ofNextContour\ncan even be used for CSG operations\nsuch as union and intersection", 260,620);
	
	
}
void ofxTLKeyframes::draw(){
	
	if(bounds.width == 0 || bounds.height < 2){
		return;
	}
	
	if(shouldRecomputePreviews || viewIsDirty){
		recomputePreviews();
	}
	
	ofPushStyle();
	
	//draw current value indicator as a big transparent rectangle
	ofSetColor(timeline->getColors().disabledColor, 30);
	//jg play solo change
	//float currentPercent = sampleAtTime(timeline->getCurrentTimeMillis());
	float currentPercent = sampleAtTime(currentTrackTime());
	ofFill();
	ofRect(bounds.x, bounds.getMaxY(), bounds.width, -bounds.height*currentPercent);
	
	//***** DRAW KEYFRAME LINES
	ofSetColor(timeline->getColors().keyColor);
	ofNoFill();
	
	preview.draw();
	
	//**** DRAW KEYFRAME DOTS
	
	//**** HOVER FRAME
	if(hoverKeyframe != NULL){
		ofPushStyle();
		ofFill();
		ofSetColor(timeline->getColors().highlightColor);
		ofVec2f hoverKeyPoint = screenPositionForKeyframe( hoverKeyframe );
		ofCircle(hoverKeyPoint.x, hoverKeyPoint.y, 6);
		ofPopStyle();
	}

	//**** ALL CACHED VISIBLE KEYS
	ofSetColor(timeline->getColors().textColor);
	ofNoFill();
	for(int i = 0; i < keyPoints.size(); i++){
		ofRect(keyPoints[i].x-1, keyPoints[i].y-1, 3, 3);
	}
	
	//**** SELECTED KEYS
	ofSetColor(timeline->getColors().textColor);
	ofFill();
	for(int i = 0; i < selectedKeyframes.size(); i++){
		if(isKeyframeIsInBounds(selectedKeyframes[i])){
			ofVec2f screenpoint = screenPositionForKeyframe(selectedKeyframes[i]);
			float keysValue = ofMap(selectedKeyframes[i]->value, 0, 1.0, valueRange.min, valueRange.max, true);
			if(keysAreDraggable){
				string frameString = timeline->formatTime(selectedKeyframes[i]->time);
				timeline->getFont().drawString(ofToString(keysValue, 4), screenpoint.x+5, screenpoint.y-5);
			}
			ofCircle(screenpoint.x, screenpoint.y, 4);
		}
	}

	ofPopStyle();
}
Ejemplo n.º 27
0
//--------------------------------------------------------------
void testApp::draw(){
	//ofMap(ofGetMouseX(),0, ofGetWidth(), 0.0,1.0); the vlaue i want to map, min & max of the value, the min & max of the value i want to map to

	float xorig = ofGetMouseX();
	float yorig = ofGetMouseY();

    float SecXorig = ofGetMouseX(); //new postions
    float SecYorig  = ofGetMouseY();
    
    float ThirdXorig = ofGetMouseX(); //new postions
    float ThirdYorig  = ofGetMouseY();
    
    float FourthXorig = ofGetMouseX(); //new postions
    float FourthYorig  = ofGetMouseY();
    
	float angle = ofGetElapsedTimef() *10;
    float SecAngle = ofGetElapsedTimef() *100;
    float ThirdAngle = ofGetElapsedTimef() *1000;
    float FourthAngle = ofGetElapsedTimef() *20;
	
    
	float x = xorig  + radius * -cos(angle);//position the shape
	float y = yorig + radius * sin(angle);//make a  new x,y float to draw a new shape
    
    float x2 = SecXorig  + SecRadius * cos(SecAngle);
    float y2 = SecYorig  + SecRadius * sin(SecAngle);

    float x3 = ThirdXorig  + ThirdRadius * cos(ThirdAngle);
    float y3 = ThirdYorig  + ThirdRadius * sin(ThirdAngle);
    
    float x4 = FourthXorig  + FourthRadius * -cos(FourthAngle);
    float y4 = FourthYorig  + FourthRadius * sin(FourthAngle);
    
    
    
    // 1 shape
    //storing the points in the vector
	ofPoint temp;
	temp.x = x;
	temp.y = y;
    
	points.push_back(temp);
	if (points.size() > 1000){
		points.erase(points.begin());
	}

   
	//drawing the circle leading the line
	ofSetRectMode(OF_RECTMODE_CENTER);
	ofSetColor(128,0,83);
    ofFill();
	ofCircle(x,y,5);
    
    ofMesh lineMesh1;
    lineMesh1.setMode(OF_PRIMITIVE_LINE_STRIP);
    for (int i = 0 ; i < points.size() ; i++){
        float alpha = ofMap(i, 0, points.size(), 0.0, 0.3);
        
        lineMesh1.addColor( ofFloatColor(255.0/255.0, 0/225.0, 127.0/255.0, alpha));
        lineMesh1.addVertex(points[i]);
    }
    
    lineMesh1.draw();
    
    

    
    
    
    //2 shape
    temp.x = x2;
    temp.y = y2;
    
    SecPoints.push_back(temp);
	if (SecPoints.size() > 150){
		SecPoints.erase(SecPoints.begin());
	}
    
    ofSetRectMode(OF_RECTMODE_CENTER);
	ofSetColor(62,4,112);
    ofFill();
	ofCircle(x2,y2,5);
    
    ofMesh lineMesh2;
    lineMesh2.setMode(OF_PRIMITIVE_LINE_STRIP);
    for (int i = 0 ; i < SecPoints.size() ; i++){
        float alpha = ofMap(i, 0, SecPoints.size(), 0.0, 0.4);
        
        lineMesh2.addColor( ofFloatColor(52.0/255.0, 57.0/225.0, 153.0/255.0, alpha));
        lineMesh2.addVertex(SecPoints[i]);
    }
    
    lineMesh2.draw(); 
    

    
    
    //3 shape
    temp.x = x3;
    temp.y = y3;
    
    ThirdPoints.push_back(temp);
	if (ThirdPoints.size() > 100){
		ThirdPoints.erase(ThirdPoints.begin());
	}
     
    ofSetRectMode(OF_RECTMODE_CENTER);
	ofSetColor(166,70,0);
    ofFill();
	ofCircle(x3,y3,5);
    
    ofMesh lineMesh3;
    lineMesh3.setMode(OF_PRIMITIVE_LINE_STRIP);
    for (int i = 0 ; i < ThirdPoints.size() ; i++){
        float alpha = ofMap(i, 0, ThirdPoints.size(), 0.0, 0.4);
        
        lineMesh3.addColor( ofFloatColor(198.0/255.0,92.0/255.0,015.0/255.0, alpha) );
        
        lineMesh3.addVertex(ThirdPoints[i]);
    }

    lineMesh3.draw();
    


    //4 shape
    temp.x = x4;
    temp.y = y4;
    
    FourthPoints.push_back(temp);
	if (FourthPoints.size() > 250){
		FourthPoints.erase(FourthPoints.begin());
	}
    
    ofSetRectMode(OF_RECTMODE_CENTER);
	ofSetColor(0,123,37,80);
    ofFill();
	ofCircle(ofGetMouseX(),ofGetMouseY(),6);
    
    ofMesh lineMesh4;
    lineMesh4.setMode(OF_PRIMITIVE_LINE_STRIP);
    for (int i = 0 ; i < FourthPoints.size() ; i++){
        float alpha = ofMap(i, 0, FourthPoints.size(), 0.0, 0.4);
        
        lineMesh4.addColor( ofFloatColor(70.0/255.0, 114.0/255.0, 153.0/255.0, alpha));
        
        lineMesh4.addVertex(FourthPoints[i]);
    }
    
    lineMesh4.draw();
    



	
	
	
}
Ejemplo n.º 28
0
void DomeData :: draw() {
	editable = gui.getVisible();
	
	if(!editable) return;

	//level1.draw();
	
	
	ofPushStyle();
	ofPushMatrix();
	ofTranslate(940,480);
	
	level1Handle.render();
	level2Handle.render();
	level3Handle.render();
	level4Handle.render();
	startHandle.render();
	c1Handle.render();
	c2Handle.render();
	endHandle.render();
	
	
	ofSetLineWidth(3);
	ofSetColor(255,0,255);
	ofBezier(start, c1, c2, end);
	ofLine(start, c1);
	ofLine(end,c2);
	
	ofSetColor(0,255,255);
	
	ofTranslate(-300,0);
	
	ofPopMatrix();
	ofPushMatrix();
	
	ofTranslate(pos);
	
	ofRotateX(rotation->x);
	ofRotateY(rotation->y);
	ofRotateZ(rotation->z);
	ofScale(scale, scale, scale);

	
	ofSetColor(255, 100);
	ofSetLineWidth(0.5);

	ofPushMatrix();
	ofScale(scaleXY->x, scaleXY->y, scaleXY->z);
	for(float x = level4->x; x <= -level4->x; x+= level4->x / -5.0f) {
		ofLine(x, level4->y, x, end->y);
	}
	for(float y = level4->y; y >= end->y; y+= (end->y - level4->y)/10.0f) {
		
		ofLine(level4->x, y, -level4->x, y);
	}
	
	
	ofPopMatrix();
	
	ofSetColor(0,255,0);
	ofPoint scalarXY = scaleXY.get(); 
	
	for(float angle = 0; angle>= -90; angle-=divAngle) {
			ofPushMatrix();
			ofRotateY( angle);
			ofScale(scaleXY->x, scaleXY->y, scaleXY->z);
			ofSetLineWidth(0.5);

			ofBezier(start, c1, c2, end);
			ofSetLineWidth(3);
			
			ofCircle(level1, 1);
			ofCircle(level2, 1);
			ofCircle(level3, 1);
			ofCircle(level4, 1);

			ofPopMatrix();
			
			ofPushMatrix();
			ofRotateY( -180 - angle);
			ofScale(scaleXY->x, scaleXY->y, scaleXY->z);
			ofSetLineWidth(0.5);
			
			//ofBezier(start, c1, c2, end);
			ofSetLineWidth(3);
			
			ofCircle(level1, 1);
			ofCircle(level2, 1);
			ofCircle(level3, 1);
			ofCircle(level4, 1);
			
			ofPopMatrix();
			
	}

	ofPopStyle();
	ofPopMatrix();
	
	
	//gui.draw();
	
}
Ejemplo n.º 29
0
void creature::draw() {
	
	ofSetColor(color);
	ofFill();
	
	//	for (int i = 0; i < particles.size(); i++){
	//		particles[i]->draw();
	//	}
	//
	//	for (int i = 0; i < springs.size(); i++){
	//		springs[i].draw();
	//	}
	
	// draw the whole thing as one shape so that you can tell
	// when the feet are inside the body. kind of cute!
	
	//	ofBeginShape();
	//	
	//	ofVertex(particles[0]->pos.x, particles[0]->pos.y);
	//	ofVertex(particles[1]->pos.x, particles[1]->pos.y);
	//	
	//	ofVertex(particles[4]->pos.x, particles[4]->pos.y);
	//	
	//	ofVertex(particles[6]->pos.x, particles[6]->pos.y);
	//	ofVertex(particles[7]->pos.x, particles[7]->pos.y);
	//	
	//	ofVertex(particles[5]->pos.x, particles[5]->pos.y);
	//	
	//	ofVertex(particles[2]->pos.x, particles[2]->pos.y);
	//	ofVertex(particles[3]->pos.x, particles[3]->pos.y);
	//	
	//	ofVertex(particles[0]->pos.x, particles[0]->pos.y);
	//	
	//	ofEndShape();
	
	
	// different method for drawing the creature with different
	// shapes for body and legs. i like it a bit more.
	ofBeginShape();
	ofVertex(particles[0]->pos.x, particles[0]->pos.y);
	ofVertex(particles[1]->pos.x, particles[1]->pos.y);
	ofVertex(particles[2]->pos.x, particles[2]->pos.y);
	ofVertex(particles[3]->pos.x, particles[3]->pos.y);
	ofEndShape();
	
	ofBeginShape();
	ofVertex(particles[1]->pos.x, particles[1]->pos.y);
	ofVertex(particles[4]->pos.x, particles[4]->pos.y);
	ofVertex(particles[6]->pos.x, particles[6]->pos.y);
	ofEndShape();

	ofBeginShape();
	ofVertex(particles[2]->pos.x, particles[2]->pos.y);
	ofVertex(particles[5]->pos.x, particles[5]->pos.y);
	ofVertex(particles[7]->pos.x, particles[7]->pos.y);
	ofEndShape();
	

	// draw the eyes
	// calculate a point partway between the top two points
	// calculate a point partway between the bottom two points
	// then calculate a point partway between these two points
	ofPoint leftShiftedTop = particles[0]->pos.getInterpolated(particles[3]->pos, 0.15);
	ofPoint leftShiftedBot = particles[1]->pos.getInterpolated(particles[2]->pos, 0.15);
	ofPoint leftEye = leftShiftedTop.getInterpolated(leftShiftedBot, 0.15);

	ofPoint rightShiftedTop = particles[0]->pos.getInterpolated(particles[3]->pos, 0.85);
	ofPoint rightShiftedBot = particles[1]->pos.getInterpolated(particles[2]->pos, 0.85);
	ofPoint rightEye = rightShiftedTop.getInterpolated(rightShiftedBot, 0.15);
	
	ofSetColor(50, 200);
	ofCircle(leftEye, size/13);
	ofCircle(rightEye, size/13);
	
}
Ejemplo n.º 30
0
//--------------------------------------------------------------
void testApp::draw(){
    ofBackground(10);
    
    int nVerts = 0;
    
    
    ofNoFill();
    ofRectangle rect = verdana200.getStringBoundingBox(text, 0,0);

    //Size of typo rects boundaries
    float typoPosX = rect.width/2;
    float typoPosY = rect.height/2;

    //Size & Position typoshapes
    
    
    //R
    tam = ofLerp(tam, 100, amount);
    tamX = ofLerp(tamX, typoPosX, amount);
    tamY = ofLerp(tamY, typoPosY, amount);

    
    ofPushMatrix();
//    {
    
//        ofTranslate((ofGetWidth()/2.0)-(bb.getWidth()/2.0), (ofGetHeight()/2.0)+(bb.height/2.0));
          ofTranslate(    ofGetWidth()/2.0, ofGetHeight()/2.0 );
//        ofRect(rect.x, rect.y, rect.width, rect.height);
        

        //FIRST ELEMENTS
        ofSetColor(myColor);
        ofFill();
        ofCircle(rect.x, rect.y + typoPosY*2, rect.height/2 + tam);

        
    
        // Create a bunch of Letter objects
        vector<ofPath> letterPaths = font.getStringAsPoints(text);
        for(int i=0; i<letterPaths.size(); i++)
        {
            vector<ofPolyline> lines = letterPaths[i].getOutline();
            for(int j=0; j<lines.size(); j++)
            {
                ofPolyline line = lines[j];
                line.simplify();
                
                ofBeginShape();
                for(int k=0; k<line.size(); k++)
                {
                    ofSetColor(200, 150);
//                    ofVertex(line[k].x + 0 + typoPosY + ofRandom(200), line[k].y + typoPosY + ofRandom(200) );z
                    ofVertex(line[k].x  - typoPosX, line[k].y  + typoPosY );

                    
                    
                    ofSetColor(myColor/2, 200);
                    ofNoFill();
                    ofCircle(line[k].x - typoPosX, line[k].y + typoPosY, tam/2);
                    nVerts++;
                }
                ofEndShape(true);
            }
        }
    //}
    ofSetColor(255, 180);
    verdana200.drawString(text,  0 - typoPosX, 0 + typoPosY);

    ofPopMatrix();
    

    
}