//---------------------------------
void GeneratedMesh::setup(ofxBulletWorldRigid &world, ofVec3f position, string url, ofVec3f ModelScale){
    type = ShapeTypeAnimatedMesh;
    collisionTime = -120;
    ModelPath = url;
    this->position = position;
    this->world = &world;
	
    //rotation = btQuaternion(btVector3(0,1,0), ofDegToRad(-90));
    
    //TODO to try with ofBtGetCylinderCollisionShape, for improve collision detection
    
    
    anisotropy = 4.;
    
    float fboDiv = 4.f;
    //    ofSetMinMagFilters( GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR_MIPMAP_LINEAR );
    fbo.allocate( (float)ofGetWidth() / fboDiv, (float)ofGetWidth() / fboDiv, GL_RGB, 4 );
    fbo.begin(); {
        ofClear(0, 0, 0, 255 );
        ofSetColor( 11,90,121, 255);
        ofRect(0, 0, ofGetWidth(), ofGetHeight() );
        ofSetColor(120, 140, 150, 255);
        
        int numIterations = 4;
        float inc = (float)fbo.getWidth() / ((float)numIterations);
        for( int i = 0; i < numIterations; i++ ) {
            float tx = (float)i*inc + inc;
            float ty = (float)i*inc + inc;
            
            ofSetColor(152,197,190, 255);
            ofSetLineWidth( 1.5 );
            if( i % 2 == 0 ) ofSetLineWidth( 0.5 );
            
            ofLine( tx, 0, tx, fbo.getHeight() );
            ofLine( 0, ty, fbo.getWidth(), ty );
        }
        
    } fbo.end();
    
    ofSetLineWidth( 1 );
    
    fbo.getTextureReference().bind();
    glGenerateMipmap( fbo.getTextureReference().texData.textureTarget);
    ofSetMinMagFilters( GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR_MIPMAP_LINEAR );
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, anisotropy);
    //    glSamplerParameterf( fbo.getTextureReference().texData.textureTarget, GL_TEXTURE_MAX_ANISOTROPY_EXT, 2 );
    fbo.getTextureReference().unbind();

    
    omesh = ofMesh::plane( 70, 70, 14, 14, OF_PRIMITIVE_TRIANGLES );
    ofQuaternion rquat;
    rquat.makeRotate( 90, 1, 0, 0);
    ofSeedRandom();
    float rseed = ofRandom(0, 10000);
    vector< ofVec3f >& verts = omesh.getVertices();
    for( int i = 0; i < verts.size(); i++ ) {
        verts[i] = rquat * verts[i];
        verts[i].y = ofSignedNoise( verts[i].x*0.02, verts[i].y*0.02 + verts[i].z*0.02, ofGetElapsedTimef() * 0.1 + rseed ) * 3;
    }
    
    vector< ofVec2f >& tcoords = omesh.getTexCoords();
    for( int i = 0; i < tcoords.size(); i++ ) {
        tcoords[i].x *= 4.f;
        tcoords[i].y *= 4.f;
    }
    mesh = omesh;
    
    
    //ofEnableSeparateSpecularLight();
    
	//save init values
	initScale = scale;
    // create ofxBullet shape
    //body.create(world.world, position, 0); // we set m=0 for kinematic body
    body.create( world.world, mesh, position, 0.f, ofVec3f(-10000, -10000, -10000), ofVec3f(10000,10000,10000) );
    body.add();
    body.enableKinematic();
    body.setActivationState( DISABLE_DEACTIVATION );
    
    
    bAnimate = true;

    body.add();
    
	
    //body.setProperties(1., 0.); // .25 (more restituition means more energy) , .95 ( friction )
    // to add force to the ball on collision set restitution to > 1
	
	body.setProperties(3, .95); // restitution, friction
	body.setDamping( .25 );
    
	
	//Set Rotation Objects
	setupRot();
	
    body.activate();
	
	setDefaultZ();
    

    
    
    
}
//--------------------------------------------------------------
void calibrationManager::draw(){

	// draw a light grid:

	if (!bPreAutomatic || !bAutomatic) panel.draw();

	ofEnableAlphaBlending();
	ofSetColor(30, 30, 30, (int) (255 - 255 *  menuEnergy));
	ofRect(0,0,ofGetWidth(), ofGetHeight());

//	ofSetColor(255, 255, 255, 40);
//	for (int i = 0; i < nDivisionsWidth; i++){
//		float xLine = calibrationRectangle.x + ((float)calibrationRectangle.width / (float)(nDivisionsWidth-1)) * i;
//		ofLine(xLine, calibrationRectangle.y,xLine, calibrationRectangle.y + calibrationRectangle.height);
//	}
//
//	for (int i = 0; i < nDivisionsHeight; i++){
//		float yLine = calibrationRectangle.y + calibrationRectangle.height - ((float)calibrationRectangle.height / (float)(nDivisionsHeight-1)) * i;
//		ofLine(calibrationRectangle.x,yLine, calibrationRectangle.x + calibrationRectangle.width,yLine);
//	}

	//-----------------------------------------------------------------------
	//-----------------------------------------------------------------------
	if (fitter.bBeenFit != true){

		ofEnableAlphaBlending();

		float rad = 30;
		glLineWidth(4);
		ofSetColor(255, 255, 255, 100);
		ofLine (xp, yp-rad, xp, yp+rad);
		ofLine (xp-rad, yp, xp+rad, yp);;


		ofSetColor(255, 255, 255, 255);

		if (bAutomatic == true && bAmInAutodrive == true && bInAutoRecording){
		} else {
			ofCircle(xp, yp, rad*0.33);
		}

		ofFill();

		//
		// TODO: do some animation stuff here:
		if (bAutomatic == true && bAmInAutodrive == true){

			if (bInAutoRecording){

				ofSetColor(255, 0, 0, 200);
				ofCircle(xp, yp, 26);

				ofSetColor(255, 255,255);
				ofCircle(xp, yp, 5);

			} else {
				ofNoFill();
				ofSetColor(255, 255, 255, 150);
				ofCircle(xp, yp, 200 - 200* autoPct);
				ofFill();
			}
		}

		glLineWidth(1);
		ofFill();

		if (!bAutomatic)
		if (inputEnergy > 0){
			ofSetColor(255, 0, 127, (int) (60*inputEnergy));
			ofCircle(xp, yp, rad * 3.5 );

			ofSetColor(255, 0, 127, (int) (150*inputEnergy));
			ofCircle(xp, yp, rad );
		}

		ofSetColor(255, 255, 255);
		//calibrationInfo.draw(100,100);
	}
	
	//-----------------------------------------------------------------------
	//-----------------------------------------------------------------------

	if (!bAutomatic && !bPreAutomatic){

		if (!fitter.bBeenFit)	{
			ofSetColor(255, 0, 0,127);
			font.drawString("not calibrated", 100,100);
		} else {
			ofSetColor(0, 255, 0, 127);
			font.drawString("calibrated", 100,100);
		}
	}

	if (bPreAutomatic == true){
		calibrationInfo.draw(100,100);
//		cout << bPreAutomatic << endl;
	}

	fitter.draw();
}
//--------------------------------------------------------------
void testApp::draw(){
    
    // gray rectangle
    ofSetColor(240);
    ofRect(0, 430, ofGetWindowWidth(), 40);
    
    // black dot
    ofSetColor(0);
    ofCircle(50, 450, 15);
    
    // red dot
    ofSetColor(255, 0, 0);
    ofCircle(100, 450, 15);
    
    // green dot
    ofSetColor(0, 255, 0);
    ofCircle(150, 450, 15);
    
    // blue dot
    ofSetColor(0, 0, 255);
    ofCircle(200, 450, 15);
    
    // heart indicator
    ofSetColor(255);
    gHeart.draw(400, 450);
    
    // if the drawer has requested to save, draw a half-heart
    // (will just draw on top of other one
    if ( bSaveRequestSent ) {
        rHeart.draw(400, 450);
    }
    if ( bSaveRequestReceived ) {
        lHeart.draw(400, 450);
    }
    
    if (bSaveRequestSent && bSaveRequestReceived ) {
        fullHeart.draw(400, 450);
    }
    
    // drawing indicator for what color is selected
    ofNoFill();
    ofSetColor(100);
    if (penColor == ofColor(0, 0, 0) ) {
        ofCircle(50, 450, 18);
    } else if (penColor == ofColor(255, 0, 0) ) {
        ofCircle(100, 450, 18);
    } else if (penColor == ofColor(0, 255, 0) ) {
        ofCircle(150, 450, 18);
    } else if (penColor == ofColor(0, 0, 255) ) {
        ofCircle(200, 450, 18);
    }
    ofFill();
    
    ofSetColor( penColor );
    
    // local drawing
    if ( bIsDrawing ) {
        ofLine(lastX, lastY, mouseX, mouseY);
        
        // every time we draw a line, send a message to the remote app
        spacebrew.sendRange("lastPosX", lastX);
        spacebrew.sendRange("lastPosY", lastY);
        spacebrew.sendRange("posX", mouseX);
        spacebrew.sendRange("posY", mouseY);
        
        lastX = mouseX;
        lastY = mouseY;
    }
    
    // draw remote information
    // note, the remote variables will update only when
    // the app receives all four within one frame
    ofSetColor(remoteColor);
    ofLine(remoteLastX, remoteLastY, remoteX, remoteY);
    
    if ( bSaveRequestReceived && bSaveRequestSent ) {
        // fullHeart.draw(400, 450); // note: if draw heart here, is black in saved .png file
        ofSaveFrame();
        bSaveRequestReceived = false;
        bSaveRequestSent = false;
        ofSetColor( 255, 255, 255 );
        ofRect(0, 0, ofGetWindowWidth(), ofGetWindowHeight());
    }
}
Exemple #4
0
//--------------------------------------------------------------
void ofApp::draw(){
	static float pTime = 0, nowTime = 0;

	nowTime = ofGetElapsedTimef();

	static int frame = 0;
#ifdef ONCE
#ifdef STRETCH
	cam.begin();
	link->solveU(nowTime - pTime);
	//link->solveV(nowTime - pTime);

	// 绿-z
	ofSetColor(0, 255, 0);
	ofLine(ofVec3f(20, 25, 0), ofVec3f(20, 25, 1000));
	// 红-y
	ofSetColor(255, 0, 0);
	ofLine(ofVec3f(20, 25, 0), ofVec3f(20, 1025, 0));
	// 蓝-x
	ofSetColor(0, 0, 255);
	ofLine(ofVec3f(20, 25, 0), ofVec3f(1020, 25, 0));
	//ofLine(ofVec3f(20, 25, 0), ofVec3f(25, 25, 5));

	link->draw();

	cout << "length: " << (node1->position - node2->position).length() << std::endl << std::endl;
	cout << "deltaU: " << node2->u - node1->u << std::endl << std::endl;
	cam.end();
#endif

#ifdef BEND
	cam.begin();
	bLink->solveU(nowTime - pTime);

	// 绿-z
	ofSetColor(0, 255, 0);
	ofLine(ofVec3f(20, 25, 0), ofVec3f(20, 25, 1000));
	// 红-y
	ofSetColor(255, 0, 0);
	ofLine(ofVec3f(20, 25, 0), ofVec3f(20, 1025, 0));
	// 蓝-x
	ofSetColor(0, 0, 255);
	ofLine(ofVec3f(20, 25, 0), ofVec3f(1020, 25, 0));
	//ofLine(ofVec3f(20, 25, 0), ofVec3f(25, 25, 5));

	bLink->draw();

	//cout << "length: " << (node1->position - node2->position).length() << std::endl << std::endl;
	//cout << "deltaU: " << node2->u - node1->u << std::endl << std::endl;
	cam.end();

#endif // !BEND

#ifdef SHEAR
	cam.begin();
	sLink->solve(nowTime - pTime);

	// 绿-z
	ofSetColor(0, 255, 0);
	ofLine(ofVec3f(20, 25, 0), ofVec3f(20, 25, 1000));
	// 红-y
	ofSetColor(255, 0, 0);
	ofLine(ofVec3f(20, 25, 0), ofVec3f(20, 1025, 0));
	// 蓝-x
	ofSetColor(0, 0, 255);
	ofLine(ofVec3f(20, 25, 0), ofVec3f(1020, 25, 0));
	//ofLine(ofVec3f(20, 25, 0), ofVec3f(25, 25, 5));

	sLink->draw();

	cam.end();
#endif // SHEAR
#endif // !ONCE


#ifdef TEST
#ifdef OFFLINE_RENDERING
	if(frame < FRAME_NUM)
	{
		fboList[frame]->begin();

		if(wovenCloth[13]->velocity.z < 10)
			wovenCloth[13]->velocity.z += 4.0;

		//float deltaT = nowTime - pTime;
		float deltaT = 0.05;
		//cout << deltaT << endl;
#endif // OFFLINE_RENDERING
		for(int i=0; i<stretchLinkList.size(); i++)
		{
			if(stretchLinkList[i]->bType == 1)
				stretchLinkList[i]->solveU(deltaT);
			else
				stretchLinkList[i]->solveV(deltaT);
		}

		for(int i=0; i<bendLinkList.size(); i++)
		{
			if(bendLinkList[i]->bType == 1)
				bendLinkList[i]->solveU(deltaT);
			else
				bendLinkList[i]->solveV(deltaT);
		}

		for(int i=0; i<shearLinkList.size(); i++)
		{
			shearLinkList[i]->solve(deltaT);
		}

		//for(int i=0; i<parallelContactLinkList.size(); i++)
		//{
		//	if(parallelContactLinkList[i]->bType == 1)
		//		parallelContactLinkList[i]->solveU(nowTime - pTime);
		//	else
		//		parallelContactLinkList[i]->solveV(nowTime - pTime);
		//}

		for(int i=0; i < wovenCloth.size(); i++)
		{
			wovenCloth[i]->velocity -= 0.1*wovenCloth[i]->velocity;
			wovenCloth[i]->velocityUV -= 0.1*wovenCloth[i]->velocityUV;
		}

		cam.begin();
		for(int i=0; i<drawLinkList.size(); i++)
		{
			if(i != drawLinkList.size()-1)
				drawLinkList[i]->draw(false, ofToString(frame));
			else
				// 最后一次循环保存模型文件
				drawLinkList[i]->draw(true, ofToString(frame));
		}
		cam.end();

#ifdef OFFLINE_RENDERING
		fboList[frame]->end();
		frame++;

		printf("渲染百分比: %d%%\n", frame * 100 / FRAME_NUM);
	}

	pTime = nowTime;

	if(frame >= FRAME_NUM)
	{
		static int nowFrame = 0;
		fboList[nowFrame]->draw(0, 0);
		nowFrame = (nowFrame + 1) % FRAME_NUM;
	}
#endif // OFFLINE_RENDERING
#endif // TEST

	ofSetColor(0);
	font.drawString(ofToString(ofGetFrameRate()), 50, 50);
}
//--------------------------------------------------------------
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();
	ofSetColor(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.
	ofSetColor(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));
	}
	ofSetColor(0x000000);
	ofDrawBitmapString("rectangles", 275,500);

	//---------------------------  transparency
	ofSetColor(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();

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

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

	if (bSmooth){
		ofEnableSmoothing();
	}

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

	if (bSmooth){
		ofDisableSmoothing();
	}

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

}
void ofApp::draw(){
     // draw raw camera feed and thresholded camera feed
     
     ofSetColor(255,255,255);
     cam.image.draw(camW * scale, 0, camW * scale, camH * scale) ;
     cvImage.draw(0, 0, camW * scale, camH * scale);

    //ARTK DEBUGGING STUFF
    int numDetected = artk.getNumDetectedMarkers();
    ofScale (scale, scale, scale);
    
    for(int i=0; i<numDetected; i++) {
        ofPoint pos = artk.getDetectedMarkerCenter(i);
        // float dir = artk.getOrientationQuaternion(i).x();
        // SWITCH ME OUT COACH
        float dir = artk.getDetectedMarkerDirection(i);
        int id = artk.getMarkerID(i);
        ofImage drone;

        untimedData[ofToString(id)]["position"] = ofToString(pos.x) + ", " + ofToString(pos.y);
        untimedData[ofToString(id)]["rotation"] = ofToString(dir);

        drone.setFromPixels(vid.getPixelsRef());
        drone.crop(pos.x - closeSize /2, pos.y - closeSize / 2, closeSize, closeSize);
        drone.draw(i * 120, 0);
    }

    
     for(int p = 0; p < contourFinder.getPolylines().size(); p++) {
     
     // get and draw the current polyline
     
     ofSetColor(255,0,0);
     ofPolyline pl = contourFinder.getPolyline(p).getResampledBySpacing(1).getSmoothed(20);
     pl.draw();
     
     // find changes of angle of each segment of the contour
     
     int segmentSize = 15;
     
     for(int i = 0; i < pl.size(); i += segmentSize) {
     
     // draw where this segment of the contour starts
     
     ofSetColor(0,0,255);
     ofPoint tpos = pl.getVertices()[i];
     ofCircle(tpos.x, tpos.y, 2);
     
     ofSetColor(0,255,0);
     
     if(pl.size()-i >= segmentSize) {
     
     // find total change in direction over these points
     
     ofVec3f diff1 =  (pl.getVertices()[i+0]
     -pl.getVertices()[i+1]);
     ofVec3f diff2 =  (pl.getVertices()[i+segmentSize-2]
     -pl.getVertices()[i+segmentSize-1]);
     diff1.normalize();
     diff2.normalize();
     float a1 = atan(diff1.y/diff1.x);
     float a2 = atan(diff2.y/diff2.x);
     float totalChange = (a1 - a2)*57.2957795;
     
     // if the change was big enough, we found a triangle edge
     
     if((diff1-diff2).length() > 1) {
     ofSetColor(0,255,255);
     ofPoint pos = pl.getVertices()[i+4];
     ofCircle(pos.x, pos.y, 5);
     }
     
     // draw the angles (debug)
     
     ofPoint pos = pl.getVertices()[i];
     ofSetColor(0,255,0);
     ofLine(pos.x, pos.y, pos.x+diff1.x*10, pos.y+diff1.y*10);
     ofSetColor(255,0,0);
     ofLine(pos.x, pos.y, pos.x+diff2.x*10, pos.y+diff2.y*10);
     
            }
     
        }
     
     }

}
Exemple #7
0
//--------------------------------------------------------------
void Spring::draw(){
    ofLine(s1->pos,s2->pos);
}
void DistanceConstraint::draw(){
	ofLine(indices[0]->x.x,indices[0]->x.y,indices[0]->x.z,indices[1]->x.x,indices[1]->x.y,indices[1]->x.z);
}
Exemple #9
0
//--------------------------------------------------------------
void ofApp::draw()
{

	ofBackground(ofColor(120,120,120));
    
    ofSetColor(100);
        if (sensor0 == true)
        {
        	ofDrawBitmapString("I am sad..make me happy...", 50, 50);
        	 ofEllipse(250, 250, 300 ,300);
        	  ofSetColor(0,0,255);
  			  ofFill();
			  ofRect(200, 210 , 30, 50);
			  ofSetColor(0,0,255);
			  ofFill();
			  ofRect(300, 210 , 30, 50);
			  ofSetColor(0,0,255);
			  ofFill();
			  //ofBezier(150, 295, 200, 370, 300, 370, 350, 295);
			  ofLine(150, 295, 350, 295);
			  ofLine(160, 180, 210, 135);
			  ofLine(160, 180, 290, 180);
        	
            
        }
        	
        

        if ((sensor0 == false) && (sensor1 == true))
        {
        	ofDrawBitmapString("Hey! You are awesome!", 50,50);
        	
        	 ofEllipse(250, 250, 300 ,300);
        	 ofSetColor(0,0,255);
  			  ofFill();
			  ofEllipse(200, 210 , 30, 70);
			  ofSetColor(0,0,255);
			  ofFill();
			  ofEllipse(300, 210 , 30, 70);
			  ofSetColor(0,0,255);
			  ofFill();
			  ofBezier(150, 295, 200, 370, 300, 370, 350, 295);
			  ofLine(150, 295, 350, 295);
			//  ofLine(160, 180, 210, 135);
			 // ofLine(160, 180, 290,180 ); 

        }


         if ((sensor0 == false) && (sensor1 == false) && (sensor2 == true)){
        	  ofDrawBitmapString("Hahahahaha", 50,50);
        	
        	 ofEllipse(250, 250, 300 ,300);
        	 ofSetColor(0,0,255);
  			  ofFill();
			  ofEllipse(200, 210 , 30, 70);
			  ofSetColor(0,0,255);
			  ofFill();
			  ofEllipse(300, 210 , 30, 70);
			  ofSetColor(0,0,255);
			  ofFill();
			 // ofBezier(150, 295, 200, 370, 300, 370, 350, 295);
			  ofEllipse(245,295,150,50);
			  //ofLine(150, 295, 350, 295); 
			//  ofLine(160, 180, 210, 135);
			 // ofLine(160, 180, 290,180 );
			}
	
}
void ofxComposer::customDraw(){
    ofPushView();
    ofPushStyle();
    ofPushMatrix();

    ofEnableAlphaBlending();
    
#ifdef USE_OFXGLEDITOR
    //  Draw the GLEditor if it�s not inside a Patch
    //
    if (bEditMode && !bGLEditorPatch){
        ofPushMatrix();
        ofRotate(180, 1, 0, 0);
        ofTranslate(0, -ofGetWindowHeight());
        ofSetColor(editorFgColor);
        editorFbo.draw(0, 0);
        ofPopMatrix();
    }
#endif
    
    //  Draw Patches
    //
    for(map<int,patch*>::iterator it = patches.begin(); it != patches.end(); it++ ){
        it->second->customDraw();
    }
    
    //  Draw active line
    //
    //mili
    ofVec3f mouse_transformed = ofVec3f(ofGetMouseX(), ofGetMouseY(), 0.0)*this->getGlobalTransformMatrix();
    //
    if (selectedDot >= 0){
        ofLine(patches[selectedDot]->getOutPutPosition(), ofPoint(mouse_transformed.x,mouse_transformed.y));
    }
    
    //mili - nodes aligned
    ofVec3f scale = ((ofCamera*)this->getParent())->getScale();
    if (verticalAlign1) {
        ofSetColor(255, 208, 111);
        ofLine(verticalAlign1, 0, verticalAlign1, ofGetHeight()*scale.y);
    }
    if (verticalAlign2) {
        ofSetColor(255, 208, 111);
        ofLine(verticalAlign2, 0, verticalAlign2, ofGetHeight()*scale.y);
    }
    if (verticalAlign3) {
        ofSetColor(255, 208, 111);
        ofLine(verticalAlign3, 0, verticalAlign3, ofGetHeight()*scale.y);
    }
    if (horizontalAlign1) {
        ofSetColor(255, 208, 111);
        ofLine(0, horizontalAlign1, ofGetWidth()*scale.x, horizontalAlign1);
    }
    if (horizontalAlign2) {
        ofSetColor(255, 208, 111);
        ofLine(0, horizontalAlign2, ofGetWidth()*scale.x, horizontalAlign2);
    }
    if (horizontalAlign3) {
        ofSetColor(255, 208, 111);
        ofLine(0, horizontalAlign3, ofGetWidth()*scale.x, horizontalAlign3);
    }
    //
        
    //  Draw Help screen
    //
    if (bHelp){
        ofSetColor(255);
        ofDrawBitmapString(helpScreen, 20, ofGetWindowHeight()*0.5- 11.0*15.0);
    }
    
    ofDisableBlendMode();
    ofEnableAlphaBlending();

    ofPopMatrix();
    ofPopStyle();
    ofPopView();
    
    
    // nico multipleSelect
    ofPushMatrix();
        ofNoFill();
        ofRect(multipleSelectRectangle);
    ofPopMatrix();
    
}
void testApp::draw()
{
    char str[32];
	// 背景は黒
	//ofBackground(0, 0, 0);
	
    // 取得したFFTの値は
    // bd.magnitude[i] のようにすればアクセス可能
    // 以下では取得したFFTをbd.magnitude[i]の形式でアクセスしてFFTを描画する

    // 生のFFTの値を描画 (1列目)
    ofSetColor(155,155,75);
    for (int i = 1; i < (int)testApp_fft_size/2; i++){
        if(i % 16 == 0)
            ofSetColor(200,0,0);
        else
            ofSetColor(155,155,75);
		ofLine(10+(i*3),150,       10+(i*3),150-bd.magnitude[i]*10.0f);
        //printf("%f \n", magnitude_average[i]);
	}
    // 画面に入りきらないので2列目
    for (int i = (int)testApp_fft_size/2,b = 1; i<testApp_fft_size ; i++){
        if(i % 16 == 0)
            ofSetColor(200,0,0);
        else
            ofSetColor(155,155,75);
		ofLine(10+(b*3),300,      10+(b*3),300-bd.magnitude[i]*10.0f);
        b++;
        //printf("%f \n", magnitude_average[i]);
	}


    // 平均化されたFFTの値を描画 (1列目)
    ofSetColor(134,113,89);
	for (int i = 1; i < (int)testApp_fft_size/2; i++){
        if(i % 16 == 0)
            ofSetColor(200,0,0);
        else
            ofSetColor(134,113,89);
		ofLine(10+(i*3),500,       10+(i*3),500-bd.magnitude_average[i]*10.0f);
        //printf("%f \n", magnitude_average[i]);
	}
    // 画面に入り切らないので2列
    for (int i = (int)testApp_fft_size/2,b = 1; i<testApp_fft_size ; i++){
        if(i % 16 == 0)
            ofSetColor(200,0,0);
        else
            ofSetColor(134,113,89);
		ofLine(10+(b*3),650,      10+(b*3),650-bd.magnitude_average[i]*10.0f);
        b++;
        //printf("%f \n", magnitude_average[i]);
	}

    //ofSetColor(200,200,200);
	//for (int i = 1; i < (int)testApp_fft_size/2; i++){
	//	//ofLine(200+(i*4),200,200+(i*4),400-magnitude[i]*10.0f);
    //    //ofLine(10+(i*5.3),400,  10+(i*5.3),400-magnitude[i]*10.0f);
    //    sprintf(str, "%.0f", magnitude[i]);
    //    fbook.drawString(str,5+(i*7), 270);
    //    fbook.drawString(str,10+(i*5.3),250-magnitude[i]*10.0f);
    //}

    // ドラム音の検出
    if(drumVisible){
        if(bd.isBeatRange(0,2,2)){
            ofSetColor(255,0,0);
            //ofRect(100,700,200,50);
            fbook.drawString("DRUM!!",100,735);
        }else{
            ofSetColor(0,255,0);
            ofRect(100,700,200,50);
        }
    }

    // スネア音の検出
    if(snareVisible){
        if(bd.isBeatRange(12,18,4)){
            ofSetColor(255,0,0);
            //ofRect(350,700,200,50);
            fbook.drawString("SNARE!!", 350, 735);
        }else{
            ofSetColor(0,255,0);
            ofRect(350,700,200,50);
        }
    }

    // ハイハット音の検出
    if(hihatVisible){
        if(bd.isBeatRange(27,31,3)){
            ofSetColor(255,0,0);
            //ofRect(600,700,200,50);
            fbook.drawString("HiHat!!", 600, 735);
        }else{
            ofSetColor(0,255,0);
            ofRect(600,700,200,50);
        }
    }

}
//-------------------------------
void ofxControlPanel::draw(){
    if( hidden ) return;

    ofPushStyle();
    ofEnableAlphaBlending();

        float panelH = boundingBox.height;
        if( minimize ){
            panelH = topBar.height;
        }

        glPushMatrix();
            glTranslatef(boundingBox.x, boundingBox.y, 0);
            //draw the background
            ofFill();
            glColor4fv(bgColor.getColorF());
            ofRect(0, 0, boundingBox.width, panelH);

            //draw the outline
            ofNoFill();
            glColor4fv(outlineColor.getColorF());
            ofRect(0, 0, boundingBox.width, panelH);
            ofLine(0, topBar.height, boundingBox.width, topBar.height);
        glPopMatrix();

        ofRect(minimizeButton.x, minimizeButton.y, minimizeButton.width, minimizeButton.height);

	if ( bDoSaveRestore )
	{
        ofPushStyle();
            ofFill();

            if( saveDown )glColor4fv(fgColor.getSelectedColorF());
            else glColor4fv(fgColor.getColorF());

            ofRect(saveButton.x, saveButton.y, saveButton.width,saveButton.height);
            ofSetColor(255, 255, 255);
		if(bUseTTFFont) {
			guiTTFFont.drawString("save", saveButton.x + 3, saveButton.y + saveButton.height -4);
		}
		else {
			ofDrawBitmapString("save", saveButton.x + 3, saveButton.y + saveButton.height -3);
		}

        ofPopStyle();

        ofPushStyle();
            ofFill();

            if( restoreDown )glColor4fv(fgColor.getSelectedColorF());
            else glColor4fv(fgColor.getColorF());

            ofRect(restoreButton.x, restoreButton.y, restoreButton.width,restoreButton.height);
            ofSetColor(255, 255, 255);
		if(bUseTTFFont) {
			guiTTFFont.drawString("restore", restoreButton.x + 3, restoreButton.y + restoreButton.height -4);
		}
		else {
			ofDrawBitmapString("restore", restoreButton.x + 3, restoreButton.y + restoreButton.height -3);
		}
		ofPopStyle();
	}

        ofPushMatrix();
            ofTranslate(2,0,0);
            glColor4fv(textColor.getColorF());
            guiBaseObject::renderText();
        ofPopMatrix();

        if( !minimize ){

            //don't let gui elements go out of their panels
            glEnable(GL_SCISSOR_TEST);
            glScissor(boundingBox.x, ofGetHeight() - ( boundingBox.y + boundingBox.height - (-2 + topSpacing) ), boundingBox.width - borderWidth , boundingBox.height);

                for(int i = 0; i < (int) panelTabs.size(); i++){
                    if( i == selectedPanel){
                        ofPushStyle();
                            ofFill();
                            glColor4fv(fgColor.getSelectedColorF());
                            ofRect(panelTabs[i].x, panelTabs[i].y, panelTabs[i].width, panelTabs[i].height);
                            glColor4fv(outlineColor.getColorF());
                        ofPopStyle();
                    }
                    glColor4fv(outlineColor.getColorF());
                    ofNoFill();
                    ofRect(panelTabs[i].x, panelTabs[i].y, panelTabs[i].width, panelTabs[i].height);
                }

                glPushMatrix();
                    glTranslatef(hitArea.x, hitArea.y, 0);
                    for(int i = 0; i < (int) panels.size(); i++){
                        if( i == selectedPanel )panels[i]->render();
                    }
                glPopMatrix();

            glDisable(GL_SCISSOR_TEST);
        }

    ofPopStyle();
}
//---------------------------------------------------------------
void audioInputChannel::drawChannel(int x, int y, int w, int h){
	
	char temp[128];
	
	glPushMatrix();
		glTranslatef(x, y, 0.0f);
		ofEnableAlphaBlending();
		
		// background
		ofFill();
		glColor4f(0.941,0.941,0.941,0.05);
		ofRect(0,y,w,h*4);
	
		glColor4f(0.941,0.941,0.941,0.2);
		signalBackground.draw(0,y);
		signalBackground.draw(0,y+h);
		signalBackground.draw(0,y+h*2);
		signalBackground.draw(0,y+h*3);
		
		
		if(bufferSize > 0){
			float stretch		= w / (float)(bufferSize - 1);
			float zeroOffset	= h / 2.0;
			
			// scope RAW
			ofNoFill();
			
			glPushMatrix();	
				glTranslatef(0, y+zeroOffset, 0.0f);
				glColor4f(0.941,0.941,0.941,0.9);
				sprintf(temp,"time domain");
				font.drawString(temp, 0, -10-zeroOffset);
				glColor4f(1.0,0.906,0.463,0.9);
				sprintf(temp,"raw signal");
				font.drawString(temp, 2, 8-zeroOffset);
				ofBeginShape();
				for (int i = 0; i < bufferSize - 1; i++){
					ofVertex(i * stretch, hardClip(chRaw[i]) * zeroOffset);
					ofVertex((i + 1) * stretch, hardClip(chRaw[i + 1]) * zeroOffset);
				}
				ofEndShape(false);
			glPopMatrix();
			
			// scope AUTOCORRELATION
			glColor4f(0.941,0.941,0.941,0.7);
			ofNoFill();
			
			glPushMatrix();	
				glTranslatef(0, y+(zeroOffset*3.0), 0.0f);
				sprintf(temp,"correlated signal");
				font.drawString(temp, 2, 8-zeroOffset);
				ofBeginShape();
				for (unsigned int i = 0; i < bufferSize - 1; i++){
					ofVertex(i * stretch, hardClip(autoCorrelation[i]) * zeroOffset);
					ofVertex((i + 1) * stretch, hardClip(autoCorrelation[i + 1]) * zeroOffset);
				}
				ofEndShape(false);
			glPopMatrix();
			
			// scope AUTOCORRELATION NORMALIZED
			glColor4f(0.941,0.941,0.941,0.7);
			ofNoFill();
			
			glPushMatrix();	
				glTranslatef(0, y+(zeroOffset*5.0), 0.0f);
				sprintf(temp,"correlated signal normalized");
				font.drawString(temp, 2, 8-zeroOffset);
				ofBeginShape();
				for (unsigned int i = 0; i < bufferSize - 1; i++){
					ofVertex(i * stretch, hardClip(autoCorrelationNorm[i]) * zeroOffset);
					ofVertex((i + 1) * stretch, hardClip(autoCorrelationNorm[i + 1]) * zeroOffset);
				}
				ofEndShape(false);
			glPopMatrix();
			
			// scope AUTOCORRELATION NOISE FILTERED
			glColor4f(1.0,0.906,0.463,0.7);
			ofNoFill();
			
			glPushMatrix();	
			glTranslatef(0, y+(zeroOffset*7.0), 0.0f);
			sprintf(temp,"filtered correlated signal");
			font.drawString(temp, 2, 8-zeroOffset);
			ofBeginShape();
			for (unsigned int i = 0; i < bufferSize - 1; i++){
				ofVertex(i * stretch, hardClip(chClean[i]) * zeroOffset);
				ofVertex((i + 1) * stretch, hardClip(chClean[i + 1]) * zeroOffset);
			}
			ofEndShape(false);
			glPopMatrix();
			
			
			// FFT SPECTRUM
			glPushMatrix();
				glTranslatef(w+18, y, 0.0f);
			
				glColor4f(0.941,0.941,0.941,0.2);
				eqBackground.draw(0,0);
				eqBackground.draw(0,h);
				eqBackground.draw(0,h*2);
				eqBackground.draw(0,h*3);
			
				glColor4f(0.941,0.941,0.941,0.9);
				sprintf(temp,"frequency domain");
				font.drawString(temp, 0, - 10);
				glColor4f(0.847,0.25,0.25,0.9);
				sprintf(temp,"noise filter");
				font.drawString(temp, 2, 8);
				sprintf(temp,"parametric eq [normalized radial basis function network]");
				font.drawString(temp, 2, 8+h);
				glColor4f(1.0,0.906,0.463,0.9);
				sprintf(temp,"filtered fft BINS [%i]",fft->getBinSize());
				font.drawString(temp, 2, 8+(h*2));
				sprintf(temp,"bark scale BINS [%i]",BARK_SCALE_CRITICAL_BANDS);
				font.drawString(temp, 2, 8+(h*3));
			
				glScalef(((float)w/fft->getBinSize()), 1.0f, 1.0f);
				
				// noise filter
				glColor4f(0.847,0.25,0.25,1.0); // 216, 64, 64
				
				glLineWidth(5.0f);
				ofBeginShape();
				for(unsigned int i = 1; i < fft->getBinSize()-1; i++){
					ofVertex(i, (hardClip(noiseFilter[i]*reduxFactor) * zeroOffset) + zeroOffset);
					ofVertex(i+1, (hardClip(noiseFilter[i+1]*reduxFactor) * zeroOffset) + zeroOffset);
				}
				ofEndShape(false);
				
				// gaussian filter
				glColor4f(0.847,0.25,0.25,1.0);
				glLineWidth(5.0f);
				ofBeginShape();
				for(unsigned int i = 0; i < fft->getBinSize()-1; i++){
					ofVertex(i, (hardClip(gaussianFilter[i]) * -zeroOffset) + zeroOffset + h);
					ofVertex(i+1, (hardClip(gaussianFilter[i+1]) * -zeroOffset) + zeroOffset + h);
				}
				ofEndShape(false);
			
				// filtered fft BINS
				glLineWidth(1.0f);
				for(unsigned int i = 2; i < fft->getBinSize(); i++){
					if(i == fft_pitchBin){
						glColor4f(0.847,0.25,0.25,0.9);
						ofLine(i,h*3 - 1,i,h*3 - h + 1);
					}else{
						glColor4f(1.0,0.906,0.463,0.9);
					}
					ofLine(i,h*3 - 1,i,(hardClip(binsFiltered[i]) * -h) + h*3 - 1);
				}
			
				// BARK SCALE BINS
				glColor4f(1.0,0.906,0.463,0.9);
				float temp = (fft->getBinSize()*1.0f)/BARK_SCALE_CRITICAL_BANDS;
				for(unsigned int i=0;i<BARK_SCALE_CRITICAL_BANDS;i++){
					ofRect(i*temp, h*4 - 1, temp, hardClip(_osc_barkBins[i] / barkGrouped[i]) * -h);
				}
			
				// background
				ofFill();
				glColor4f(0.941,0.941,0.941,0.05);
				ofRect(0,0,fft->getBinSize(),h*4);
				
				// frame
				ofNoFill();
				glColor4f(0.941,0.941,0.941,0.4);
				ofRect(0,0,fft->getBinSize(),h);
				ofRect(0,h,fft->getBinSize(),h);
				ofRect(0,h*2,fft->getBinSize(),h);
				ofRect(0,h*3,fft->getBinSize(),h);
				
			glPopMatrix();
			
		}
	
		// frames
		glColor4f(0.941,0.941,0.941,0.4);
		ofRect(0,y,w,h);
		ofRect(0,y+h,w,h);
		ofRect(0,y+(h*2),w,h);
		ofRect(0,y+(h*3),w,h);
		
		// graphics gui
		glColor4f(0.941,0.941,0.941,0.8);
		timeFreq.draw(0,y+(h*4));
	
		ofDisableAlphaBlending();
	glPopMatrix();
	
}
Exemple #14
0
//--------------------------------------------------------------
void testApp::draw(){
	ofEnableAlphaBlending();
    ofSetColor(255,120,0,100);
    
    stroke.draw();
    ofFill();
	for (int i = 0; i < particles.size(); i++){
		particles[i].draw();
	}
	

    ofMesh mesh;
    mesh.setMode(OF_PRIMITIVE_TRIANGLE_STRIP);
    
    vector < ofPoint > pts = stroke.getVertices();
    
    for (int i = 3; i < pts.size(); i++){
        
        int i_m_1 = MAX(i-1,0);
        int i_p_1 = MIN(i+1, pts.size()-1);
        
        ofPoint pta = pts[i_m_1];
        ofPoint ptb = pts[i];
        ofPoint ptc = pts[i_p_1];
        
        //ofPoint diff = ptc - pta;
	
		//ofPoint avgdiff = (pts[i]-pts[i-1]);
		//	ofPoint avgdiff[n] = diff[n]/4;

		
		ofPoint diff = ((pts[i]-pts[i-1])+(pts[i-1]-pts[i-2])+(pts[i-2]-pts[i-3])+(pts[i-3]-pts[i-4])+(pts[i-4]-pts[i-5])+(pts[i-5]-pts[i-6]))/7;
		float d = (1.0/(float)ofDist(0,0,diff.x,diff.y)) * 100.0;
		if (d > .05){
			d==.05;
			cout << d<<endl;;
		//float width = diff.length();
		float width = d;
		
        float angle = atan2(diff.y, diff.x);
        
        angle += PI/2;
        
	
        //float width = diff.length(); //diff.length();
        
        ofPoint offsetA;
        offsetA.x = ptb.x + width * cos(angle);
        offsetA.y = ptb.y + width * sin(angle);
        
        ofPoint offsetB;
        offsetB.x = ptb.x - width * cos(angle);
        offsetB.y = ptb.y - width * sin(angle);

        ofLine(offsetA, offsetB);
        
        //ofColor col;
        //col.setHsb(ofMap(angle, -PI/2, 3*PI/2, 0,255, true), 100,255, ofMap(angle, -PI/2, 3*PI/2, 0,255, true));
        //mesh.addColor(col);
        mesh.addVertex(offsetA);
        //mesh.addColor(col);

        mesh.addVertex(offsetB);
        
		}
		
        
    }

    // draw the mesh
    ofEnableAlphaBlending();
    ofSetColor(255,120,0,100);
    ofFill();
    mesh.draw();
	
    
}
void creature::draw() {
    
    
    ofFill();
    ofSetColor(color);

//    for (int i = 0; i < particles.size(); i++){
//        particles[i]->draw();
//    }
//
//    for (int i = 0; i < springs.size(); i++){
//        springs[i].draw();
//    }
    
    //HEAD
    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();
    
    //BODY
    ofBeginShape();
        ofVertex(particles[4]->pos.x, particles[4]->pos.y);
        ofVertex(particles[5]->pos.x, particles[5]->pos.y);
        ofVertex(particles[6]->pos.x, particles[6]->pos.y);
        ofVertex(particles[7]->pos.x, particles[7]->pos.y);
	ofEndShape();
    
    //LEFT FEET
    ofBeginShape();
        ofVertex(particles[8]->pos.x, particles[8]->pos.y);
        ofVertex(particles[9]->pos.x, particles[9]->pos.y);
        ofVertex(particles[10]->pos.x, particles[10]->pos.y);
        ofVertex(particles[11]->pos.x, particles[11]->pos.y);
	ofEndShape();
    
    //RIGHT FEET
    ofBeginShape();
        ofVertex(particles[12]->pos.x, particles[12]->pos.y);
        ofVertex(particles[13]->pos.x, particles[13]->pos.y);
        ofVertex(particles[14]->pos.x, particles[14]->pos.y);
        ofVertex(particles[15]->pos.x, particles[15]->pos.y);
	ofEndShape();
    
    //LEFT ARM
    ofBeginShape();
        ofVertex(particles[16]->pos.x, particles[16]->pos.y);
        ofVertex(particles[17]->pos.x, particles[17]->pos.y);
        ofVertex(particles[4]->pos.x, particles[4]->pos.y);
	ofEndShape();
    
    //RIGHT ARM
    ofBeginShape();
        ofVertex(particles[18]->pos.x, particles[18]->pos.y);
        ofVertex(particles[19]->pos.x, particles[19]->pos.y);
        ofVertex(particles[7]->pos.x, particles[7]->pos.y);
	ofEndShape();
    
    ofPushMatrix();
        ofTranslate(particles[0]->pos.x, particles[0]->pos.y);
            ofPushMatrix();
                ofTranslate(size/2, size+size/2);
                ofSetColor(50,50,50);
                //TEETH
                ofTriangle(-size*3/8, 0, -size/4, size/3, -size/8, 0);
                ofTriangle(size/8,0, size/4, size/3, size*3/8,0);
                ofLine(-size/4, 0, size/4, 0);
            ofPopMatrix();
    ofPopMatrix();

//    ofPopMatrix();
    //    ofPoint righteyes;
    //    righteyes.x = particles[0]->pos.x + size/5;
    //    righteyes.y = particles[0]->pos.y + size/3;
    //
    //    ofPoint lefteyes;
    //    lefteyes.x = particles[3]->pos.x - size/5;
    //    lefteyes.y = particles[3]->pos.y + size/3;
    
    //    ofCircle(righteyes, size/5);
    //    ofCircle(lefteyes, size/6);
    
    
    float myLeftEyeX = (particles[3]->pos.x - particles[0]->pos.x)/4;
    float myLeftEyeY = (particles[1]->pos.y - particles[0]->pos.y)/4;
    
    float myRightEyeX = -(particles[3]->pos.x - particles[0]->pos.x)/4;
    float myRightEyeY = (particles[2]->pos.y - particles[3]->pos.y)/4;
    
    ofSetColor(50,50,50);

    ofPushMatrix();
        ofTranslate(particles[0]->pos.x, particles[0]->pos.y);
        ofCircle(myLeftEyeX, myLeftEyeY, size/5);
    ofPopMatrix();
    
    ofPushMatrix();
        ofTranslate(particles[3]->pos.x, particles[3]->pos.y);
        ofCircle(myRightEyeX, myRightEyeY, size/5);
    ofPopMatrix();

    
}
Exemple #16
0
//--------------------------------------------------------------
void DrumKit::draw() {
    ofSetColor(255,255,0, 10);
    #pragma omp parallel for
    for(int i=0;i<drumCount;i++)
        ofLine(i*ofGetWidth()/drumCount, 0, i*ofGetWidth()/drumCount, ofGetHeight());
}
Exemple #17
0
void Boid::draw() {
    
    // Draw a triangle rotated in the direction of velocity
	
    
    if(loc.x == 0 || loc.x == ofGetWindowWidth()) vel.x *= -1;
    if(loc.y == 0 || loc.y == ofGetWindowHeight()) vel.y *= -1;


	
	float angle = (float)atan2(-vel.y, vel.x);
    float theta =  -1.0*angle;
	float heading2D = ofRadToDeg(theta)+90;
	
	ofEnableAlphaBlending();
    ofSetColor(255, 255, 255);
    ofFill();
    ofPushMatrix();
    ofTranslate(loc.x, loc.y);
    ofRotateZ(heading2D);
    
	/* DRAW BOID ARROW - REPLACED WITH PNG IN FINAL VERSION
    ofBeginShape();
    ofVertex(0, -r*2);
    ofVertex(-r, r*2);
    ofVertex(r, r*2);
    ofEndShape(true);
    */
    
    // DRAW PNG IMAGE FOR AIRPLANE
    i.setAnchorPoint(10, 12);
    i.draw(0,0);
    
    ofPopMatrix();
	ofDisableAlphaBlending();
    
    
    // Draw the predicted location
    if (debug) {
		ofFill();
        
		ofSetColor(0,191,255); // BLUE
		ofLine(loc.x,loc.y,predictLoc.x, predictLoc.y);
        
        // PREDICTED LOCATION 
		ofEllipse(predictLoc.x, predictLoc.y,4,4);

		// Draw normal location
		ofSetColor(255, 69, 0); //ORANGE
		ofLine(predictLoc.x, predictLoc.y, target.x, target.y);
		ofEllipse(target.x,target.y,4,4);
		
		// Draw actual target (red if steering towards it)
		ofLine(predictLoc.x,predictLoc.y,target.x,target.y);
		

        // VIOLET CIRCLE IS TARGET + DIR
		ofSetColor(255, 20, 147);
		ofEllipse(target.x+dir.x, target.y+dir.y, 8, 8);
    }

    
}
Exemple #18
0
void ofxSymbolInstance::drawLayer(layer *ly,float alpha) {
    if (!ly) {
        return;
    }
    
    ofPushMatrix();
    glMultMatrixf(mat.getPtr());
    frame &f = ly->frames[ly->currentFrame];
    for (vector<ofxSymbolInstance>::iterator iter=f.instances.begin(); iter!=f.instances.end(); iter++) {
        if (iter->bVisible) {
            switch (iter->type) {
                case BITMAP_INSTANCE: {
                    ofPushMatrix();
                    glMultMatrixf(iter->mat.getPtr());
                    ofSetColor(255, 255, 255,alpha*alphaMultiplier*255.0);
                    iter->bitmapItem->draw();
                    ofSetColor(255, 255, 255,255);
                    ofPopMatrix();
                } break;
                    
                    
                case SHAPE: {
                    
                    ofxShape &shape = symbolItem->shapes[iter->shapeIndex]; 
                    if (!shape.curve.empty()) {
                        vector<curvePath>::iterator citer=shape.curve.begin(); 
                        ofBeginShape();
                        ofVertex(citer->p0.x,citer->p0.y);
                        for (vector<vector<ofVec2f> >::iterator iter=citer->segments.begin(); iter!=citer->segments.end(); iter++) {
                            
                            ofBezierVertex(iter->at(0).x,iter->at(0).y,iter->at(1).x,iter->at(1).y,iter->at(2).x,iter->at(2).y);
                        }
                        ofEndShape();
                    }
                    
                    
                    
                    if (!shape.line.empty()) {
                        //linePath l = shape.line.front();
                        vector<linePath>::iterator liter = shape.line.begin();
                        
                        if (liter->bClosed) {
                            
                            if (!shape.solidColorFill.empty()) {
                                
                                ofPushStyle();
                                ofSetHexColor(shape.solidColorFill.front());
                                
                                ofFill();
                                ofBeginShape();
                                ofVertex(liter->p0.x,liter->p0.y);
                                
                                for (vector<ofVec2f>::iterator iter=liter->segments.begin(); iter!=liter->segments.end()-1; iter++) { // roikr: we don't need the end
                                    ofVertex(iter->x,iter->y);
                                }
                                
                                ofEndShape();
                                ofPopStyle();
                                
                            };
                            
                            if (!shape.solidColorStroke.empty()) {
                                
                                ofPushStyle();
                                ofSetHexColor(shape.solidColorStroke.front());
                                
                                ofNoFill();
                                ofBeginShape();
                                ofVertex(liter->p0.x,liter->p0.y);
                                
                                for (vector<ofVec2f>::iterator iter=liter->segments.begin(); iter!=liter->segments.end(); iter++) {
                                    ofVertex(iter->x,iter->y);
                                }
                                
                                ofEndShape();
                                ofPopStyle();
                                
                            };
                            
                            if (!shape.bitmapFill.empty()) {
                                
                                ofxBitmapFill &bitmapFill = shape.bitmapFill.front();
                                
                                
//                                
//                                glEnable(GL_SCISSOR_TEST);
//                                ofRectangle &rect = bitmapFill.rect;
//                                
//#ifndef TARGET_OPENGLES                   
//                                ofVec2f p = (ofVec2f(rect.x,rect.y+rect.height)+doc->offset)*doc->zoom+0.5*ofVec2f(ofGetWidth(),ofGetHeight());
//                                
//                                glScissor(p.x, ofGetHeight()-p.y, rect.width*doc->zoom , rect.height*doc->zoom);
//                                
//#else                    
//                                ofVec2f q = (ofVec2f(rect.x+rect.width,rect.y+rect.height)+offset)*zoom+0.5*ofVec2f(ofGetWidth(),ofGetHeight());
//                                ofVec2f p = ofVec2f(ofGetHeight(),ofGetWidth())-ofVec2f(q.y,q.x);
//                                
//                                glScissor(p.x, p.y, rect.height*zoom , rect.width*zoom);
//#endif
                                
                                ofPushMatrix();
                                glMultMatrixf(bitmapFill.mat.getPtr());
                                bitmapFill.bitmapItem->draw();
                                ofPopMatrix();
                                
//                                glDisable(GL_SCISSOR_TEST);
            
                            }
                        } else {
                            
                            if (!shape.solidColorStroke.empty()) {
                                ofPushStyle();
                                ofSetHexColor(shape.solidColorStroke.front());
                                ofLine(liter->p0, liter->segments.front());
                                for (vector<ofVec2f>::iterator iter=liter->segments.begin(); iter!=liter->segments.end()-1; iter++) {
                                    ofLine(*iter, *(iter+1));
                                }
                                ofPopStyle();
                            }
                        }
                        
                    }
                }   break;
                    
            
            
            
                
                case SYMBOL_INSTANCE: 
                    iter->draw(alpha*alphaMultiplier);
                    break;
                    
                default:
                    break;
                    
            }

            
        }
    }
    
    ofPopMatrix();
     
/*    
        
        
    
    ofPushStyle();
    for (vector<tlfText>::iterator titer=ly.texts.begin();titer!=ly.texts.end();titer++) {
        
        float v = 0;
        
        for (vector<span>::iterator iter=titer->spans.begin(); iter!=titer->spans.end(); iter++) {
            ofPushMatrix();
//                ofTranslate(titer->translation+ofVec2f(0,v+iter->fontSize));
            ofTranslate(titer->translation+ofVec2f(0,v+(float)font.stringHeight(iter->text)*(float)iter->fontSize/(float)font.getSize()));
            float scale = (float)iter->fontSize/(float)font.getSize();
            ofScale(scale, scale);
            ofSetHexColor(iter->color);
            font.drawString(iter->text, 0, 0);
            ofPopMatrix();
            v+= (float)iter->fontSize*lineHeight;
        }
                        
    }
    ofPopStyle();
*/
    
    
}
Exemple #19
0
//--------------------------------------------------------------
void ofxMuiColorPicker::draw() {
    
    //if(name == "MCP") {
    //    cout << "in here" << endl;
    //}
    
    ofPushStyle();
	ofPushMatrix(); // initial push
    
    ofTranslate(getHitBoxX(),getHitBoxY());
    

    
    ofSetColor(255);
    picker.draw(0,0);

    ofFill();
    ofSetColor(getValue());
    ofxRect(colorPickerPreview);

    ofFill();
    ofSetColor(30);
    ofLine(colorPickerPreview.x,colorPickerPreview.y,getHitBoxWidth(),colorPickerPreview.y);
    
    ofNoFill();
    
    
    if(showEyeDroperPreview) {
        
        eyeDropperPreview.loadScreenData(mousePosition.x-eyeDropperPreviewPixelWidth/2.0f,
                                         mousePosition.y-eyeDropperPreviewPixelHeight/2.0f
                                         ,eyeDropperPreviewPixelWidth,eyeDropperPreviewPixelHeight);

        
        ofPushMatrix();
        ofTranslate(screenToHitBox(mousePosition));

        
        ofSetColor(255);
       // ofxRect(0,0,
       // ofPushMatrix(

        ofPushMatrix();
        ofScale(defaults->colorPickerEyeDropperZoom,defaults->colorPickerEyeDropperZoom);
        ofTranslate(-eyeDropperPreviewPixelWidth/2.0, -eyeDropperPreviewPixelHeight/2.0f);
        eyeDropperPreview.draw(0,0);
        ofPopMatrix();
        
        ofCircle(0,0,4,4);

        
        ofPopMatrix();
     
    } else {
        //ofSetColor(getValue().getInverted().getBrightness());
        ofCircle(cursor.x-2, cursor.y-2, 4);
    }
    
    /*
    if(isDragging) {
        ofFill();
        ofSetColor(255);
        ofxRect(0,0,40,40);
    }
    */
        
        
    ofPopMatrix(); // HIT RECT PUSH
    ofPopStyle();
    
    
}
Exemple #20
0
void testApp::drawScene(int iCameraDraw){	
	
	nodeSwarm.draw();
	nodeGrid.draw();
	
	//////////////////////////////////
	// DRAW EASYCAM FRUSTUM PREVIEW
	//////////////////////////////////
	//
	// This code draws our camera in
	//	the scene (reddy/pink lines)
	//
	// The pyramid-like shape defined
	//	by the cameras view is called
	//	a 'frustum'.
	//
	// Often we refer to the volume
	//	which can be seen by the
	//	camera as 'the view frustum'.
	//
	
	
	//let's not draw the camera
	//if we're looking through it
	if (iCameraDraw != 0)
	{
		ofPushStyle();
				
		//in 'camera space' this frustum
		//is defined by a box with bounds
		//-1->1 in each axis
		//
		//to convert from camera to world
		//space, we multiply by the inverse
		//matrix of the camera
		//
		//by applying this transformation
		//our box in camera space is
		//transformed into a frustum in
		//world space.
		
		ofMatrix4x4 inverseCameraMatrix;
		
		//the camera's matricies are dependant on
		//the aspect ratio of the viewport
		//so we must send the viewport if it's not
		//the same as fullscreen
		//
		//watch the aspect ratio of preview camera
		inverseCameraMatrix.makeInvertOf(camEasyCam.getModelViewProjectionMatrix( (iMainCamera == 0 ? viewMain : viewGrid[0]) ));
		
		// By default, we can say
		//	'we are drawing in world space'
		//
		// The camera matrix performs
		//	world->camera
		//
		// The inverse camera matrix performs
		//	camera->world
		//
		// Our box is in camera space, if we
		//	want to draw that into world space
		//	we have to apply the camera->world
		//	transformation.
		//
		ofPushMatrix();
		glMultMatrixf(inverseCameraMatrix.getPtr());
		
		
		ofSetColor(255, 100, 100);
		
		//////////////////////
		// DRAW WIREFRAME BOX
		//
		// xy plane at z=-1 in camera sapce
		// (small rectangle at camera position)
		//
		GLfloat vertices1[] = {
				-1.0f, -1.0f, -1.0f,
				-1.0f, 1.0f, -1.0f,
				1.0f, 1.0f, -1.0f,
				1.0f, -1.0f, -1.0f
		};

		glEnableClientState(GL_VERTEX_ARRAY);
		glVertexPointer(3, GL_FLOAT, 0, vertices1);
		glDrawArrays(GL_LINE_LOOP, 0, 4);
		glDisableClientState(GL_VERTEX_ARRAY);
		
		
		// xy plane at z=1 in camera space
		// (generally invisible because so far away)
		//
		GLfloat vertices2[] = {
						-1.0f, -1.0f, 1.0f,
						-1.0f, 1.0f, 1.0f,
						1.0f, 1.0f, 1.0f,
						1.0f, -1.0f, 1.0f};

		glEnableClientState(GL_VERTEX_ARRAY);
		glVertexPointer(3, GL_FLOAT, 0, vertices2);
		glDrawArrays(GL_LINE_LOOP, 0, 4);
		glDisableClientState(GL_VERTEX_ARRAY);
		
		// connecting lines between above 2 planes
		// (these are the long lines)
		//
		GLfloat vertices3[] = {
				-1.0f, 1.0f, -1.0f,
				-1.0f, 1.0f, 1.0f,

				1.0f, 1.0f, -1.0f,
				1.0f, 1.0f, 1.0f,

				-1.0f, -1.0f, -1.0f,
				-1.0f, -1.0f, 1.0f,

				1.0f, -1.0f, -1.0f,
				1.0f, -1.0f, 1.0f
		};

		glEnableClientState(GL_VERTEX_ARRAY);
		glVertexPointer(3, GL_FLOAT, 0, vertices3);
		glDrawArrays(GL_LINE_LOOP, 0, 8);
		glDisableClientState(GL_VERTEX_ARRAY);
		//
		//////////////////////

		ofPopStyle();
		ofPopMatrix();
	}
	
	//
	//////////////////////////////////

	
	
	//////////////////////////////////
	// DRAW RAY
	//////////////////////////////////
	//
	//draw if we've got camEasyCam selected
	//and we're not looking through it
	if (iMainCamera == 0 && iCameraDraw != 0)
	{
		ofPushStyle();
		ofSetColor(100, 100, 255);
		ofLine(ray[0], ray[1]);
		ofPopStyle();
	}
	//
	//////////////////////////////////
}
//----------------------------------------------------------------------------------
void ofxCvBlobFinder::draw(float x, float y, float w, float h) {
    
    // draw blobs
    //ofxCvContourFinder::draw(x, y, w, h);
    // scale blob
    float scalex = 0.0f;
    float scaley = 0.0f;
    
    if (_width != 0) {
        scalex = w / _width;
    }
    else {
        scalex = 1.0f;
    }
    
    if (_height != 0) {
        scaley = h / _height;
    }
    else {
        scaley = 1.0f;
    }
    
    
    ofSetPolyMode(OF_POLY_WINDING_NONZERO);
    // apply transformation
    glPushMatrix();
    glTranslatef(x, y, 0.0);
    glScalef(scalex, scaley, 0.0);
    
    
#define DRAW_BLOB_VECTOR(points) do{ \
ofBeginShape(); \
for(int i = 0; i < (points).size(); i++){ \
ofVertex((points[i]).x, (points[i]).y); \
} \
ofEndShape(true); \
} while(0)
    
    ofNoFill();
    for (int j = 0; j < blobz.size(); j++) {
        ofSetHexColor(0xFF0000);
        DRAW_BLOB_VECTOR( blobz[j].getPoints());
        
        ofSetHexColor(0x00FF00);
        DRAW_BLOB_VECTOR(blobz[j].getHullPoints());
        
        ofSetHexColor(0x0000FF);
        DRAW_BLOB_VECTOR( blobz[j].getApproxPoints());
        
        ofSetHexColor(0x00ffae);
        ofRectangle c = blobz[j].getBoundingBox();
        
        
        // draw bounding box
        ostringstream s;
        s << j << "Area = " << blobz[j].getArea();
        
        ofDrawBitmapString(s.str(), c.x, c.y + 50);
        ofRect(c.x, c.y, c.width, c.height);
        
        // get convexity defects
        vector<ofxCvConvexityDefect> cd = blobz[j].getConvexityDefects();
        ofSetHexColor(0x00effe);
        for(int i=0; i < cd.size(); i++){
            ofLine(cd[i].start.x, cd[i].start.y, cd[i].end.x, cd[i].end.y);
            ofCircle(cd[i].defect.x, cd[i].defect.y, 2);
            float angle = atan2f( ( (float) (cd[i].end.y - cd[i].start.y) ) , ( (float) (cd[i].end.x - cd[i].start.x)));
            float x = cd[i].defect.x - sinf(angle) * cd[i].length;
            float y = cd[i].defect.y + cosf(angle) * cd[i].length;
            ofSetHexColor(0xF0F0F0);
            ofLine(cd[i].defect.x, cd[i].defect.y, x, y);
        }
    }
    
    for (int k = 0; k < blobParams.size(); k++){
        ofDrawBitmapString("Blob:" + ofToString(blobParams[k].id), blobParams[k].position);
    }
    
    glPopMatrix();
}
void pclSystem::animate() {

	double x,y,d,theta,force;

	for (int i = 0;i < particles.size();i++) {
		for (int j = 0;j < fields.size();j++) {
				y = abs(particles[i].y-fields[j].y);
				x = abs(particles[i].x-fields[j].x);
				d = sqrt(pow(abs(particles[i].x-fields[j].x),2)+pow(abs(particles[i].y-fields[j].y),2));
				theta = asin(y/d);
				force = (fields[j].strength*particles[i].mass)/(pow(d,2));

				if (particles[i].x > fields[j].x) {
					particles[i].xSpeed -= force*cos(theta);
				}
				else{
					particles[i].xSpeed += force*cos(theta);
				}

				if (particles[i].y > fields[j].y) {
					particles[i].ySpeed -= force*sin(theta);
				}
				else{
					particles[i].ySpeed += force*sin(theta);
				}
		}
		particles[i].x += particles[i].xSpeed;
		particles[i].y += particles[i].ySpeed;

		particles[i].red += particles[i].redIncrease;
		particles[i].blue += particles[i].blueIncrease;
		particles[i].green += particles[i].greenIncrease;

		particles[i].alpha += particles[i].alphaDecay;
		if (particles[i].size > 0) {
			particles[i].size  -= particles[i].sizeDecay;
			if (particles[i].size < 0) {
				particles[i].size = 0;
			}
		}

		particles[i].ySpeed += gravityY;
		particles[i].xSpeed += gravityX;


		if (particles[i].shape == "circle") {
			ofEnableAlphaBlending();
			ofSetColor(particles[i].red,particles[i].green,particles[i].blue,255-particles[i].alpha);
			ofFill();
			ofCircle(particles[i].x,particles[i].y,particles[i].size);
		}
		else if (particles[i].shape == "square") {
			ofEnableAlphaBlending();
			ofSetColor(particles[i].red,particles[i].green,particles[i].blue,255-particles[i].alpha);
			ofFill();
			ofRect(particles[i].x,particles[i].y,particles[i].size,particles[i].size);
		}
		else if (particles[i].shape == "hor_line") {
			ofEnableAlphaBlending();
			ofSetColor(particles[i].red,particles[i].green,particles[i].blue,255-particles[i].alpha);
			ofFill();
			ofLine(particles[i].x,particles[i].y,particles[i].x+particles[i].size,particles[i].y);
		}
		else if (particles[i].shape == "circle_hollow") {
			ofEnableAlphaBlending();
			ofSetColor(particles[i].red,particles[i].green,particles[i].blue,255-particles[i].alpha);
			ofNoFill();
			ofCircle(particles[i].x,particles[i].y,particles[i].size);
		}
		else if (particles[i].shape == "square_hollow") {
			ofEnableAlphaBlending();
			ofSetColor(particles[i].red,particles[i].green,particles[i].blue,255-particles[i].alpha);
			ofNoFill();
			ofRect(particles[i].x,particles[i].y,particles[i].size,particles[i].size);
		}
	}

	for (int i = 0;i < particles.size();i++) {
		if (particles[i].alpha > 255) {
			vector<pclType>::iterator loc = particles.begin();
			particles.erase(loc+i);
		}
	}
	for (int i = 0;i < particles.size();i++) {
		if ( (abs(particles[i].xSpeed) > 35)||(abs(particles[i].ySpeed) > 35) ) {
			vector<pclType>::iterator loc = particles.begin();
			particles.erase(loc+i);
		}
	}
	for (int i = 0;i < particles.size();i++) {
		for (int j = 0;j < fields.size();j++) {
			y = abs(particles[i].y-fields[j].y);
			x = abs(particles[i].x-fields[j].x);
			if ((x < 10)&&(y<10)) {
				vector<pclType>::iterator loc = particles.begin();
				particles.erase(loc+i);
			}
		}
	}

}
void Line::display()
{
	ofColor(200, 100, 60);
	ofLine(locationpoint1.x, locationpoint1.y, locationpoint2.x, locationpoint2.y);
}
Exemple #24
0
//--------------------------------------------------------------
void testApp::draw(){
	//ofSetColor(255,255,255);
	//int px[4]={512,512,512,512},py[4]={384,384,384,384};
    
    //draw all cv images
    //hsb.draw(640,0);
    //hue.draw(0,240);
    //sat.draw(320,240);
    //bri.draw(640,240;

	//draw images 
	if(clickCount<5)
	{
		rgb.draw(0,0);
		filtered[0].draw(320,0);
		filtered[1].draw(0,240);
		filtered[2].draw(320,240);
		filtered[3].draw(640,240);

		for(int i=0;i<4;i++)
			contours[i].draw(0,480);
		
    
		//ofSetColor(255, 0, 0);
		//ofFill();
	}
	else
	{
    //draw red circles for found blobs
		
		Position *pos;

		ofSetLineWidth(10);
		

		for(int k=0;k<NUM_MARKERS;k++)
		{
			ofSetColor(color[k],30);
			//ofSetColor(rand()%255,rand()%255,rand()%255,50);
			pos=start[k];
			int j=0;
			while(pos!=NULL && pos->x!=-4 && pos->y!=-4 && (elementCount[k]-j*3)>4)
			{
				int z=0;
				while(z<3)
				{				// 4 control points for bezier curves....
					points[z].x=pos->x;
					points[z].y=pos->y;
					pos=pos->next;
					z++;
				}
				/*if(k==1){
					continue;
				}*/
				points[z].x=pos->x;
				points[z].y=pos->y;

				/*points[0].x=pos->x;points[0].y=pos->y;
				pos=pos->next;
				points[1].x=pos->x;points[1].y=pos->y;
				pos=pos->next;
				points[2].x=pos->x;points[2].y=pos->y;*/
				bezier(15,4);

				for(int i=1;i<=15;i++)
				{
					ofCircle(bz[i].x,bz[i].y,20 );
					ofCircle(bz[i].x+30,bz[i].y,20);
					ofCircle(bz[i].x+10,bz[i].y-30,20);
					ofLine(bz[i-1].x,bz[i-1].y,bz[i].x,bz[i].y);
					//ofCircle(bz[i+1].x-bz[i].x/2,bz[i+1].y-bz[i].y/2,40);
				}
					//ofLine(bz[i-1].x,bz[i-1].y,bz[i].x,bz[i].y);
				j++;
			}
			//pos=start[k];
			//while(pos!=NULL)
			//{
			//	ofSetColor(rand()%255,rand()%255,rand()%255,50);
			//	ofCircle(pos->x,pos->y, 10);
			//	float tx=pos->x,ty=pos->y;
			//	pos=pos->next;
			//	/*if(pos!=NULL)
			//	{
			//		ofSetColor(255,0,0);
			//		if(pos->x!=-4 && pos->y!=-4)
			//			ofLine(tx,ty,pos->x,pos->y);
			//	}*/
			//}
		}
			
	}
}
//------------------------------------------------------------------
void uiCreate::draw(ofTrueTypeFont& basicFont) {

//    sprintf (timeString, "time: %0.2i:%0.2i:%0.2i \nelapsed time %i", ofGetHours(), ofGetMinutes(), ofGetSeconds(), ofGetElapsedTimeMillis());
	
    ofSetHexColor(0x000000);
//	basicFont.drawString(timeString, 10,ofGetHeight()-90);
//	basicFont.drawString(eventString, 10,ofGetHeight()-20);
    
//-----------------------------------------------
//What is created

    for (int i = 0; i < drawThese.size(); i++) {
        drawThese[i].draw();
    }
    
    
//-----------------------------------------------
//Tools
        
    if (*fontSelected) {
//        basicFont.drawString("text selected", 10, 500);
    }
    
    ofSetLineWidth(2.0);
    
    if (*pencilSelected) {
//        basicFont.drawString("pencil selected", 10, 500);
                
        if (currentDrawing.size()>0) {
            for (int i = 1; i < currentDrawing.size(); i++) {
                ofLine(currentDrawing[i-1].x, currentDrawing[i-1].y, currentDrawing[i].x, currentDrawing[i].y);
            }
        }
    }
    
    if (*tableSelected) {
//        basicFont.drawString("table selected", 10, 500);
    }

    if (*okSaveSelected) {
//        basicFont.drawString("ok save selected", 10, 500);
    }

    
//-----------------------------------------------
//Tool Button UI

    pencilButton.drawToggle();
    fontButton.drawToggle();
    tableButton.drawToggle();
    okSaveButton.drawToggle();
    
    ofSetHexColor(0x000000);
    
    ofEnableAlphaBlending();
    pencil->draw(10, 310);
    font->draw(10, 355);
    table->draw(10, 400);
    okSave->draw(10, 445);
    ofDisableAlphaBlending();
    
}
Exemple #26
0
void ofxTLColorTrack::drawModalContent() {
    if(drawingColorWindow) {

        //this happens when a new keyframe is added
        //we need to wait until the draw cycle for the new
        //key to be in the array so we can determine it's
        //surrounding samples
        if(setNextAndPreviousOnUpdate) {
            setNextAndPreviousSamples();
            setNextAndPreviousOnUpdate = false;
        }

        if(selectedKeyframe == NULL) {
            ofLogError("ofxTLColorTrack::drawModalContent") << "The selected keyframe is null" << endl;
            drawingColorWindow = false;
            timeline->dismissedModalContent();
            return;
        }

        if(!colorPallete.bAllocated()) {
            ofLogError("ofxTLColorTrack::drawModalContent") << "The color palette is not allocated" << endl;
            timeline->dismissedModalContent();
            drawingColorWindow = false;
        }
        ofPushStyle();
        ofFill();
        ofSetColor(255);

        ofxTLColorSample* selectedSample = (ofxTLColorSample*)selectedKeyframe;
        colorWindow = ofRectangle( millisToScreenX(selectedKeyframe->time), bounds.y+bounds.height, 200, 200);
        if(colorWindow.getMaxY()+25 > timeline->getBottomLeft().y) {
            colorWindow.y = bounds.y - 25 - colorWindow.height;
        }
        if(colorWindow.getMaxX() > ofGetWidth()) {
            colorWindow.x -= colorWindow.width;
        }
        colorPallete.draw(colorWindow);

        ofVec2f selectionPoint = colorWindow.getMin() + selectedSample->samplePoint * ofVec2f(colorWindow.width,colorWindow.height);
        ofSetColor(selectedSample->color.getInverted());
        ofLine(selectionPoint - ofVec2f(8,0), selectionPoint + ofVec2f(8,0));
        ofLine(selectionPoint - ofVec2f(0,8), selectionPoint + ofVec2f(0,8));

        ofPushStyle();
        ofNoFill();
        if(previousSample != NULL) {
            ofVec2f previousSamplePoint = colorWindow.getMin() + previousSample->samplePoint * ofVec2f(colorWindow.width,colorWindow.height);
            ofSetColor(previousSample->color.getInverted(), 150);
            ofCircle(previousSamplePoint, 3);
            ofLine(previousSamplePoint,selectionPoint);
        }
        if(nextSample != NULL) {
            ofVec2f nextSamplePoint = colorWindow.getMin() + nextSample->samplePoint * ofVec2f(colorWindow.width,colorWindow.height);
            ofSetColor(nextSample->color.getInverted(), 150);

            //draw a little triangle pointer
            ofVec2f direction = (nextSamplePoint - selectionPoint).normalized();
            ofVec2f backStep = nextSamplePoint-direction*5;
            ofTriangle(nextSamplePoint,
                       backStep + direction.getRotated(90)*3,
                       backStep - direction.getRotated(90)*3);
            ofLine(nextSamplePoint,selectionPoint);
        }
        ofPopStyle();

        previousColorRect = ofRectangle(colorWindow.x, colorWindow.getMaxY(), colorWindow.width/2, 25);
        newColorRect = ofRectangle(colorWindow.x+colorWindow.width/2, colorWindow.getMaxY(), colorWindow.width/2, 25);

        ofSetColor(colorAtClickTime);
        ofRect(previousColorRect);
        ofSetColor(selectedSample->color);
        ofRect(newColorRect);
        ofSetColor(timeline->getColors().keyColor);
        ofNoFill();
        ofSetLineWidth(2);
        ofRect(colorWindow);
        ofPopStyle();
    }
}
Exemple #27
0
void SConnection::draw(vector<float> *livedata) {
			
	ofxTuioPoint *fromPt = new ofxTuioPoint(fAnchor->getTuio()->getPosition().getX(),fAnchor->getTuio()->getPosition().getY());
	ofxTuioPoint *toPt = new ofxTuioPoint(tAnchor->getTuio()->getPosition().getX(),tAnchor->getTuio()->getPosition().getY());
	
	float fX = fromPt->getX() * ofGetWidth();
	float fY = fromPt->getY() * ofGetHeight();
	float tX = toPt->getX() * ofGetWidth();
	float tY = toPt->getY() * ofGetHeight();
	
	ofxTuioPoint *fnPt = new ofxTuioPoint(fX, fY);
	ofxTuioPoint *tnPt = new ofxTuioPoint(tX, tY);
	
	//ofLine(fX, fY, tX, tY);
	
	glPushMatrix();
	
	glTranslatef(fX, fY, 0.0);
		
	float dx = fX-tX;
	float dy = fY-tY;
	
	float dist = sqrtf(dx*dx+dy*dy);

	glRotatef(180.0-ofRadToDeg(fnPt->getAngle(tnPt)), 0.0, 0.0, 1.0);
	
	
	glColor3f(0.3, 0.3, 0.3);
	
	ofLine(0.0, 0.0, dist, 0.0);
	
	ofLine(dist - 5.0, 0.0, dist - 12.0, -5.0);
	ofLine(dist - 5.0, 0.0, dist -12.0, 5.0);
	
	glColor3f(0.7, 0.7, 0.7);

	// drawing live data feedback if any
	// A simple line otherwise
	ofBeginShape();

	ofVertex(0.0, 0.0);

	float incr = dist / livedata->size();

	//int idx = 0;
	//while (!livedata.empty()) {
		
	for (int idx=0; idx<livedata->size(); idx++) {
		if (idx*incr>dist) break;
		
		ofVertex(idx*incr, livedata->at(idx)*50);
			
		if (idx*incr+incr>dist) break;
		
		idx++;
	}
	
	//livedata->clear();
	
	ofVertex(dist, 0.0);
	
	ofEndShape(false);
	
	
	glPopMatrix();
	
	if (getConnectionVisual() == CONNECTION_SIN_FREQ) {
	
	} else if (getConnectionVisual() == CONNECTION_SQUARE_FREQ) {
		
	} else if (getConnectionVisual() == CONNECTION_TRIANGLE_FREQ) {
	
	} else if (getConnectionVisual() == CONNECTION_CHUNKS) {
	
	}	
	
	delete fnPt;
	delete tnPt;
	delete fromPt;
	delete toPt;
}
Exemple #28
0
void ofxTLColorTrack::draw() {

    if(bounds.height == 0) {
        return;
    }

    if(viewIsDirty || shouldRecomputePreviews) {
        updatePreviewPalette();
    }

    if(keyframes.size() == 0) {
        ofPushStyle();
        ofSetColor(defaultColor);
        ofFill();
        ofRect(bounds);
        ofPopStyle();
    }
    else if(keyframes.size() == 1) {
        ofPushStyle();
        ofxTLColorSample* s = (ofxTLColorSample*)keyframes[0];
        ofSetColor(s->color);
        ofFill();
        ofRect(bounds);
        ofPopStyle();
    }
    else {
        previewPalette.draw(bounds);
    }

    for(int i = 0; i < keyframes.size(); i++) {

        if(!isKeyframeIsInBounds(keyframes[i])) {
            continue;
        }

        float screenX = millisToScreenX(keyframes[i]->time);

        ofPoint a = ofPoint(screenX-10,bounds.y);
        ofPoint b = ofPoint(screenX+10,bounds.y);
        ofPoint c = ofPoint(screenX,bounds.y+10);

        ofPushStyle();
        ofFill();
        ofxTLColorSample* s = (ofxTLColorSample*)keyframes[i];
        ofSetColor(s->color);
        ofTriangle(a,b,c);
        ofNoFill();
        ofSetColor(s->color.getInverted());
        ofSetLineWidth(1);
        ofTriangle(a,b,c);

        if(keyframes[i] == hoverKeyframe) {
            ofSetColor(timeline->getColors().highlightColor);
            ofSetLineWidth(3);
        }
        else if(isKeyframeSelected(keyframes[i])) {
            ofSetColor(timeline->getColors().textColor);
            ofSetLineWidth(2);
        }
        else {
            ofSetColor(s->color.getInverted());
        }
        ofLine(c, ofVec2f(screenX, bounds.getMaxY()));
        ofPopStyle();
    }
}
Exemple #29
0
void Canvas::draw()
{
    ofEnableBlendMode(OF_BLENDMODE_ALPHA);
    ofSetColor(ResourceManager::getInstance().getBackgroundColor());
    ofFill();
    ofRect(0, 0, ofGetWindowWidth(), ofGetWindowHeight());
    ofDisableBlendMode();
    
//    bgImg.draw(0, 0);

    if (Params::colorMode == 0)
    {
        ofEnableBlendMode(OF_BLENDMODE_SUBTRACT);
    }
    else {
        ofEnableBlendMode(OF_BLENDMODE_ADD);
    }
    
    // Draw normal strokes (#1)
    for (int i=0; i<strokes.size(); i++)
    {
        strokes[i]->draw();
    }
    if (currentStroke) {
        currentStroke->draw();
    }
    
    // Draw surface strokes (#2)
    ofSetColor(Params::surfaceColor);
    ofFill();
    for (int i=0; i<surfaceStrokes.size(); i++)
    {
        surfaceStrokes[i]->drawSurface();
    }
    if (currentSurfaceStroke) {
        currentSurfaceStroke->drawSurface();
    }

    // Draw particle strokes (#3)
    for (int i=0; i<particleStrokes.size(); i++)
    {
        particleStrokes[i]->draw();
    }
    if (currentParticleStroke) {
        currentParticleStroke->draw();
    }
    
    // Draw repeatable strokes (#4)
    for (int i=0; i<repeatableStrokes.size(); i++)
    {
        repeatableStrokes[i]->draw();
    }
    if (currentRepeatableStroke) {
        currentRepeatableStroke->draw();
    }

    // Draw spring strokes (#5)
    for (int i=0; i<springStrokes.size(); i++)
    {
        springStrokes[i]->draw();
    }
    if (currentSpringStroke) {
        currentSpringStroke->draw();
    }
    
    // Draw particle emitters (#7)
    for (int i=0; i<emitters.size(); i++)
    {
        emitters[i]->draw();
    }
    
    // Draw flow field ('f')
    if (bShowFlowfield) {
        flowField.draw();
    }

    
    // draw cursor
    ofSetColor(ResourceManager::getInstance().getStrokeColor());
    ofNoFill();
    if (strokeType == 4) {
        ofLine(ofGetMouseX()-7, ofGetMouseY()-7, ofGetMouseX()+7, ofGetMouseY()+7);
        ofLine(ofGetMouseX()+7, ofGetMouseY()-7, ofGetMouseX()-7, ofGetMouseY()+7);
        ofLine(bladePrev, blade);
    }
    else {
        ofEllipse(ofGetMouseX(), ofGetMouseY(), 15, 15);
    }
    
    ofDisableBlendMode();

}
//--------------------------------------------------------------
void RuleOne::draw(){
    
    //BG------white paper with light blue gridded lines--------------------
    ofBackground(255);
    ofSetColor( ofColor::lightBlue);
    ofSetLineWidth(1);
    for (int i = 0; i < ofGetWidth(); i = i + 20){
        ofLine(i,0,i, ofGetHeight());
        
    }
    
    for (int i = 0; i < ofGetHeight(); i = i + 20){
        ofLine(0, i, ofGetWidth(), i);
    }
    
//----------draw ellipses------------------------------
    
    float sinOfTime				= sin( ofGetElapsedTimef() );
    float sinOfTimeMapped		= ofMap( sinOfTime, -1, 1, 0, 255);
    
    float sinOfTime2			= sin( ofGetElapsedTimef() + PI);
    float sinOfTimeMapped2		= ofMap( sinOfTime2, -1, 1, 0, 255);
    

    sin(ofGetElapsedTimef()); // moves from -1 and 1 every 2Pi seconds
    float sinValue = sin(ofGetElapsedTimef()*2);
    ofColor c;
    c.set(ofColor::pink);
    c.lerp( ofColor::blue,  ofMap(ofGetMouseX(), 0, ofGetWidth(), 0, 1, true));
    ofSetColor(c);
    ofCircle(610,480+sinValue*17, 5);
    ofCircle(640,480+sinValue*15, 5);
    ofCircle(670,480+sinValue*20, 5);

//----------draw letters-----------------
    moveup = 20;
    ofSetColor(255);
    Inst.draw(540,ofGetHeight()-60);
    
    letterheight = 380- moveup;
    float intalphaMapped = ofMap(moveZach, 20, ofGetWidth()-400, 0, 255);
  
    ofSetColor(224,103,99,intalphaMapped);
    IntroBlack.drawString(letterT, 235,letterheight);
    ofSetColor(245,155,181,intalphaMapped);
    IntroBlack.drawString(letterR, 405,letterheight);
    ofSetColor(200,221,109,intalphaMapped);
    IntroBlack.drawString(letterU, 605,letterheight);
    ofSetColor(98,196,215,intalphaMapped);
    IntroBlack.drawString(letterS, 805, letterheight);
    ofSetColor(245,155,181,intalphaMapped);
    IntroBlack.drawString(letterT2, 1005,letterheight);
    
    
    ofSetColor(brown);
    RuleOneeverything.draw(50,25);

    if (ofGetMousePressed() && ofGetMouseX()>100 && ofGetMouseX()<ofGetWidth()-305){
        moveZach = ofGetMouseX();
         }

    Zach.draw(moveZach-220,434,484/1.1,430/1.1);

   

}