//--------------------------------------------------------------
void Leaf::draw(){
    ofPushMatrix();
    
        ofTranslate(xPos,yPos);
        ofRotate(90);
        ofRotate(rotation);
    
    
        //leaf left side
    
  
        ofSetColor(leafColor);
    
        ofBeginShape();
            ofVertex(x1,y1);
            ofBezierVertex(x2, y2, x3, y3, x4, y4);
    
        ofEndShape();
    
        //right side
        ofBeginShape();
            ofVertex(x1,y1);
            ofBezierVertex(-x2, y2, -x3, y3, -x4, y4);
    
        ofEndShape();
    
    //leaf line
    ofSetColor(stemColor);
    ofTriangle(0-stemWidth/2, y1, 0+stemWidth/2, y1, 0, leafLength );

    
    ofPopMatrix();
    
}
Ejemplo n.º 2
0
//--------------------------------------------------------------
void testApp::draw(){
    ofEnableAlphaBlending();
    float bez1X1 = 350+50 * cos(ofGetElapsedTimef()*2.0f); 
    float bez1Y1 = 200+100 * sin(ofGetElapsedTimef()/3.5f);
    float bez1X2 = 400+30 * cos(ofGetElapsedTimef()*5.0f); 
    float bez1Y2 = 300+100 * sin(ofGetElapsedTimef());     
    float bez2X1 = 350+50 * cos(ofGetElapsedTimef()*2.0f); 
    float bez2Y1 = 200-100 * sin(ofGetElapsedTimef()/3.5f); 
    float bez2X2 = 400+30 * cos(ofGetElapsedTimef()*5.0f); 
    float bez2Y2 = 300-100 * sin(ofGetElapsedTimef());
    ofFill();
    ofSetColor(255, 0, 0, 127); ofBeginShape();
    // first we create the point from which to begin drawing ofVertex(100,300);
    // then create the Bezier vertex ofBezierVertex(100,300,bez1X2,bez1Y2,650,300); ofBezierVertex(650,300,bez2X2,bez2Y2,100,300);
    // finish the shape
    ofVertex(650,300); 
    ofEndShape();
    ofFill();
    ofSetColor(255, 0, 0, 127); ofBeginShape();
    ofVertex(100,300); ofBezierVertex(bez1X1,bez1Y1,bez1X2,bez1Y2,650,300); 
    ofBezierVertex(bez2X1,bez2Y1,bez2X2,bez2Y2,100,300); 
    ofVertex(650,300);
    ofEndShape();    
    
}
Ejemplo n.º 3
0
//--------------------------------------------------------------
void testApp::heart(float x2, float y2, float scale, float color) {

    float myLenght = sin(myRotation/6.5) *20;
    
    //LINES BG
    ofPushMatrix();
        ofRotate(myRotation * 1.5);
        ofFill();
        ofSetColor(0, 180, 180);

        float myPulse = 130 + myLenght;
        ofLine(0, 0, 0,  myPulse);
        ofLine(0, -myPulse, 0,  0);
    
        ofSetColor(110, 0, 150, 100 );
        ofCircle(myPulse+10, 0, 1);

    ofPopMatrix();
    
    
    //HEART
    ofPushMatrix();
    ofSetColor(250, 0, 0);

    ofTranslate(0, -25);
    ofBeginShape();
        ofVertex(0, 20);
        ofBezierVertex(0, -35, 80, 10, 0, 60);
        ofVertex(0, 20);
        ofBezierVertex(0, -35, -80, 10, 0, 60);
    ofEndShape();
    ofPopMatrix();
 

}
Ejemplo n.º 4
0
void ArrowShape::draw(float scale = 1, bool fill = false){
    
    ofSetColor(colour);
    ofPushMatrix();
    ofPushStyle();
    ofTranslate(pos);
    ofScale(size*scale, size*scale);
    ofRotate(rotation);
    
    if (!fill) {
        ofNoFill();
        ofSetLineWidth(2);
    }
    
    //ofCircle(0, 0, 1);
    
    ofBeginShape();
    ofVertex(-25,7);
    ofBezierVertex(-25,11,-18,17,-18,17);
    ofVertex(-13,23);
    ofBezierVertex(-8,18,0,10,0,10);
    ofVertex(13,23);
    ofVertex(17,18);
    ofBezierVertex(17,18,24,13,25,8);
    ofBezierVertex(25,3,21,0,21,0);
    ofVertex(0,-23);
    ofVertex(-22,-2);
    ofBezierVertex(-22,-2,-26,2,-25,7);
    ofEndShape();

    ofPopStyle();
    ofPopMatrix();
    
}
Ejemplo n.º 5
0
void CurveSquare::draw(float scale = 1, bool fill=false){
    
    ofSetColor(colour);
    ofPushMatrix();
    ofPushStyle();
    ofTranslate(pos);
    ofScale(size*scale, size*scale);
    ofRotate(rotation);
    
    if (!fill) {
        ofNoFill();
        ofSetLineWidth(2);
    }
    
   
    //ofCircle(0, 0, 1);
    
    ofBeginShape();
    ofVertex(-9,-21);
    ofBezierVertex(-9,-21,-15,-21,-18,-17);
    ofBezierVertex(-21,-13,-21,-5,-21,-5);
    ofVertex(-21,21);
    ofVertex(4,21);
    ofBezierVertex(4,21,12,22,16,19);
    ofBezierVertex(20,16,21,10,21,10);
    ofVertex(21,-21);
    ofVertex(-9,-21);
    ofEndShape();    
    ofPopStyle();
    ofPopMatrix();
}
//--------------------------------------------------------------
void Leaf::draw(){
    //    ofRect(xPos, yPos, 20,20); //test if code is working - white rect
    cout << stemWidth << endl;  //this is println - displays values
    
    ofPushMatrix();
    ofTranslate(xPos, yPos);
    ofScale(scaleFactor, scaleFactor);
    ofRotateZ(rotation);
    
    //1
    //left leaf
//    ofSetColor (myColor);
    ofBeginShape();
    float x0 = 0;
    float x1 = x0 - leafWidth/2;
    float x2 = x0 - leafWidth/4; // or leafCurvature
    float x3 = x0;
    
    float y0 = 0 -  stemLength;
    float y1 = y0 - leafLength/3;
    float y2 = y1 - leafLength/3;
    float y3 = y0 - leafLength;
    
    ofVertex (x0, y0);
    ofBezierVertex(x1, y1, x2, y2, x3, y3);
    
    ofEndShape();
    
    
    //right leaf
    ofBeginShape();
    x0 = 0;
    x1 = x0 + leafWidth/2;
    x2 = x0 + leafWidth/leafCurvature;
    x3 = x0;
    
    y0 = 0 - stemLength;
    y1 = y0 - leafLength/3;
    y2 = y1 - leafLength/3;
    y3 = y0 - leafLength;
    
    ofVertex (x0, y0);
    ofBezierVertex(x1, y1, x2, y2, x3, y3);
    
    ofEndShape();
    
    //draw stem
//    ofSetColor (stemColor);
//    ofRect (0,0 - (stemLength/2), stemWidth, stemLength);
//    ofTriangle (0 - stemWidth/2, 0 - stemLength, 0 + stemWidth/2, 0 - stemLength, 0, 0 - stemLength - 3*(leafLength/4));
    
    
    ofPopMatrix();
    
}
Ejemplo n.º 7
0
void testApp::myShape1(int _x, int _y, int _rot) {
    //HEART
    ofPushMatrix();
        ofSetColor(250, 0, 0, 10);

        ofTranslate(_x, _y);
        ofRotate(_rot);
        ofBeginShape();
            ofVertex(0, 20);
            ofBezierVertex(0, -35, 80, 10, 0, 60);
            ofVertex(0, 20);
            ofBezierVertex(0, -35, -80, 10, 0, 60);
        ofEndShape();
    ofPopMatrix();
}
Ejemplo n.º 8
0
void GReaf::draw(){
	ofRotateZ(rotZ);
	
	ofSetPolyMode(OF_POLY_WINDING_NONZERO);
	
	glPushMatrix();
	ofSetColor(255, 255, 255);
	ofRotateZ(180);
    myImage.draw(0, 0, 100, reafTopMov);
    glImage.draw(0, 105, 50, reafTopMov+100);
	glPopMatrix();
		//
	ofSetColor(213, 255, 155, 70);
	ofFill();
	//ofSetLineWidth(1);
    
    //ofSetColor(0, 123, 80, 70);
	//ofNoFill();
	ofSetLineWidth(6);
	
	ofBeginShape();
	ofVertex(0, -105);
	ofBezierVertex(0, -105, reafLeftMov, -105, reafTopRLMov, reafTopMov);
	ofVertex(reafTopRLMov, reafTopMov);
	ofBezierVertex(reafTopRLMov, reafTopMov, reafRightMov, -105, 0, -105);
	ofEndShape();
		//
	
    	
    /*
	ofBeginShape();
	ofVertex(0, -135);
	ofBezierVertex(0, -135, reafLeftMov, -135, reafTopRLMov, reafTopMov);
	ofVertex(reafTopRLMov, reafTopMov);
	ofBezierVertex(reafTopRLMov, reafTopMov, reafRightMov, -135, 0, -135);
	ofEndShape();
		//ofNextContour();//
	ofBeginShape();
	ofVertex(0, -135);
	ofBezierVertex(0, -135, (reafLeftMov+reafRightMov)/2, -135, reafTopRLMov, reafTopMov);
	ofVertex(reafTopRLMov, reafTopMov);
	ofBezierVertex(reafTopRLMov, reafTopMov, (reafLeftMov+reafRightMov)/2, -135, 0, -135);
	ofEndShape();
     
     */
	
}
Ejemplo n.º 9
0
void Weirdo::draw(){
    
    ofPushMatrix();
    ofPushStyle();
    ofTranslate(posEnd.x, posEnd.y);
    ofRotate(rotation);
    ofScale(scaleAmount, scaleAmount);
    ofFill();
    ofBeginShape();
    ofVertex(0,0);
    ofBezierVertex(-5,-2,-13,0,-20,7);
    ofBezierVertex(-22,-7,-27,-18,-35,-18);
    ofBezierVertex(-45,-19,-55,0,-57,26);
    ofBezierVertex(-60,51,-54,72,-44,74);
    ofBezierVertex(-43,76,-42,77,-40,78);
    ofBezierVertex(-30,83,-14,70,-2,48);
    ofBezierVertex(8,26,9,4,0,0);
    ofEndShape();
    
    ofPopMatrix();
    ofPopStyle();
    
    
    
}
void TextImageContent::quadraticBezierVertex(float cpx, float cpy, float x, float y, float prevX, float prevY )
{
    float cp1x = prevX + 2.0/3.0*(cpx - prevX) ;
    float cp1y = prevY + 2.0/3.0*(cpy - prevY) ;
    float cp2x = cp1x + ( x-prevX )/3.0 ;
    float cp2y = cp1y + ( y-prevY )/3.0 ;

    ofBezierVertex( cp1x , cp1y , cp2x , cp2y , x , y ) ;
}
Ejemplo n.º 11
0
void simpleToggle::quadraticBezierVertex(float cpx, float cpy, float x, float y, float prevX, float prevY) {
    float cp1x = prevX + 2.0/3.0*(cpx - prevX);
    float cp1y = prevY + 2.0/3.0*(cpy - prevY);
    float cp2x = cp1x + (x - prevX)/3.0;
    float cp2y = cp1y + (y - prevY)/3.0;
    
     // finally call cubic Bezier curve function
    ofBezierVertex(cp1x, cp1y, cp2x, cp2y, x, y);
};
Ejemplo n.º 12
0
void wave::draw(){

ofSetColor(r,g,b,alpha);
    ofBeginShape();

        ofVertex(0,600);
        ofBezierVertex(50+ySin*0.5,50 +xSin*0.5,100+xSin,100+ySin,150+ySin*0.5,180+xSin*0.5);
        ofBezierVertex(150+ySin*0.5,180 +xSin*0.5,300+xSin,550+ySin,400+ySin*0.5,400+xSin*0.5);
        ofBezierVertex(400+ySin*0.5,400+xSin*0.5,600+xSin,50+ySin,650+ySin*0.5,600+xSin*0.5);
        ofBezierVertex(650+ySin*0.5,600+xSin*0.5,700+xSin,700+ySin,850+ySin*0.5,400+xSin*0.5);
        ofBezierVertex(850+ySin*0.5,400+xSin*0.5,950+xSin,300+ySin,1200+ySin*0.5,150+xSin*0.5);
        ofVertex(1200,800);
        ofVertex(0,800);

    ofEndShape(true);


};
Ejemplo n.º 13
0
void mui::Helpers::quadraticBezierVertex(float cpx, float cpy, float x, float y, float prevX, float prevY) {
	float cp1x = prevX + 2.0f/3.0f*(cpx - prevX);
	float cp1y = prevY + 2.0f/3.0f*(cpy - prevY);
	float cp2x = cp1x + (x - prevX)/3.0f;
	float cp2y = cp1y + (y - prevY)/3.0f;
	
	// finally call cubic Bezier curve function
	ofBezierVertex(cp1x, cp1y, cp2x, cp2y, x, y);
};
Ejemplo n.º 14
0
//------------------------------------------------------------------
void creature::draw() {

	
	
	ofFill();
	
	   
	
	ofPushMatrix();
	
	ofTranslate(pos.x, pos.y, 0);
	ofRotateZ(angle * RAD_TO_DEG);

	
	
	// creature body color
	ofSetColor(255,240,230);
//	ofSetColor(198,246,55);

	
	ofBeginShape();
	
	ofVertex(0,0);
	
	for(int i =0; i< 3; i++){
		ofBezierVertex(vertices[i][0].x, vertices[i][0].y, vertices[i][1].x, vertices[i][1].y, vertices[i][2].x, vertices[i][2].y);
		ofVertex(vertices[i][2].x, vertices[i][2].y);
	}
	
		
	ofEndShape();
	
		
	
	
	
	ofPopMatrix();
	

	//draw tentacles
	ofNoFill();
	ofBeginShape();

	for (int i = 0; i < points.size(); i++){
		ofVertex(points[i].x + cos(ofGetElapsedTimef()*10+1*i)*10, points[i].y );
	}
	ofEndShape();
	
	ofBeginShape();
	for (int i = 0; i < points.size(); i++){
		ofVertex(points[i].x, points[i].y );
	}
	ofEndShape();
	
	
}
Ejemplo n.º 15
0
void SpikeGraph::drawSpike(spike s) {
	float ybase = 0;
	if (s.direction == 1)
		ybase = h / 2;
	else
		ybase = h / 2;
	float c1y = ybase + s.height*0.1*s.direction;
	float c2y = ybase + s.height*0.3*s.direction;
	float c1x = spikeWidth*0.1;
	float c2x = spikeWidth*0.05;

	ofVertex(s.x, ybase);
	ofBezierVertex(ofPoint(s.x + spikeWidth - c1x, c1y),
				   ofPoint(s.x + spikeWidth - c2x, c2y),
				   ofPoint(s.x + spikeWidth, ybase + s.height*s.direction));
	ofBezierVertex(ofPoint(s.x + spikeWidth + c2x, c2y),
				   ofPoint(s.x + spikeWidth + c1x, c1y),
				   ofPoint(s.x + spikeWidth * 2, ybase));
}
Ejemplo n.º 16
0
void Radar::debug_draw_bezier_segments() {
  ofNoFill();
  ofBeginShape();
  {
    for (int i = 0; i < bezier_segments.size(); i++) {
      bezier b = bezier_segments[i];
      if (i == 0)
        ofVertex(b.start);
      ofBezierVertex(b.c1, b.c2, b.end);
    }
  }
  ofEndShape();
}
Ejemplo n.º 17
0
//----------------------------------------------------------	
//this takes three arguments as it is based off the idea that at least one 
//inital polyVertex has already been set. 					
void ofxVectorGraphics::bezierVertex(float x1, float y1, float x2, float y2, float x3, float y3){
	if(bDraw){
		ofBezierVertex(x1, y1, x2, y2, x3, y3);
	}
	if(bRecord){
		
		//clear curve vertices
		if(whichShapeMode == 1){
			clearAllVertices();	
		}
		
		whichShapeMode = 2;					
		
		//we can only add a bezier curve if the curve
		//has started with a polyVertex
		//so as long as this is not the first point we add it
		if(!bFirstPoint){
			creeps.addCurve(x1, y1, x2, y2, x3, y3);
		}
		
	}
}			
void Leaf::draw(float _xPos, float _yPos){
    
    ofPushMatrix();
    ofSetLineWidth(1);
    ofTranslate(_xPos, _yPos);
    ofScale(scaleFactor, scaleFactor);
    ofRotateZ(rotation);
    
    //draw leaf
    
    ofSetColor(leafColor);
    
    //draw left half of leaf
    
    ofBeginShape();
    
    float x0 = 0;
    float x1 = x0 - leafWidth;
    float x2 = x0 - leafWidth/leafCurvature;
    float x3 = x0;
    
    float y0 = 0 - stemLength;
    float y1 = y0 - leafLength/3;
    float y2 = y1 - leafLength/3;
    float y3 = y0 - leafLength;
    
    ofVertex(x0,y0);
    ofBezierVertex(x1,y1,x2,y2,x3,y3);
    
    ofEndShape();
    
    //draw middle part of leaf
    ofBeginShape();
    
    x0 = 0;
    x1 = x0 - leafWidth;
    x2 = x0 - leafWidth/leafCurvature;
    x3 = x0;
    
    y0 = 0 - stemLength;
    y1 = y0 - leafLength/3;
    y2 = y1 - leafLength/2;
    y3 = y0 - leafLength/2;
    
    ofVertex(x0,y0);
    ofBezierVertex(x1,y1,x2,y2,x3,y3);
    
    ofEndShape();
    
    //draw right half of leaf
    
    ofBeginShape();
    
    x0 = 0; //don't need to redefine as float, because we are just reusing the variables created above
    x1 = x0 + leafWidth;
    x2 = x0 + leafWidth/leafCurvature;
    x3 = x0 + leafWidth/3;
    
    y0 = 0 - stemLength;
    y1 = y0 - leafLength/3;
    y2 = y1 - leafLength/3;
    y3 = y0 - leafLength;
    
    ofVertex(x0,y0);
    ofBezierVertex(x1,y1,x2,y2,x3,y3);
    
    ofEndShape();
    
    //draw stem and veins of leaf
    
    ofSetColor(stemColor);
    ofRect(0,0 - (stemLength/2), stemWidth, stemLength); //MATH!

    ofTriangle(0 - stemWidth/2, 0 - stemLength, 0 + stemWidth/2, 0 - stemLength, 0, 0 - stemLength - 3*(leafLength/4));
    
    cout << "x1 = ";
    cout << x1 << endl;
    cout << "x2 = ";
    cout << x2 << endl;
    
    ofPopMatrix();
    
    
}
//--------------------------------------------------------------
void testApp::draw(){
	ofFill();
	ofSetHexColor(0xe0be21);

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

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

	ofEndShape(true);
	
	glTranslatef(100,0,0);
	
	ofSetPolyMode(OF_POLY_WINDING_NONZERO);	
	ofBeginShape();
		
		ofVertex(300,500);
		ofVertex(380,550);
		ofVertex(300,600);
		
		ofNextContour(true);
		
		for (int i = 0; i < 20; i++){
			float anglef = ((float)i / 19.0f) * TWO_PI;
			float x = 340 + 30 * cos(anglef);
			float y = 550 + 30 * sin(anglef); 
			ofVertex(x,y);
			radius 	+= radiusAdder; 
		}
		
	ofEndShape(true);
	
	glTranslatef(100,0,0);
	ofSetPolyMode(OF_POLY_WINDING_ABS_GEQ_TWO);
	ofBeginShape();
		ofVertex(300,500);
		ofVertex(380,550);
		ofVertex(300,600);
		ofNextContour(true);
		
		for (int i = 0; i < 20; i++){
			float anglef = ((float)i / 19.0f) * TWO_PI;
			float x = 340 + 30 * cos(anglef);
			float y = 550 + 30 * sin(anglef); 
			ofVertex(x,y);
			radius 	+= radiusAdder; 
		}
		
		
	ofEndShape(true);
	
	glPopMatrix();

	//-------------------------------------
	
	ofSetHexColor(0x000000);
	ofDrawBitmapString("(a) star\nwinding rule odd", 20,210);
	
	ofSetHexColor(0x000000);
	ofDrawBitmapString("(b) star\nwinding rule nonzero", 220,210);
	
	ofSetHexColor(0x000000);
	ofDrawBitmapString("(c) dynamically\ncreated shape", 420,210);
	
	ofSetHexColor(0x000000);
	ofDrawBitmapString("(d) random points\npoly", 670,210);
	
	ofSetHexColor(0x000000);
	ofDrawBitmapString("(e) fun with sin/cos", 20,410);
	
	ofSetHexColor(0x000000);
	ofDrawBitmapString("(f) ofCurveVertex\nuses catmull rom\nto make curved shapes", 220,410);
	
	ofSetHexColor(0x000000);
	ofDrawBitmapString("(g) ofBezierVertex\nuses bezier to draw curves", 460,410);
	
	
	ofSetHexColor(0x000000);
	ofDrawBitmapString("(h) ofNextContour\nallows for holes", 20,610);
	
	ofSetHexColor(0x000000);
	ofDrawBitmapString("(i) ofNextContour\ncan even be used for CSG operations\nsuch as union and intersection", 260,620);
	
}
Ejemplo n.º 20
0
void OctoplusShape::draw(float scale = 1, bool fill = false){
    
    ofSetColor(colour);
    ofPushMatrix();
    ofPushStyle();
    ofTranslate(pos);
    ofScale(size*scale, size*scale);
    ofRotate(rotation);
    
    if (!fill) {
        ofNoFill();
        ofSetLineWidth(2);
    }
    
    //ofCircle(0, 0, 1);
    
    ofBeginShape();
    ofVertex(24,4);
    ofBezierVertex(21,8,21,17,21,17);
    ofVertex(21,22);
    ofVertex(17,22);
    ofBezierVertex(17,22,8,21,4,24);
    ofBezierVertex(0,27,0,33,0,33);
    ofBezierVertex(0,33,0,27,-3,24);
    ofBezierVertex(-7,21,-16,22,-16,22);
    ofVertex(-21,22);
    ofVertex(-21,17);
    ofBezierVertex(-21,17,-21,8,-24,4);
    ofBezierVertex(-27,0,-33,0,-33,0);
    ofBezierVertex(-33,0,-27,0,-24,-3);
    ofBezierVertex(-21,-7,-21,-16,-21,-16);
    ofVertex(-21,-22);
    ofBezierVertex(-18,-22,-16,-22,-16,-22);
    ofBezierVertex(-16,-22,-7,-21,-3,-24);
    ofBezierVertex(0,-27,0,-33,0,-33);
    ofBezierVertex(0,-33,0,-27,4,-24);
    ofBezierVertex(8,-21,17,-22,17,-22);
    ofVertex(21,-22);
    ofVertex(21,-16);
    ofBezierVertex(21,-16,21,-7,24,-3);
    ofBezierVertex(27,0,33,0,33,0);
    ofBezierVertex(33,0,27,0,24,4);
    ofEndShape();
    
    ofPopStyle();
    ofPopMatrix();
}
Ejemplo n.º 21
0
//------------------------------------------------------------
void particle::draw(){
 //   ofCircle(pos.x, pos.y, 3);
    ofFill();
	
    
	
	ofPushMatrix();
	
	ofTranslate(pos.x, pos.y, 0);
	ofRotateZ(angle * RAD_TO_DEG);
    
	
	
	// creature body color
	ofSetColor(230,80,0);
    //	ofSetColor(198,246,55);
    
	
	ofBeginShape();
	
	ofVertex(0,0);
	
	for(int i =0; i< 3; i++){
		ofBezierVertex(vertices[i][0].x, vertices[i][0].y, vertices[i][1].x, vertices[i][1].y, vertices[i][2].x, vertices[i][2].y);
		ofVertex(vertices[i][2].x, vertices[i][2].y);
	}
	
    
	ofEndShape();
	
    
	
	
	
	ofPopMatrix();
	
    
	//draw tentacles
	ofNoFill();
	ofBeginShape();
    
	for (int i = 0; i < points.size(); i++){
		ofVertex(points[i].x + cos(ofGetElapsedTimef()*10+1*i)*10, points[i].y );
	}
	ofEndShape();
	
	ofBeginShape();
	for (int i = 0; i < points.size(); i++){
		ofVertex(points[i].x, points[i].y );
	}
	ofEndShape();
    
    
    //only replace points if moving
	if(currVel > .01) {
		ofPoint tempPt;
		tempPt.x = pos.x;
		tempPt.y = pos.y;
		points.push_back(tempPt);
	//	printf ("size of vector %i \n", points.size());
		
		
		if (points.size() > 35){
			points.erase(points.begin());
		}
	}


}
Ejemplo n.º 22
0
//--------------------------------------------------------------
void rm_assembly::draw(ofColor _collider){
    
    if (currentLevel == thisLevel) {
        
        // Placeholder: draw the current level number onscreen:
        //ofDrawBitmapString(ofToString(thisLevel), ofGetWidth()/2, ofGetHeight()/2);
        
        collider = _collider;
        
        ofSetColor(collider);
        
        // Draw the boundary walls:
        ofRect(0, 0, ofGetWidth()/4, thickWall); // Top-left
        ofRect(ofGetWidth()/4+gap, 0, ofGetWidth()-(ofGetWidth()/4+gap), thickWall); // Top-right
        ofRect(0, 0, thickWall, ofGetHeight()); // Left
        ofRect(ofGetWidth()-thickWall, 0, thickWall, ofGetHeight()); // Right
        ofRect(0, ofGetHeight()-thickWall, ofGetWidth(), thickWall); // Bottom
        
        
        // Draw the room contents:
        
        
        
        // THE ARROWS:
        
        ofNoFill();
        ofSetLineWidth(1);
        ofSetColor(66,108,255);
        ofBeginShape();
        ofVertex(548,121);
        ofBezierVertex(548,139,549,157,548,174);
        ofBezierVertex(538,174,531,162,524,154);
        ofBezierVertex(533,165,552,177,563,163);
        ofEndShape();
        
        ofNoFill();
        ofSetLineWidth(1);
        ofSetColor(66,108,255);
        ofBeginShape();
        ofVertex(756,280);
        ofBezierVertex(737,282,722,287,704,291);
        ofBezierVertex(706,283,709,275,712,267);
        ofBezierVertex(712,276,703,290,714,294);
        ofEndShape();
        
        ofNoFill();
        ofSetLineWidth(1);
        ofSetColor(66,108,255);
        ofBeginShape();
        ofVertex(882,499);
        ofBezierVertex(864,499,840,485,825,475);
        ofBezierVertex(824,479,824,484,826,488);
        ofBezierVertex(829,469,834,467,854,462);
        ofEndShape();
        
        ofNoFill();
        ofSetLineWidth(1);
        ofSetColor(66,108,255);
        ofBeginShape();
        ofVertex(600,494);
        ofBezierVertex(600,480,600,464,595,452);
        ofBezierVertex(583,457,574,466,562,471);
        ofBezierVertex(579,449,594,433,620,448);
        ofEndShape();
        
        ofNoFill();
        ofSetLineWidth(1);
        ofSetColor(66,108,255);
        ofBeginShape();
        ofVertex(381,468);
        ofBezierVertex(399,468,421,450,436,440);
        ofBezierVertex(427,434,414,435,404,434);
        ofBezierVertex(430,436,429,443,429,466);
        ofEndShape();
        
        ofNoFill();
        ofSetLineWidth(1);
        ofSetColor(66,108,255);
        ofBeginShape();
        ofVertex(304,126);
        ofBezierVertex(322,133,340,140,358,147);
        ofBezierVertex(367,150,376,150,381,157);
        ofBezierVertex(372,159,362,159,352,159);
        ofBezierVertex(362,160,384,164,392,157);
        ofBezierVertex(389,150,384,145,378,139);
        ofEndShape();
        
        
        
        // THE HEXAGON:
        
        ofSetColor(collider);
        
        ofPushMatrix();
        ofTranslate(0, -25);
        
        // Top:
        ofPushMatrix();
        ofTranslate(0, -yPos);
        ofFill();
        //ofSetColor(247,165,47);
        ofBeginShape();
        ofVertex(658,186);
        ofVertex(458,186);
        ofVertex(458,164);
        ofVertex(658,164);
        ofVertex(658,186);
        ofEndShape();
        ofPopMatrix();
        
        // Top-left:
        ofPushMatrix();
        ofTranslate(-xPos, -yPos);
        ofFill();
        //ofSetColor(247,165,47);
        ofBeginShape();
        ofVertex(370,355);
        ofVertex(350,345);
        ofVertex(445,169);
        ofVertex(465,179);
        ofVertex(370,355);
        ofEndShape();
        ofPopMatrix();
        
        // Bottom-left:
        ofPushMatrix();
        ofTranslate(-xPos, yPos);
        ofFill();
        //ofSetColor(247,165,47);
        ofBeginShape();
        ofVertex(448,533);
        ofVertex(348,360);
        ofVertex(367,349);
        ofVertex(467,522);
        ofVertex(448,533);
        ofEndShape();
        ofPopMatrix();
        
        // Bottom:
        ofPushMatrix();
        ofTranslate(0, yPos);
        ofFill();
        //ofSetColor(247,165,47);
        ofBeginShape();
        ofVertex(661,533);
        ofVertex(461,533);
        ofVertex(461,511);
        ofVertex(661,511);
        ofVertex(661,533);
        ofEndShape();
        ofPopMatrix();
        
        // Bottom-right:
        ofPushMatrix();
        ofTranslate(xPos, yPos);
        ofFill();
        //ofSetColor(247,165,47);
        ofBeginShape();
        ofVertex(671,527);
        ofVertex(652,516);
        ofVertex(752,343);
        ofVertex(771,354);
        ofVertex(671,527);
        ofEndShape();
        ofPopMatrix();
        
        // Top-right:
        ofPushMatrix();
        ofTranslate(xPos, -yPos);
        ofFill();
        //ofSetColor(247,165,47);
        ofBeginShape();
        ofVertex(752,354);
        ofVertex(652,181);
        ofVertex(671,170);
        ofVertex(771,343);
        ofVertex(752,354);
        ofEndShape();
        ofPopMatrix();
        
        ofPopMatrix();
        
        ofFill();
        ofSetColor(255);
    }
    
}
Ejemplo n.º 23
0
//--------------------------------------------------------------
void rm_music::draw(ofColor _collider){
    
    if (currentLevel == thisLevel) {
        
        // Placeholder: draw the current level number onscreen:
        //ofDrawBitmapString(ofToString(thisLevel), ofGetWidth()/2, ofGetHeight()/2);
        
        collider = _collider;
        
        ofSetColor(collider);
        
        // Draw the boundary walls:
        ofRect(0, 0, ofGetWidth(), thickWall); // Top
        ofRect(0, 0, thickWall, ofGetHeight()); // Left
        
        
        // Draw the room contents:
        
        ofPushMatrix();
        
        ofTranslate(0, 10);
        
        // Bottom of gramophone:
        ofFill();
        //ofSetColor(255,255,255);
        ofBeginShape();
        ofVertex(449,449);
        ofVertex(50,449);
        ofVertex(50,388);
        ofVertex(449,388);
        ofVertex(449,449);
        ofEndShape();
        
        // Top of gramophone:
        ofFill();
        //ofSetColor(255,255,255);
        ofBeginShape();
        ofVertex(634,286);
        ofBezierVertex(617,299,560,256,507,189);
        ofBezierVertex(454,122,425,56,442,43);
        ofBezierVertex(459,29,516,72,569,140);
        ofBezierVertex(622,207,652,272,634,286);
        ofEndShape();
        
        // Left side:
        // The line generated from the original image is not sufficient to prevent movement. So we draw a rectangle and rotate it to fill in for the line:
        //ofNoFill();
        //ofSetLineWidth(5);
        //ofSetColor(0,0,0);
        /*ofBeginShape();
         ofVertex(442,43);
         ofVertex(232,354);
         ofEndShape();*/
        ofPushMatrix();
        ofTranslate(232, 354);
        ofRotate(-56);
        ofRect(0,0, ofDist(232, 354, 442, 43), 15);
        ofPopMatrix();
        
        // Right side:
        // The line generated from the original image is not sufficient to prevent movement. So we draw a rectangle and rotate it to fill in for the line:
        //ofNoFill();
        //ofSetLineWidth(5);
        //ofSetColor(0,0,0);
        /*ofBeginShape();
         ofVertex(620,288);
         ofVertex(345,363);
         ofEndShape();*/
        ofPushMatrix();
        ofTranslate(345, 363);
        ofRotate(-18);
        ofRect(0,0, ofDist(345, 363, 620, 288), 15);
        ofPopMatrix();
        
        //ofNoFill();
        ofSetLineWidth(1);
        //ofSetColor(0,0,0);
        ofBeginShape();
        ofVertex(232,354);
        ofBezierVertex(232,354,213,372,204,376);
        ofBezierVertex(195,380,158,388,158,388);
        ofEndShape();
        
        //ofNoFill();
        ofSetLineWidth(1);
        //ofSetColor(0,0,0);
        ofBeginShape();
        ofVertex(345,363);
        ofBezierVertex(345,363,333,372,346,377);
        ofBezierVertex(358,381,402,388,402,388);
        ofEndShape();
        
        ofColor buttonStatus;
        if (pressedButton) {
            buttonStatus.r = 0;
            buttonStatus.g = 0;
            buttonStatus.b = 255;
        }
        else {
            buttonStatus.r = 255;
            buttonStatus.g = 1;
            buttonStatus.b = 0;
        }
        ofFill();
        ofSetColor(buttonStatus);
        ofBeginShape();
        ofVertex(99,423);
        ofVertex(78,423);
        ofVertex(78,414);
        ofVertex(99,414);
        ofVertex(99,423);
        ofEndShape();
        
        ofPopMatrix();
        
        ofSetColor(255);
    }
    
}
//--------------------------------------------------------------
void ofApp::draw(){
    
    ofPushMatrix();
    ofRotateZ(rotation);
    ofRotate(rotation, xPos, yPos, 0);
    
    ofTranslate(xPos, yPos);
    ofRotate(rotation);
    ofScale(scaleFactor, scaleFactor);
    
    
    //petal1
    ofBeginShape();
    float x0 = 0;
    float x1 = x0 - petalWidth/2;
    float x2 = x0 - petalWidth/4;
    float x3 = x0;
    
    float y0 = 0;
    float y1 = y0 + petalLength/3;
    float y2 = y1 + petalLength/3;
    float y3 = y0 + petalLength;
    
    ofRotate(0, x0, y0, 30);
    ofVertex(x0,y0);
    ofBezierVertex(x1,y1,x2,y2,x3,y3);
    ofEndShape();
    
    ofBeginShape();
    x0 = 0;
    x1 = x0 + petalWidth/2;
    x2 = x0 + petalWidth/petalCurvature;
    x3 = x0;
    
    y0 = 0;
    y1 = y0 + petalLength/3;
    y2 = y1 + petalLength/3;
    y3 = y0 + petalLength;
    
    ofVertex(x0,y0);
    ofBezierVertex(x1,y1,x2,y2,x3,y3);
    ofEndShape();
    
    
    //stem rectangle
    ofBeginShape();
    ofRect(x0, y0 - (stemLength/2), stemWidth, stemLength);
    ofEndShape();
    
    
    
    //petal2
    ofBeginShape();
    ofRotate(70, x0, y0, 30);
    
    x0 = 0;
    x1 = x0 - petal2Width/2;
    x2 = x0 - petal2Width/4;
    x3 = 0;
    
    y0 = 0;
    y1 = y0 + petal2Length/3;
    y2 = y1 + petal2Length/3;
    y3 = y0 + petal2Length;
    
    ofVertex(x0,y0);
    ofBezierVertex(x1,y1,x2,y2,x3,y3);
    ofEndShape();
    
    ofBeginShape();
    x0 = 0;
    x1 = x0 + petal2Width/2;
    x2 = x0 + petal2Width/petalCurvature;
    x3 = 0;
    
    y0 = 0;
    y1 = y0 + petal2Length/3;
    y2 = y1 + petal2Length/3;
    y3 = y0 + petal2Length;
    
    ofVertex(x0,y0);
    ofBezierVertex(x1,y1,x2,y2,x3,y3);
    ofEndShape();
    
    
    //petal3
    ofBeginShape() ;
    ofRotate(70, x0, y0, 30);
    
    x0 = 0;
    x1 = x0 - petal3Width/2;
    x2 = x0 - petal3Width/4;
    x3 = x0;
    
    y0 = 0;
    y1 = y0 + petal3Length/3;
    y2 = y0 + petal3Length/3;
    y3 = y0 + petal3Length;
    
    ofVertex(x0, y0);
    ofBezierVertex(x1, y1, x2, y2, x3, y3);
    ofEndShape();
    
    ofBeginShape();
    x0 = 0;
    x1 = x0 + petal3Width/2;
    x2 = x0 + petal3Width/petalCurvature;
    x3 = x0;
    
    y0 = 0;
    y1 = y0 + petal3Length/3;
    y2 = y0 + petal3Length/3;
    y3 = y0 + petal3Length;
    
    ofVertex(x0, y0);
    ofBezierVertex(x1,y1,x2,y2,x3,y3);
    ofEndShape();
    
    
    //petal4
    ofBeginShape() ;
    ofRotate(80, x0, y0, 30);
    
    x0 = 0;
    x1 = x0 - petalWidth/2;
    x2 = x0 - petalWidth/4;
    x3 = x0;
    
    y0 = 0;
    y1 = y0 + petalLength/3;
    y2 = y0 + petalLength/3;
    y3 = y0 + petalLength;
    
    ofVertex(x0, y0);
    ofBezierVertex(x1, y1, x2, y2, x3, y3);
    ofEndShape();
    
    ofBeginShape();
    x0 = 0;
    x1 = x0 + petalWidth/2;
    x2 = x0 + petalWidth/petalCurvature;
    x3 = x0;
    
    y0 = 0;
    y1 = y0 + petalLength/3;
    y2 = y0 + petalLength/3;
    y3 = y0 + petalLength;
    
    ofVertex(x0, y0);
    ofBezierVertex(x1,y1,x2,y2,x3,y3);
    ofEndShape();
    
    //petal5
    ofBeginShape() ;
    ofRotate(70, x0, y0, 20);
    
    x0 = 0;
    x1 = x0 - petal4Width/2;
    x2 = x0 - petal4Width/4;
    x3 = x0;
    
    y0 = 0;
    y1 = y0 + petal4Length/3;
    y2 = y0 + petal4Length/3;
    y3 = y0 + petal4Length;
    
    ofVertex(x0, y0);
    ofBezierVertex(x1, y1, x2, y2, x3, y3);
    ofEndShape();
    
    ofBeginShape();
    x0 = 0;
    x1 = x0 + petal4Width/2;
    x2 = x0 + petal4Width/petalCurvature;
    x3 = x0;
    
    y0 = 0;
    y1 = y0 + petal4Length/3;
    y2 = y0 + petal4Length/3;
    y3 = y0 + petal4Length;
    
    ofVertex(x0, y0);
    ofBezierVertex(x1,y1,x2,y2,x3,y3);
    ofEndShape();
    
    
    ofPopMatrix();
    
}
//--------------------------------------------------------------
void Leaf::draw(){
    
    // DRAW LEAF / STEM / FRUIT
    
    ofPushMatrix();
    
    ofTranslate(xPos, yPos);    // Set Center Point to xPos and yPos.
    //------0. Do Rotation and Scale------//
    ofRotateZ(rotation);
    ofScale(scaleFactor, scaleFactor);
    
    
    //------1. Draw Left Leaf------//
    ofBeginShape();
    ofSetColor(leafColorLeft);  // Set Color Green to Leaf.
    
    
    // Set x Values of Bezier
    float x0 = 0;
    float x1 = x0-leafWidth/2;
    float x2 = x0-leafWidth/4;
    float x3 = x0;

    // Set y Values of Bezier
    float y0 = (2*stemHeight)/3;
    float y1 = y0+leafHeight/3;
    float y2 = y0+(2*leafHeight)/3;
    float y3 = y0+leafHeight;
    
    ofVertex(x0, y0);
    ofBezierVertex(x1, y1, x2, y2, x3, y3);
    
    ofEndShape();
    
    
    //-----2. Draw Right Leaf-----//
    ofBeginShape();
    ofSetColor(leafColorRight);
    
    // Set x Values of Bezier
    x0 = 0;
    x1 = x0+leafWidth/2;
    x2 = x0+leafWidth/4;
    x3 = x0;
    
    // Set y Values of Bezier
    y0 = (2*stemHeight)/3;
    y1 = y0+leafHeight/3;
    y2 = y0+(2*leafHeight)/3;
    y3 = y0+leafHeight;
    
    ofVertex(x0, y0);
    ofBezierVertex(x1, y1, x2, y2, x3, y3);
    
    ofEndShape();
    
    
    //-----3. Draw Stem Body-----//
    ofSetColor(stemColor);  //Set Color Brown to Stem.
    ofRect(0, 0+stemHeight/2, stemWidth, stemHeight);
    
    
    //-----4. Draw Stem Head-----//
    ofTriangle(0-stemWidth/2, 0+stemHeight, 0+stemWidth/2, 0+stemHeight, 0, 0+stemHeight+leafHeight/3);
    
    
    //-----5. Draw Fruits No.01-----//
    ofSetColor(fruitColorOne);
    ofCircle(fruitXPosOne, fruitYPosOne, fruitRadiusOne);
    
    
    //-----6. Draw Fruits No.02-----//
    ofSetColor(fruitColorTwo);
    ofCircle(fruitXPosTwo, fruitYPosTwo, fruitRadiusTwo);
    
    //-----7. Draw Root
    ofSetColor(stemColor);
    ofCircle(0, 0, stemWidth/2);
    
    ofPopMatrix();
    
}
Ejemplo n.º 26
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();
*/
    
    
}
Ejemplo n.º 27
0
//--------------------------------------------------------------
void Leaf::draw(){
    //DRAW STUFF
//    ofRect(xPos, yPos, 20, 40);
    
    //Draw leave
    
    //draw leaf left
    
    ofPushMatrix();
        ofTranslate(xPos, yPos);
        ofRotateZ(rotation);
        ofScale(scaleFactor, scaleFactor);
    
        ofSetColor(leafColor);
        ofBeginShape();
        
            float x0 = 0;
            float x1 = x0 - leafWidth/2;
            float x2 = x0 - leafWidth/4;
            float x3 = 0;
        
            float y0 = 0 + stemLength;
            float y1 = y0 + leafLength/3;
            float y2 = y1 + leafLength/3;
            float y3 = y0 + leafLength;
        
            ofVertex(x0,y0);
            ofBezierVertex(x1,y1,x2,y2,x3,y3);
        
        ofEndShape();

        //draw leaf right
        ofBeginShape();
        
            x0 = 0;
            x1 = x0 + leafWidth/2;
            x2 = x0 + leafWidth/4;
            x3 = 0;
            
            y0 = 0 + stemLength;
            y1 = y0 + leafLength/3;
            y2 = y1 + leafLength/3;
            y3 = y0 + leafLength;
            
            ofVertex(x0,y0);
            ofBezierVertex(x1,y1,x2,y2,x3,y3);
        
        ofEndShape();
        
        //draw stem
        ofSetColor(stemColor);
        ofRect(0, 0 + stemLength/2, stemWidth, stemLength);
        
        //triangular stem through leaf
        ofTriangle(0 - stemWidth/2, 0 + stemLength, 0 + stemWidth/2, 0 + stemLength, 0, 0 + stemLength + 2*(leafLength/3));
    
    
    ofPopMatrix();
    
    
    
    
}
//--------------------------------------------------------------
void ofApp::draw(){

    ofBackground(235, 180, 68);
    ofSetColor(255);
    background.draw(-165, -8);
    ofSetColor(255);
    orangeBackground.draw(273,221);
    
 
   
    for(int i=0; i<numLines; i++){
        lines[i].draw();
    }
    for(int i=0; i<numLittleSquares; i++){
        dressSquares[i].draw();
    }
    //image of green circle on dress
    ofSetColor(255);
    ofEnableAlphaBlending();
    greenCircle.draw(376.496,333);

    for(int i=0; i<numSmallCircles; i++){
        smallCircles[i].draw();
    }
    for(int i=0; i<numBigCirclesDress; i++){
        //check to see if they have overlapped
        bigCircles[i].draw();
    }
        ofBeginShape();
        ofVertex(132,213);
        ofBezierVertex(132,213,137,172,137,163);
        ofBezierVertex(136,154,124,87,133,73);
        ofBezierVertex(142,58,159,27,166,26);
        ofBezierVertex(174,24,180,22,183,20);
        ofBezierVertex(186,18,189,15,212,9);
        ofBezierVertex(236,3,261,-2,267,-3);
        ofBezierVertex(273,-3,294,-9,303,-9);
        ofBezierVertex(312,-9,364,-9,388,-8);
        ofBezierVertex(413,-7,450,0,462,5);
        ofBezierVertex(474,9,506,31,515,45);
        ofBezierVertex(524,58,534,67,536,75);
        ofBezierVertex(538,83,541,90,545,96);
        ofBezierVertex(549,102,555,133,555,133);
        ofBezierVertex(555,133,555,159,554,163);
        ofBezierVertex(554,167,544,195,540,207);
        ofBezierVertex(536,219,531,239,532,245);
        ofBezierVertex(534,251,543,295,550,311);
        ofBezierVertex(558,327,572,369,576,373);
        ofBezierVertex(580,378,582,397,584,401);
        ofBezierVertex(585,406,594,451,594,457);
        ofBezierVertex(594,464,592,488,592,495);
        ofBezierVertex(593,501,597,527,603,537);
        ofBezierVertex(609,546,616,564,616,568);
        ofBezierVertex(616,572,613,583,622,593);
        ofBezierVertex(632,602,624,615,624,619);
        ofBezierVertex(625,623,631,635,629,641);
        ofBezierVertex(627,648,618,662,618,668);
        ofBezierVertex(618,674,625,692,632,700);
        ofBezierVertex(638,708,637,739,637,739);
        ofBezierVertex(637,739,610,738,585,752);
        ofBezierVertex(559,765,531,789,516,794);
        ofBezierVertex(501,798,490,792,486,798);
        ofBezierVertex(481,804,462,824,451,830);
        ofBezierVertex(441,836,361,858,352,855);
        ofBezierVertex(343,852,321,860,306,861);
        ofBezierVertex(291,863,264,870,250,863);
        ofBezierVertex(237,855,229,849,220,849);
        ofBezierVertex(211,849,190,849,183,840);
        ofBezierVertex(175,831,168,797,166,788);
        ofBezierVertex(165,779,145,734,145,720);
        ofBezierVertex(145,707,138,687,138,677);
        ofBezierVertex(138,666,133,659,133,648);
        ofBezierVertex(133,638,130,620,130,620);
        ofBezierVertex(130,620,131,599,131,594);
        ofBezierVertex(130,589,126,571,126,565);
        ofBezierVertex(126,560,127,544,127,544);
        ofBezierVertex(127,544,123,528,123,523);
        ofBezierVertex(123,517,125,481,125,470);
        ofBezierVertex(125,459,118,406,119,386);
        ofBezierVertex(121,365,127,246,127,238);
        ofBezierVertex(128,230,132,213,132,213);

        
        ofNextContour(true);
        //beginning point
        ofFill();
   
        ofVertex(471,309);
        ofBezierVertex(471,309,435,309,412,309);
        ofBezierVertex(389,309,334,298,334,298);
        ofBezierVertex(334,298,328,314,325,330);
        ofBezierVertex(322,346,333,372,333,387);
        ofBezierVertex(333,402,331,416,331,426);
        ofBezierVertex(331,436,350,493,358,510);
        ofBezierVertex(366,527,381,560,385,568);
        ofBezierVertex(389,576,381,613,381,627);
        ofBezierVertex(381,641,398,662,400,675);
        ofBezierVertex(402,688,386,739,382,753);
        ofBezierVertex(378,767,380,798,380,798);
        ofVertex(472,796);
        ofBezierVertex(472,796,472,752,473,740);
        ofBezierVertex(474,728,460,681,455,673);
        ofBezierVertex(450,665,446,652,446,644);
        ofBezierVertex(446,636,464,598,466,587);
        ofBezierVertex(468,576,463,548,459,536);
        ofBezierVertex(455,524,448,496,450,487);
        ofBezierVertex(452,478,472,382,475,366);
        ofBezierVertex(478,350,475,309,475,309);
        ofVertex(471,309);
        ofEndShape();

      
    //image of arm
    ofSetColor(255);
    ofEnableAlphaBlending();
    arm.draw(329, 274);
    //image of under spirals
    ofSetColor(255);
    ofEnableAlphaBlending();
    spiralBackground.draw(424,203,291, 820);
    
    //heads image
    ofSetColor(255);
    heads.draw(210,-5);
    
    //spiral
    for(int i=0; i<numSpirals; i++){
        spirals[i].draw();
    }
    
//    ofPushMatrix();
//    ofTranslate(100,300,0);
//    ofSetHexColor(0xff2220);
//    ofFill();
//    ofSetPolyMode(OF_POLY_WINDING_ODD);
//    ofBeginShape();
//    float angleStep 	= TWO_PI/(100.0f + sin(ofGetElapsedTimef()/5.0f) * 60);
//    float radiusAdder 	= 0.5f;
//    float radius 		= 0;
//    for (int i = 0; i < 200; i++){
//        float anglef = (i) * angleStep;
//        float x = radius * cos(anglef);
//        float y = radius * sin(anglef);
//        ofVertex(x,y);
//        radius 	+= radiusAdder;
//    }
//    ofEndShape();
//    ofPopMatrix();
 
// guy image
    ofSetColor(255);
    ofEnableAlphaBlending();
    man.draw(-165, -8);
    
   
    
    
}