示例#1
0
//--------------------------------------------------------------
void testApp::drawActor(const ramActor &actor)
{
	ramNode n1 = actor.getNode(ramActor::JOINT_HEAD);
	ramNode n2 = actor.getNode(ramActor::JOINT_RIGHT_HAND);
	ramNode n3 = actor.getNode(ramActor::JOINT_LEFT_HAND);
	ramNode n4 = actor.getNode(ramActor::JOINT_RIGHT_TOE);
	ramNode n5 = actor.getNode(ramActor::JOINT_LEFT_TOE);

	ofPushStyle();
	{
		// draw line betweem two nodes
		ofNoFill();
		ofSetColor( ramColor::RED_LIGHT );
		ofSetLineWidth( 3 );
		ofLine( n2, n3 );


		// draw triangle using three nodes
		ofFill();
		ofSetColor( ramColor::BLUE_LIGHT );
		ofSetLineWidth( 3 );
		ofTriangle( n1, n4, n5 );


		// ramNode::beginTransform() ~ endTransform()
		n1.beginTransform();
		{
			// draw cube at JOINT_HEAD
			ofNoFill();
			ofSetColor( ramColor::YELLOW_DEEP );
			ofSetLineWidth( 3 );
			ofBox( 20 );

			// draw cone at JOINT_HEAD
			ofNoFill();
			ofSetColor( ramColor::GRAY );
			ofSetLineWidth( 2 );
			ofCone(10, 100);
		}
		n1.endTransform();


		// draw plane using several nodes
		ofNoFill();
		ofSetColor( ramColor::YELLOW_LIGHT );
		ofSetLineWidth( 2 );
		ofPushMatrix();
		{
			ofScale( 3, 3, 3 );
			ramStripe( n1, n2, n3, n4, n5 );
		}
		ofPopMatrix();
	}
	ofPopStyle();
}
void radar::draw(){
    ofSetColor(255,255,0);
    //length of radar
    float x1 = 2000 * cos(ofDegToRad(angle + width));
    float y1 = 2000 * sin(ofDegToRad(angle + width));
    
    float x2 = 2000 * cos(ofDegToRad(angle - width));
    float y2 = 2000 * sin(ofDegToRad(angle - width));
    
    ofTriangle(ofGetWidth()/2,ofGetHeight()/2,x1,y1,x2,y2);
}
示例#3
0
void ofDrawTriangles(const ArrayBridge<ofShapeTriangle2>& Triangles)
{
	for ( int t=0;	t<Triangles.GetSize();	t++ )
	{
		auto& Triangle = Triangles[t];
		auto& v0 = Triangle.mTriangle[0];
		auto& v1 = Triangle.mTriangle[1];
		auto& v2 = Triangle.mTriangle[2];
		ofTriangle( v0.x, v0.y, v1.x, v1.y, v2.x, v2.y );
	}
}
示例#4
0
//--------------------------------------------------------------
void ofApp::draw(){
    //draw the polygons using built-in openframeworks functions
    ofTriangle(triX1, triY1, triX2, triY2, triX3, triY3);
    ofRect(rectX, rectY, rectW, rectH);
    ofCircle(circX, circY, radius);
    
    //draw the polygons using our own custom functions
    drawTriangleByVertex(triX1 + xOffset2, triY1, triX2 + xOffset2, triY2, triX3 + xOffset2, triY3);
    drawRectByVertex(rectX + xOffset2, rectY, rectW, rectH);
    drawCircleByVertex(circX + xOffset2, circY, radius);
}
示例#5
0
//--------------------------------------------------------------
void testApp::draw(){
    ofSetColor(242, 242, 242, 127); //描画色の設定(アルファ付き)
    ofLine(100, 300, 800, 500); //線を描く
    ofSetColor(242, 204, 47, 127); //描画色の再設定(アルファ付き)
    ofRect(200, 250, 200, 300); //四角形を描く
    ofSetColor(174, 221, 60, 127); //描画色の再設定(アルファ付き)
    ofCircle(450, 300, 150); //真円を描く
    ofSetColor(116, 193, 206, 127); //描画色の再設定(アルファ付き)
    ofEllipse(550, 500, 400, 300); //楕円を描く
    ofSetColor(211, 24, 24, 127); //描画色の再設定(アルファ付き)
    ofTriangle(700, 150, 450, 400, 750, 400); //三角形を描く
}
示例#6
0
void Shape::kaktNenShape(int xpos, int ypos, int radius){
    type = ofRandom(0, 3);
    int color = ofRandom(0,6);
    int alpha = 200;
    if (radius > 16) {
        radius = 16;
    }
    
    switch (color) {
        case 0:
            ofSetColor(22, 147, 165, alpha);
            break;
            
        case 1:
            ofSetColor(69,181,196, alpha);
            break;
            
        case 2:
            ofSetColor(126,206,202, alpha);
            break;
            
        case 3:
            ofSetColor(160,222,214, alpha);
            break;
            
        case 4:
            ofSetColor(199,237,232, alpha);
            break;
            
        default:
            ofSetColor(69,181,196, alpha);
            break;
    }
    
    
    switch (type) {
        case 0:
            ofCircle(xpos, ypos, radius);
            break;
            
        case 1:
            ofTriangle(xpos, ypos - radius, xpos + radius*0.5, ypos+radius*0.5, xpos-radius*0.5, ypos+radius*0.5);
            break;
        case 2:
            ofRect(xpos - radius * .5, ypos - radius * .5, radius, radius);
            break;
            
        default:
            ofCircle(xpos, ypos, radius);
            break;
    }
    ofSetColor(255, 255, 255, 255);
}
示例#7
0
 static int lua_graphics_triangle(lua_State *L) {
     float x1 = luaL_checknumber(L, 1);
     float y1 = luaL_checknumber(L, 2);
     float x2 = luaL_checknumber(L, 3);
     float y2 = luaL_checknumber(L, 4);
     float x3 = luaL_checknumber(L, 5);
     float y3 = luaL_checknumber(L, 6);
     
     ofTriangle(x1, y1, x2, y2, x3, y3);
     
     return 0;
 }
