コード例 #1
0
//-----------------------------------------------------------
void ofTrueTypeFont::drawCharAsShape(int c, float x, float y) {


	//----------------------- error checking
	if (!bLoadedOk){
		ofLog(OF_LOG_ERROR,"Error : font not allocated -- line %d in %s", __LINE__,__FILE__);
		return;
	}

	//----------------------- error checking
	if (!bMakeContours){
		ofLog(OF_LOG_ERROR,"Error : contours not created for this font - call loadFont with makeContours set to true");
		return;
	}

	if (c >= nCharacters){
		//ofLog(OF_LOG_ERROR,"Error : char (%i) not allocated -- line %d in %s", (c + NUM_CHARACTER_TO_START), __LINE__,__FILE__);
		return;
	}
	//-----------------------

	int cu = c;
	ofTTFCharacter & charRef = charOutlines[cu];

	ofBeginShape();
		for(int k = 0; k < (int)charRef.contours.size(); k++){
			if( k!= 0)ofNextContour(true);
			for(int i = 0; i < (int)charRef.contours[k].pts.size(); i++){
				ofVertex(charRef.contours[k].pts[i].x + x, charRef.contours[k].pts[i].y + y);
			}
		}
	ofEndShape( true );

}
コード例 #2
0
ファイル: testApp.cpp プロジェクト: DHaylock/ofxDxfExport
//--------------------------------------------------------------
void testApp::keyPressed(int key)
{
    
    if(key == OF_KEY_DEL || key == OF_KEY_BACKSPACE){
		words = words.substr(0, words.length()-1);
	}
	else if(key == OF_KEY_RETURN ){

        dxf.writeFile(ofToString(ofGetTimestampString()));
        if (stringPts.size() > 0)
        {
            for (int p = 0; p < stringPts.size(); p++) {
                if (p <= stringPts.size()) {
                    dxf.addPoints(stringPts[p].pts, false);
                }
                else
                {
                    dxf.addPoints(stringPts.back().pts, true);
                }
            }
            
        }
        dxf.endFile();
	}
    else if (key == '=')
    {
        chars = text.getStringAsPoints(words);
        
        if (chars.size() > 0)
        {
            for (int p = 0; p < chars.size(); p++) {
                charSet s;
                for(int k = 0; k <(int)chars[p].getOutline().size(); k++){
                    if( k!= 0)ofNextContour(true);
                    for(int i = 0; i < (int)chars[p].getOutline()[k].size(); i++){
                        s.pts.push_back(ofVec3f(chars[p].getOutline()[k].getVertices()[i].x, chars[p].getOutline()[k].getVertices()[i].y,0));
                    }
                    stringPts.push_back(s);
                }
            }
        }
        cout << stringPts.size() << endl;
    }
    else if(key == ']')
    {
        stringPts.clear();
        chars.clear();
        words.clear();
    }
    else{
		if( bFirst ){
			words.clear();
			bFirst = false;
		}
		words.append(1, (char)key);
	}
    
}
コード例 #3
0
//-----------------------------------------------------
void imageProjection::drawProjectionMask(float x, float y, float w, float h){
	
	ofPoint2f *pts = QUAD.getScaledQuadPoints(w, h);
	
	//we do a mask around the quad
	ofSetColor(0x000000);
	ofBeginShape();
		ofVertex(x, y);
		ofVertex(x + w, y);
		ofVertex(x + w, y+h);
		ofVertex(x , y+h);

		ofNextContour(true);
		ofVertex(x + pts[0].x, y + pts[0].y);
		ofVertex(x + pts[1].x, y + pts[1].y);
		ofVertex(x + pts[2].x, y + pts[2].y);
		ofVertex(x + pts[3].x, y + pts[3].y);
	ofEndShape();
}
コード例 #4
0
void ofDrawRectOutline(const ofRectangle & rect, int thickness, ofDrawRectOutlineMode mode) {
    
    float b0, b1;
    if(mode == ofDrawRectOutlineModeOuter) {
        b0 = thickness;
        b1 = 0;
    } else if(mode == ofDrawRectOutlineModeInner) {
        b0 = 0;
        b1 = thickness;
    } else if(mode == ofDrawRectOutlineModeMiddle) {
        b0 = thickness * 0.5;
        b1 = thickness * 0.5;
    }
    
    ofVec2f po0(rect.x - b0, rect.y - b0);
    ofVec2f po1(rect.x + rect.width + b0, rect.y - b0);
    ofVec2f po2(rect.x + rect.width + b0, rect.y + rect.height + b0);
    ofVec2f po3(rect.x - b0, rect.y + rect.height + b0);
    
    ofVec2f pi0(rect.x + b1, rect.y + b1);
    ofVec2f pi1(rect.x + rect.width - b1, rect.y + b1);
    ofVec2f pi2(rect.x + rect.width - b1, rect.y + rect.height - b1);
    ofVec2f pi3(rect.x + b1, rect.y + rect.height - b1);
    
    ofBeginShape();

    ofVertex(po0.x, po0.y);
    ofVertex(po1.x, po1.y);
    ofVertex(po2.x, po2.y);
    ofVertex(po3.x, po3.y);
    
    ofNextContour();
    
    ofVertex(pi0.x, pi0.y);
    ofVertex(pi1.x, pi1.y);
    ofVertex(pi2.x, pi2.y);
    ofVertex(pi3.x, pi3.y);
    
    ofEndShape(true);
}
コード例 #5
0
ファイル: ofxFreeType2.cpp プロジェクト: jellevdster/FALv07
//-----------------------------------------------------------
void ofxFreeType2::drawCharAsShape(int c) {
	//Make sure we're not out of bounds wtih loaded characters
	if (c >= nChars){
		ofLog(OF_LOG_ERROR,"Error : char (%i) not allocated -- line %d in %s", (c - START_CHAR), __LINE__,__FILE__);
		return;
	}
	
	ofTTCharacter & charRef = charOutlines[c];
	
	glPushMatrix();
	//glTranslatef(0, -chars[c].top, 0);
	
	ofBeginShape();
	for(int k = 0; k < (int)charRef.contours.size(); k++){
		if( k!= 0)ofNextContour(true);
		for(int i = 0; i < (int)charRef.contours[k].pts.size(); i++){
			ofVertex(charRef.contours[k].pts[i].x, charRef.contours[k].pts[i].y);
		}
	}
	ofEndShape( true );
	glPopMatrix();
}
コード例 #6
0
ファイル: testApp.cpp プロジェクト: DHaylock/ofxDxfExport
//--------------------------------------------------------------
void testApp::setup()
{
    text.loadFont("MarkerFelt.ttc", 100,true,true,true); // You can change the font and size simply drag and drop the font into the data folder and Replace the MarkerFelt.ttc
    words = "Hello World";
    showPtsline = false;
    bFirst = true;
    chars = text.getStringAsPoints(words);
    
    if (chars.size() > 0)
    {
        for (int p = 0; p < chars.size(); p++) {
            charSet s;
            for(int k = 0; k <(int)chars[p].getOutline().size(); k++){
                if( k!= 0)ofNextContour(true);
                for(int i = 0; i < (int)chars[p].getOutline()[k].size(); i++){
                    s.pts.push_back(ofVec3f(chars[p].getOutline()[k].getVertices()[i].x, chars[p].getOutline()[k].getVertices()[i].y,0));
                }
                stringPts.push_back(s);
            }
        }
    }
    cout << stringPts.size() << endl;
}
コード例 #7
0
//--------------------------------------------------------------
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);
	
}
コード例 #8
0
ファイル: testApp.cpp プロジェクト: DHaylock/ofxDxfExport
//--------------------------------------------------------------
void testApp::draw()
{
    ofBackground(100, 100, 100);
    // Plain Text Output
    ofSetColor(255, 255, 255);
    ofDrawBitmapStringHighlight("Plain Draw String", 60,30);
    text.drawString(words, 50,150);
    
    // Contours String Points
    ofNoFill();
	ofPushMatrix();
    ofTranslate(60, 300, 0);
    ofDrawBitmapStringHighlight("Contours Draw String", 0,-120);
    ofBeginShape();
    if (chars.size() > 0)
    {
        for (int p = 0; p < chars.size(); p++) {
            for(int k = 0; k <(int)chars[p].getOutline().size(); k++){
                if( k!= 0)ofNextContour(true) ;
                for(int i = 0; i < (int)chars[p].getOutline()[k].size(); i++){
                    ofVertex(chars[p].getOutline()[k].getVertices()[i].x, chars[p].getOutline()[k].getVertices()[i].y);
                }
            }
            ofEndShape(true);
        }
    }
    ofPopMatrix();
    
    // Points Output
    ofNoFill();
	ofPushMatrix();
    ofScale(1,1);
    ofTranslate(60, 450, 0);
    ofDrawBitmapStringHighlight("Pts Draw String", 0,-120);
    ofBeginShape();
    if (chars.size() > 0)
    {
        for (int p = 0; p < chars.size(); p++) {
            for(int k = 0; k <(int)chars[p].getOutline().size(); k++){
                if( k!= 0)ofNextContour(true) ;
                
                if (showPtsline == true) {
                    for(int i = 0; i < (int)chars[p].getOutline()[k].size(); i++){
                        ofVertex(chars[p].getOutline()[k].getVertices()[i].x, chars[p].getOutline()[k].getVertices()[i].y);
                    }
                }
                else
                {
                    //Don't Draw Lines
                }
                
                for(int i = 0; i < (int)chars[p].getOutline()[k].size(); i+=7){
                    ofPushStyle();
                    ofFill();
                    ofSetColor(ofColor::red);
                    ofCircle(chars[p].getOutline()[k].getVertices()[i].x, chars[p].getOutline()[k].getVertices()[i].y, 2);
                    ofPopStyle();
                }
            }
            ofEndShape(true);
        }
    }
    ofPopMatrix();
    
    
    // Dxf Points Output
    ofNoFill();
	ofPushMatrix();
    ofTranslate(60,600);
    ofDrawBitmapStringHighlight("DXF Output", 0,-120);
    ofSetColor(255, 0, 0);
    ofBeginShape();
    if (stringPts.size() > 0)
    {
        for (int p = 0; p < stringPts.size(); p++) {
            for(int k = 0; k <(int)stringPts[p].pts.size(); k++){
                ofVertex(stringPts[p].pts[k].x, stringPts[p].pts[k].y);
            }
            ofEndShape(true);
        }
    }
    ofPopMatrix();
    
    stringstream info;
    info << "Press 'ENTER' to Save File" << endl;
    info << "Press '=' to push the new string" << endl;
    info << "Press ']' to clear the points" << endl;
    info << "Number of Characters: " << chars.size() << endl;
    
    ofDrawBitmapStringHighlight(info.str(), 0,ofGetHeight()-60);

}
コード例 #9
0
ファイル: Wish.cpp プロジェクト: thiagohersan/NotTooPublic
void Wish::update(){
    NotTooPublic::update();

    if(currentState == STATE_INTRO){
        stateLogicIntro();
    }
    else if(currentState == STATE_BLANK){
        stateLogicBlank();
    }
    else if(currentState == STATE_SPERM) {
        if(currentDistance <= 0.0){
            currentDistance = 0;
            lastStateChangeMillis = nowMillis;
            currentState = STATE_PAUSE;
        }
        else{
            currentDistance -= 1.0;
        }
    }
    else if(currentState == STATE_PAUSE) {
        if(nowMillis - lastStateChangeMillis > 2000){
            currentDistance = 0;
            lastStateChangeMillis = nowMillis;
            currentState = STATE_LINES;
        }
        else{
            //
        }
    }
    else if(currentState == STATE_LINES) {
        if(currentDistance > originalDistance){
            currentDistance = 0;
            lastStateChangeMillis = nowMillis;
            currentState = STATE_CLEAR;
        }
        else{
            currentDistance += 4.0f;
        }
    }
    else if(currentState == STATE_CLEAR) {
        if(currentDistance > originalDistance){
            currentDistance = originalDistance;
            lastStateChangeMillis = nowMillis;
            currentState = STATE_BLANK;
        }
        else{
            currentDistance += 4.0f;
        }
    }
    else if(currentState == STATE_OUTRO){
        stateLogicOutro();
    }

    ///// actual drawings
    if(currentState == STATE_INTRO){
        drawIntro();
    }

    if(currentState == STATE_OUTRO){
        drawCredits();
    }

    if(currentState == STATE_SPERM){
        fboCanvas.begin();
        ofEnableAlphaBlending();
        ofFill();
        // SPERM: ofSetColor(0, 24);
        ofSetColor(0, 64);
        ofRect(0,0, fboCanvas.getWidth(), fboCanvas.getHeight());
        ofPushMatrix();
        ofScale(currentMessageScaling, currentMessageScaling);
        ofTranslate((fboCanvas.getWidth()/currentMessageScaling-myFont.stringWidth(currentMessage))/2,
                    (fboCanvas.getHeight()/currentMessageScaling-myFont.stringHeight(currentMessage))/2+myFont.stringHeight("Tell"));

        ofFill();
        for(int i=0; i<currentMessagePath.size(); i++){
            ofVec3f center = currentMessagePath.at(i).getTessellation().getCentroid();
            for(int j=0; j<currentMessagePath.at(i).getOutline().size(); j++){
                for(int k=0; k<currentMessagePath.at(i).getOutline().at(j).size(); k++){
                    ofPoint tp = currentMessagePath.at(i).getOutline().at(j).getVertices().at(k);
                    ofVec3f direction = (tp-center).normalize();
                    tp += direction*max(0.0f,currentDistance);
                    if(!(k%(int)ceil(currentMessagePoints/1000.0f))){
                        // SPERM: int complexity = 24;
                        int complexity = 4;
                        float magnitude = 8.0f;
                        float dx = ofNoise(complexity*tp.x/fboCanvas.getWidth()+PI,
                                           complexity*tp.y/fboCanvas.getHeight()+PI,
                                           (float)(ofGetFrameNum())/120.0f+PI);
                        float dy = ofNoise(complexity*tp.x/fboCanvas.getWidth()-PI,
                                           complexity*tp.y/fboCanvas.getHeight()-PI,
                                           (float)(ofGetFrameNum())/130.0f-PI);
                        float a = magnitude*ofNoise(dy,dx,(float)(ofGetFrameNum())/100.0f);
                        ofSetColor(255);
                        ofCircle(tp.x-a+2*a*dx, tp.y-a+2*a*dy, 1.0);
                    }
                }
            }
        }
        ofPopMatrix();
        ofDisableAlphaBlending();
        fboCanvas.end();
    }

    if(currentState == STATE_PAUSE){
        fboCanvas.begin();
        ofEnableAlphaBlending();
        ofPushMatrix();
        ofScale(currentMessageScaling, currentMessageScaling);
        ofTranslate((fboCanvas.getWidth()/currentMessageScaling-myFont.stringWidth(currentMessage))/2,
                    (fboCanvas.getHeight()/currentMessageScaling-myFont.stringHeight(currentMessage))/2+myFont.stringHeight("Tell"));

        ofFill();
        ofSetColor(0,8);
        myFont.drawString(currentMessage, 0, 0);

        ofNoFill();
        ofSetColor(255,8);
        ofSetLineWidth(2);
        for(int i=0; i<currentMessagePath.size(); i++){
            ofBeginShape();
            ofVec3f center = currentMessagePath.at(i).getTessellation().getCentroid();
            for(int j=0; j<currentMessagePath.at(i).getOutline().size(); j++){
                ofNextContour();
                for(int k=0; k<currentMessagePath.at(i).getOutline().at(j).size(); k++){
                    ofPoint tp = currentMessagePath.at(i).getOutline().at(j).getVertices().at(k);
                    ofVertex(tp.x, tp.y);
                }
            }
            ofEndShape(true);
        }
        ofPopMatrix();
        ofDisableAlphaBlending();
        fboCanvas.end();
    }

    if(currentState == STATE_LINES){
        fboCanvas.begin();
        ofEnableAlphaBlending();
        ofFill();
        ofSetColor(0, 32);
        ofRect(0,0, fboCanvas.getWidth(), fboCanvas.getHeight());
        ofPushMatrix();
        ofScale(currentMessageScaling, currentMessageScaling);
        ofTranslate((fboCanvas.getWidth()/currentMessageScaling-myFont.stringWidth(currentMessage))/2,
                    (fboCanvas.getHeight()/currentMessageScaling-myFont.stringHeight(currentMessage))/2+myFont.stringHeight("Tell"));

        ofNoFill();
        ofSetLineWidth(1.5);
        for(int i=0; i<currentMessagePath.size(); i++){
            ofVec3f center = currentMessagePath.at(i).getTessellation().getCentroid();
            for(int j=0; j<currentMessagePath.at(i).getOutline().size(); j++){
                for(int k=0; k<currentMessagePath.at(i).getOutline().at(j).size(); k++){
                    ofPoint tp = currentMessagePath.at(i).getOutline().at(j).getVertices().at(k);
                    ofVec3f direction = (tp-center).normalize();
                    tp += direction*max(0.0f,currentDistance);
                    if(!(k%(int)ceil(currentMessagePoints/1000.0f))){
                        ofSetColor(255,128);
                        ofLine(center, tp);
                    }
                }
            }
        }
        ofSetColor(0);
        myFont.drawString(currentMessage, 0, 0);
        ofPopMatrix();
        ofDisableAlphaBlending();
        fboCanvas.end();
    }

    if(currentState == STATE_CLEAR){
        fboCanvas.begin();
        ofEnableAlphaBlending();
        ofFill();
        ofSetColor(0, 32);
        ofRect(0,0, fboCanvas.getWidth(), fboCanvas.getHeight());
        ofPushMatrix();
        ofScale(currentMessageScaling, currentMessageScaling);
        ofTranslate((fboCanvas.getWidth()/currentMessageScaling-myFont.stringWidth(currentMessage))/2,
                    (fboCanvas.getHeight()/currentMessageScaling-myFont.stringHeight(currentMessage))/2+myFont.stringHeight("Tell"));

        ofNoFill();
        ofSetLineWidth(1.5);
        for(int i=0; i<currentMessagePath.size(); i++){
            ofVec3f center = currentMessagePath.at(i).getTessellation().getCentroid();
            for(int j=0; j<currentMessagePath.at(i).getOutline().size(); j++){
                for(int k=0; k<currentMessagePath.at(i).getOutline().at(j).size(); k++){
                    ofPoint tp = currentMessagePath.at(i).getOutline().at(j).getVertices().at(k);
                    ofVec3f direction = (tp-center).normalize();
                    tp += direction*max(0.0f,currentDistance);
                    ofPoint maxDistance = tp+direction*originalDistance;
                    if(!(k%(int)ceil(currentMessagePoints/1000.0f))){
                        ofSetColor(255,128);
                        ofLine(maxDistance, tp);
                    }
                }
            }
        }
        ofSetColor(0);
        myFont.drawString(currentMessage, 0, 0);
        ofPopMatrix();
        ofDisableAlphaBlending();
        fboCanvas.end();
    }
}
コード例 #10
0
//--------------------------------------------------------------
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);
    
   
    
    
}