示例#8
0
void Player::draw() const {
    ofFill();
    ofSetColor(0, 0, 255);
    float x = rect.getX();
    float y = rect.getY();

    ofTriangle(
       x, y + H,
       x + W / 2, y,
       x + W, y + H
    );
}
示例#9
0
//--------------------------------------------------------------
void ofApp::draw(){
    ofColor background;
    ofColor brush;
    background.set(30, 40, 30);
    brush.set(200, 200, 10);
    ofBackground(background);
    int circleSize = 400;
    ofNoFill();
    ofSetColor(brush);
//    ofCircle(ofGetWidth()/2, ofGetHeight()/2, circleSize);
    float a = 1.5;
    for (int i = 0; i < 48; i++) {
        a = ofRandom(1.0);
        ofLine(ofGetWidth()/2, ofGetHeight()/2,
               ofGetWidth()/2  + a * circleSize * cos(PI*(i/24.0)),
               ofGetHeight()/2 + a * circleSize * sin(PI*(i/24.0))
               );
    }
    int k = 50;
    ofTriangle(ofGetWidth()/2  + k * cos(PI*(-0.5+(2.0/3.0))),
               ofGetHeight()/2 + k * sin(PI*(-0.5+(2.0/3.0))),
               ofGetWidth()/2  + k * cos(PI*(-0.5+(4.0/3.0))),
               ofGetHeight()/2 + k * sin(PI*(-0.5+(4.0/3.0))),
               ofGetWidth()/2  + k * cos(PI*(-0.5+(6.0/3.0))),
               ofGetHeight()/2 + k * sin(PI*(-0.5+(6.0/3.0)))
               );
    k = 45;
    ofFill();
    ofTriangle(ofGetWidth()/2  + k * cos(PI*(-0.5+(2.0/3.0))),
               ofGetHeight()/2 + k * sin(PI*(-0.5+(2.0/3.0))),
               ofGetWidth()/2  + k * cos(PI*(-0.5+(4.0/3.0))),
               ofGetHeight()/2 + k * sin(PI*(-0.5+(4.0/3.0))),
               ofGetWidth()/2  + k * cos(PI*(-0.5+(6.0/3.0))),
               ofGetHeight()/2 + k * sin(PI*(-0.5+(6.0/3.0)))
               );
    ofSetColor(background);
    ofCircle(ofGetWidth()/2, ofGetHeight()/2, 15);
    ofSetColor(brush);
    ofCircle(ofGetWidth()/2, ofGetHeight()/2, 10);
}
示例#10
0
void View::DrawGravityAt(ofPoint position, const Model &model) const {
  const ofVec2f gravity = OpenFrameworksVector(model.GravityAt(Box2dVector(position)));
  ofPushStyle();
  ofPushMatrix();
  ofTranslate(position.x, position.y);
  ofScale(0.5, 0.5);
  ofSetColor(ofColor::slateGrey, 64.0);
  const ofVec2f arrowhead = gravity / 9.81;
  ofTriangle(arrowhead, kBallRadius * arrowhead.perpendiculared(),
             -kBallRadius * arrowhead.perpendiculared());
  ofPopMatrix();
  ofPopStyle();
}
示例#11
0
//----------------------------------------------------------
void ofxVectorGraphics::triangle(float x1,float y1, float x2, float y2, float x3, float y3){
	if(bDraw){
		ofTriangle(x1, y1,  x2,  y2,  x3,  y3);
	}
	if(bRecord){
		creeps.startPath(x1, y1);
		creeps.addLine(x2,  y2);
		creeps.addLine(x3,  y3);						
		creeps.closeSubpath();
		if(bFill)creeps.endPath(CreEPS::FILL);
		else creeps.endPath(CreEPS::STROKE);
	}
}	
示例#12
0
void ofxSimpleGuiComboBox::draw(float x, float y) {
	//we assume a max of 256 characters.
	char choiceBuf[512];
	
	setPos(x, y);
	
	glPushMatrix();
	glTranslatef(x, y, 0);
	
	ofEnableAlphaBlending();
	ofFill();
	setTextBGColor();
	ofRect(0, 0, width, height);
	
	setTextColor();
//	sprintf(choiceBuf, "%s: %s", m_title, m_choices.size() ? m_choices[m_selectedChoice] : "(No Choices Available)");
	
	ofDrawBitmapString(m_title + " : " + (m_choices.size() ? m_choices[m_selectedChoice] : "N/A"), kSGCBTextPaddingX, kSGCBTextPaddingY);
	//draw a combobox down triangle icon so the users know to click
	ofTriangle(width - (kSGCBTriangleWidth + KSGCBTrianglePadding), kSGCBTextPaddingY/2,
			   width - (KSGCBTrianglePadding), kSGCBTextPaddingY/2,
			   width - (kSGCBTriangleWidth/2 + KSGCBTrianglePadding), kSGCBTextPaddingY);
	
	if ( ignoresXML() ){
		ofSetHexColor(config->noXmlColor);
		ofRect(width-config->noXmlBarWidth, 0, config->noXmlBarWidth, height);
	}

	if(m_hasFocus) {
		setCBTextBGColor();
		ofRect(0, height, width, config->comboBoxTextHeight * m_choices.size());
		setTextColor();
		ofLine(0, config->comboBoxHeight-1, width, config->comboBoxHeight-1);
		
		for(int i=0; i < m_choices.size(); i++) {
			setCBTextColor();
			//invert for selected choice
			float curY = height + i*config->comboBoxTextHeight; 
			if(i==m_mouseChoice){
				//draw a text colored rect so we can see the inverse
				ofRect(0, curY, width, config->comboBoxTextHeight);
				setCBTextBGColor();
			}
			
			ofDrawBitmapString(m_choices[i], kSGCBTextPaddingX, curY + kSGCBTextPaddingY);
		}
	}
	ofDisableAlphaBlending();
	
	glPopMatrix();
}
示例#13
0
//--------------------------------------------------------------
void testApp::draw(){
	ofBackground( 255, 255, 255 );      	//Set white background
	ofSetColor( 0, 0, 0 );					//Set black color

	ofNoFill();								//Draw shapes unfilled

	ofSetCircleResolution( 40 );			//Increase smoothing of the circle

	ofCircle( stem0, 40 );					//Blossom
	ofLine( stem0, stem3 );					//Stem
	ofTriangle( stem1, stem2, leftLeaf );	//Left leaf
	ofTriangle( stem1, stem2, rightLeaf );	//Right leaf

	//Drawing petals

	ofPushMatrix();		//Store the coordinate system

	//Translate the coordinate system center to stem0
	ofTranslate( stem0 );

	//Rotate the coordinate system depending on the time
	float angle = ofGetElapsedTimef() * 30;
	ofRotate( angle );

	int petals = 15;	//Number of petals
	for (int i=0; i<petals; i++) {
		//Rotate the coordinate system
		ofRotate( 360.0 / petals );

		//Draw petal as a triangle
		ofPoint p1( 0, 20 );
		ofPoint p2( 80, 0 );
		ofTriangle( p1, -p1, p2 );
	}

	//Restore the coordinate system
	ofPopMatrix();
}
示例#14
0
//--------------------------------------------------------------
void testApp::drawGravity(ofPoint p, ofPoint gravity) {
    
    float angle = (atan2(gravity.y, gravity.x) * 180 / PI) - 90;
    float len   = MIN(200, gravity.length()*10); // scale it up a bit
    
    ofPushMatrix();
    ofTranslate(p.x, p.y);
    ofRotate(angle);
    ofLine(0, 0, 0, len);
    ofTriangle(0, len, 
               -5, len-10, 
               5, len-10);
    ofPopMatrix();
}
示例#15
0
void Player::draw(){
	ofSetColor(color.x, color.y, color.z);
	ofFill();
	ofCircle(pos.x, pos.y, 10);
	setShape();
	//ofLine(pos.x,pos.y,pos.x + (cos(ofDegToRad(heading)) * length), pos.y + (sin(ofDegToRad(heading)) * length));
	//ofLine(leftHand.x,leftHand.y,rightHand.x,rightHand.y);
	ofNoFill();
	ofSetLineWidth(2);
	ofTriangle(head.x,head.y, rightHand.x,rightHand.y,leftHand.x,leftHand.y);
	ofSetLineWidth(1);
	goodMind->draw();
	//badMind->draw();
}
示例#16
0
void Arrow::draw() {
    
    float x1 = 0;
    float y1 = -10;
    float x2 = 0;
    float y2 = 10;
    float x3 = 30;
    float y3 = 0;
    
    ofTranslate(pos);
    ofRotate(rot);
    ofSetColor(color);
    ofTriangle(x1, y1, x2, y2, x3, y3);
}
示例#17
0
void Timeline::draw(int speed){
    
    if(!this->isShow)
        return;
    
    ofSetColor(this->line_color);
    ofFill();

    int y_pos = 1030;
    
    // horizontal line
    // ofLine( 60, y_pos, 1860, y_pos);
    
    // tick
    int current_frame = ofGetFrameNum();
    
    int x = ((current_frame/speed)%365 + (1.0*(current_frame%speed)/speed)) * (1800/365.0) + 60;
    
    ofTriangle(x, y_pos, x-4, y_pos+2*this->tick_size, x+4, y_pos+2*this->tick_size);
    
    
    float scale, maxFontWidth, newFontWidth;
    float month_displacement, displacement;
    float offset;
    // draw month name
    for(int i = 0 ; i < 12; i++){
        
        maxFontWidth = max_font->stringWidth(this->monthNames[i]);
        month_displacement = i+0.5;
        
        displacement = (x-60)/150.0;
        offset = displacement-month_displacement;
        if( abs(offset) <= 0.5){
            if( offset <= 0)
                scale = 1 + offset;
            else
                scale = 1 - offset;
        }else{
            scale = 0.5;
        }
        newFontWidth = maxFontWidth * scale;
        
        ofPushMatrix();
            ofTranslate(60+month_displacement*150, y_pos-8);
            ofScale(scale, scale, 1);
            this->max_font->drawString(this->monthNames[i],-newFontWidth/2,0 );
        ofPopMatrix();
        
    }
}
//--------------------------------------------------------------
void testApp::draw() {
    ofSetBackgroundColor(255);
    int i = 0;
    for(Circle c : circles)
    {
        //ofCircle(c.pos.getPosition(), c.radius);
        ofSetColor(0);
        ofVec3f p = c.pos.getPosition();
        ofTriangle(p + c.tri[0], p + c.tri[1], p + c.tri[2]);
        ofSetColor(255);
        ofDrawBitmapString(ofToString(i++), c.pos.getPosition());
    }
    gui.draw();
}
示例#19
0
void BlackBoxApp::drawTriangleColor() {
    ofPushStyle();
    
    ofFill();
    int i = 0;
    int l = triangle.nTriangles;
    for (; i<l; i++) {
        ofSetColor(ofRandom(0, 0xffffff));
        ofTriangle(getResizedX(triangle.triangles[i].a.x), getResizedY(triangle.triangles[i].a.y),
                   getResizedX(triangle.triangles[i].b.x), getResizedY(triangle.triangles[i].b.y),
                   getResizedX(triangle.triangles[i].c.x), getResizedY(triangle.triangles[i].c.y));
    }
    
    ofPopStyle();
}
示例#20
0
// ----------------------------------
void LeafNY::drawMe()
{
    //To draw the square leaves
    ofSetColor(color);
    
    float angle = ofMap(radius, 15, 30, 0, 360);
    //To let the leaves have rotation
    ofSetRectMode(OF_RECTMODE_CENTER);
    ofPushMatrix();
    ofTranslate(pos.x,pos.y);
    ofRotate(angle);
    ofTriangle(0, radius*energy, 0.866*radius*energy, -0.5*radius*energy, -0.866*radius*energy, -0.5*radius*energy);
    ofPopMatrix();
    
}
示例#21
0
void BlackBoxApp::drawTriangleBlue() {
    ofPushStyle();
    
    ofFill();
    int i = 0;
    int l = triangle.nTriangles;
    for (; i<l; i++) {
        ofSetColor(ofRandom(0, 150), ofRandom(75, 220), ofRandom(200, 255), 255);
        ofTriangle(getResizedX(triangle.triangles[i].a.x), getResizedY(triangle.triangles[i].a.y),
                   getResizedX(triangle.triangles[i].b.x), getResizedY(triangle.triangles[i].b.y),
                   getResizedX(triangle.triangles[i].c.x), getResizedY(triangle.triangles[i].c.y));
    }
    
    ofPopStyle();
}
示例#22
0
//--------------------------------------------------------------
void testApp::draw(){
	
	// shapes color and transparency example 2
	ofNoFill();									// set the draw mode to be outline -- noFill()
	ofSetColor(0,0,0);							// set the color of the shape you'll draw next
	ofCircle(380, 201, 90);						// draw the shape - circle
	
	ofFill();
	ofSetColor(255, 0, 0, 180);					// choose the color and transparency values for the triangle you'll be drawing (Red, Green, Blue, Alpha)
	ofTriangle(225, 215, 475, 215, 350, 365);	// drawing a Triangle - values are for X,Y for each of the 3 points that define the shape
	

	ofSetColor(150, 255, 255,150);				// choose the color and transparency values for the rectangle shape you'll be drawing (Red, Green, Blue, Alpha)
	ofRect(180, 145, 150, 150);					// drawing a Rectangle - values are for: X position, Y position, Width, Height	
	
}
示例#23
0
void Boid::display()
{
    // Draw a triangle rotated in the direction of velocity
    float angle = (float)atan2(-velocity.y, velocity.x);
    float theta =  -1.0*angle;
    float heading2D = ofRadToDeg(theta)+90;
    
    ofEnableAlphaBlending();
    ofSetColor(color);
    ofFill();
    ofPushMatrix();
    ofTranslate(location.x, location.y);
    ofRotateZ(heading2D);
    ofTriangle(0, -r*2, -r, r*2, r, r*2);
    ofPopMatrix();
    ofDisableAlphaBlending();
}
void testApp::draw()
{
	ofSetColor(255, 255, 255);
	if(playback) 
	{
		// draw from the player
		kinectPlayer.drawDepth(10, 10, displayWidth, displayHeight);
	} 
	else 
	{
		// draw from the live kinect
		depthImage.draw(10, 10, displayWidth, displayHeight);
	}
	blobsImage.draw(displayWidth+10*2, 10, displayWidth, displayHeight);
	contourFinder.draw(displayWidth+10*2, 10, displayWidth, displayHeight);
	blobsManager.debugDraw(displayWidth+10*2, 10, kinect.width, kinect.height, displayWidth, displayHeight);
	
	// draw recording/playback indicators
	ofPushMatrix();
	ofTranslate(25, 25);
	ofFill();
	if(record)
	{
		ofSetColor(255, 0, 0);
		ofCircle(0, 0, 10);
	}
	if(playback) 
	{
		ofSetColor(0, 255, 0);
		ofTriangle(-10, -10, -10, 10, 10, 0);
	}
	ofPopMatrix();
	
	ofSetColor(255, 255, 255);
	stringstream reportStream;
	reportStream 
	<< "set near threshold " << nearThreshold << " (press: + -)" << endl
	<< "set far threshold " << farThreshold << " (press: < >) " << endl 
	<< "num blobs found " << contourFinder.nBlobs
	<< ", fps: " << ofGetFrameRate() << endl
	<< "press UP and DOWN to change the tilt angle: " << angle << " degrees" << endl
	<< "press r to record and p to playback. " << ((record)? "is recording." : "") << ((playback)? "is playing." : "") << endl
	<< "set tilt angle: " << angle << " degrees (press UP and DOWN)";
	ofDrawBitmapString(reportStream.str(),10,displayHeight+10*3);
}
//--------------------------------------------------------------
void testApp::draw(){

    ofEnableAlphaBlending();    
    ofEnableSmoothing();      
    ofSetLineWidth(1);
    
    
    
    //draw two dimensional array
    
    ofSeedRandom(0);
    
    ofSetColor(24, ofRandom(255), 117,70);
    ofNoFill();
  
    for(int i=0; i<NUM; i++){
        mouse.x=mouseX;
        mouse.y=mouseY;
        int distance= (pos[i] - mouse).length()/6;
        distance=ofClamp(distance, 7, ofRandom(5,100));
        difference = pos[i]-mouse;
        
        float angle = atan2(difference.y, difference.x);
        
//        polygon = ofRandom(3,8);
     
//        for (int j = 0; j < polygon; j++) {
//            j = j+1;
//            ofPushMatrix();
//            ofTranslate(pos[i].x,pos[i].y);
//            ofRotate(360/polygon*j);
//            ofTriangle(0,0,distance,0,distance*cos(360/polygon*j),sin(360/polygon*j));
//            ofPopMatrix(); 
//        }
        
        ofPushMatrix();
        ofTranslate(pos[i].x,pos[i].y);
        ofRotate(angle * RAD_TO_DEG);
        ofTriangle(0,0,distance,0,distance*0.5,distance*0.866);
        ofPopMatrix();
                 
           }
    

}
示例#26
0
void compassInput::drawTriangle(int x, int y,float scale){
    
    // compass triangle
    ofPushMatrix();
    ofTranslate(x, y);
    ofScale(scale, scale);
    ofRotateZ   (heading);
	float size  = 20;
    ofPushMatrix();
    ofRotate(-90);
	ofPoint ptA = ofPoint( cos(TWO_PI/3)    * size, sin(TWO_PI/3)   * size);
	ofPoint ptB = ofPoint( cos(2*TWO_PI/3)  * size, sin(2*TWO_PI/3) * size);
	ofPoint ptC = ofPoint( cos(3*TWO_PI/3)  * size, sin(3*TWO_PI/3) * size);
	ofTriangle  (ptA, ptB, ptC);
    ofPopMatrix();
    ofLine(0, size/2, 0, -size);
    ofPopMatrix();
    
}
示例#27
0
void ofDrawTriangles(const ArrayBridge<ofShapeTriangle2>& Triangles,ofTexture& Texture,const ArrayBridge<ofShapeTriangle2>& TexCoords)
{
	Texture.bind();

	for ( int t=0;	t<Triangles.GetSize();	t++ )
	{
		auto& Triangle = Triangles[t];
		auto& TexCoord = TexCoords[t];
		auto& v0 = Triangle.mTriangle[0];
		auto& v1 = Triangle.mTriangle[1];
		auto& v2 = Triangle.mTriangle[2];
		
		glEnableClientState(GL_TEXTURE_COORD_ARRAY);
		glTexCoordPointer( 2, GL_FLOAT, sizeof(ofVec2f), &TexCoord );
		ofTriangle( v0.x, v0.y, v1.x, v1.y, v2.x, v2.y );
		glDisableClientState(GL_TEXTURE_COORD_ARRAY);
	}

	Texture.unbind();
}
示例#28
0
void ofApp::mousePressed(int x, int y, int button)
{
    //--------------------------------------------------------------
    // Trigger stuff. Press right mouse button for bells.
    //--------------------------------------------------------------
    
    if (button == 0)
    {
        this->mouseDragged(x, y, button);
        synth->set("amp", 0.8f);
    }
    else if (button == 2)
    {
        playbuf->set("rate", 2.0f * x / ofGetWidth());
        playbuf->create();
        
        ofSetColor(255, 255, 0, 200);
        ofTriangle(x, y - 10, x + 10, y + 10, x - 10, y + 10);
    }
}
//--------------------------------------------------------------
void ofApp::draw(){
    //*********************************
    //AUDIO
    //*********************************
    
    //*********************************
    //END OF AUDIO
    //*********************************
    
    //*********************************
    //TRIANGLES CLOUD
    //*********************************
    ofEnableDepthTest();    //Enable z-buffering
    
    //Set a gradient background from white to gray
    //for adding an illusion of visual depth to the scene
    ofBackgroundGradient( ofColor( 255 ), ofColor( 128 ) );
    
    ofPushMatrix();    //Store the coordinate system
    
    //Move the coordinate center to screen's center
    ofTranslate( ofGetWidth()/2, ofGetHeight()/2, 0 );
    
    //Calculate the rotation angle
    float time = ofGetElapsedTimef();       //Get time in seconds
    float angle = time * 10;                //Compute angle. We rotate at speed
    //10 degrees per second
    ofRotate( angle, 0, 1, 0 );             //Rotate the coordinate system
    //Draw the triangles
    for (int i=0; i<nTri; i++) {
        ofSetColor( colors[i] );            //Set color
        ofTriangle( vertices[ i*3 ],
                   vertices[ i*3 + 1 ],
                   vertices[ i*3 + 2 ] );   //Draw triangle
        
    }
    ofPopMatrix(); //Restore the coordinate system
    //*********************************
    //END OF TRIANGLES CLOUD
    //*********************************
}
示例#30
0
void Boid::draw(float brightness) {
    // Draw a triangle rotated in the direction of velocity
	float angle = (float)atan2(-vel.y, vel.x);
    float theta =  -1.0*angle;
	float heading2D = ofRadToDeg(theta)+90;
	
	ofEnableAlphaBlending();
    ofSetColor(255, 255, 255, 255*brightness);
    ofFill();
    ofPushMatrix();
    ofTranslate(loc.x, loc.y);
    ofRotateZ(heading2D);
	ofTriangle(0, -r*2, -r, r*2, r, r*2); //ofTriangle is quicker according to: http://www.openframeworks.cc/forum/viewtopic.php?f=8&t=3026&view=previous	
		//	ofBeginShape(); 
//    ofVertex(0, -r*2);
//    ofVertex(-r, r*2);
//    ofVertex(r, r*2);
//    ofEndShape(true);
    ofPopMatrix();
	ofDisableAlphaBlending();
}