void ofxTLKeyframer::draw() {

    if(bounds.width == 0 || bounds.height == 0) {
        ofLog(OF_LOG_ERROR, "ofxTLKeyframer --- Error condition, invalid bounds " + ofToString(bounds.width) + " " + ofToString(bounds.height) );
        return;
    }

    ofPushStyle();
    ofPushMatrix();
    ofEnableSmoothing();

    //**** DRAW BORDER
    ofNoFill();
    if(hover) {
        ofSetColor(9,147,211);
    }
    else if(focused) {
        ofSetColor(9,147,211);
    }
    else {
        ofSetColor(timeline->getColors().outlineColor);
    }
    ofRect(bounds.x+4, bounds.y, bounds.width, bounds.height);


    //**** DRAW KEYFRAME LINES
    ofSetColor(9,147,211);
    ofSetLineWidth(2);
    ofNoFill();
    ofBeginShape();
    if(keyframes.size() == 0 || keyframes.size() == 1) {
        ofVertex(bounds.x, bounds.y + bounds.height - sampleAt(.5)*bounds.height);
        ofVertex(bounds.x+bounds.width, bounds.y + bounds.height - sampleAt(.5)*bounds.height);
    }
    else {
        for(int p = 4; p <= bounds.width; p++) {
            ofVertex(bounds.x + p,  bounds.y + bounds.height - sampleAt(ofMap(p, 0, bounds.width, zoomBounds.min, zoomBounds.max, true)) * bounds.height);
        }
    }
    ofEndShape(false);

    ofSetLineWidth(1);

    //**** DRAW KEYFRAME DOTS
    ofSetColor(timeline->getColors().textColor);
    for(int i = 0; i < keyframes.size(); i++) {
        if(!keyframeIsInBounds(keyframes[i])) {
            continue;
        }

        ofSetColor(timeline->getColors().textColor);
        ofVec2f screenpoint = coordForKeyframePoint(keyframes[i]->position);
        if(keyframes[i] == selectedKeyframe) {
            float keysValue = ofMap(selectedKeyframe->position.y, 0, 1.0, valueRange.min, valueRange.max, true);
            string frameString = timeline->getIsFrameBased() ?
                                 ofToString(int(selectedKeyframe->position.x*timeline->getDurationInFrames())) :
                                 ofToString(selectedKeyframe->position.y*timeline->getDurationInSeconds());
            //ofDrawBitmapString(frameString+"|"+ofToString(keysValue, 2), screenpoint.x+5, screenpoint.y+10);
            keyFramesFont.drawString(frameString+" | "+ofToString(keysValue, 2), screenpoint.x+5, screenpoint.y+10);
            ofFill();
        }
        else {
            ofNoFill();
        }

        if(keyframes[i] == hoverKeyframe) {
            ofPushStyle();
            ofFill();
            ofSetColor(9,147,211);
            ofCircle(screenpoint.x, screenpoint.y, 8);
            ofPopStyle();
        }

        ofCircle(screenpoint.x, screenpoint.y, 4);
    }

    //****** DRAW EASING CONTROLS
    if(drawingEasingWindow) {
        for(int i = 0; i < easingFunctions.size(); i++) {
            if(easingFunctions[i] == selectedKeyframe->easeFunc) {
                ofSetColor(9,147,211);
            }
            else {
                ofSetColor(80, 80, 80);
            }
            ofFill();
            ofRect(easingWindowPosition.x + easingFunctions[i]->bounds.x, easingWindowPosition.y +easingFunctions[i]->bounds.y,
                   easingFunctions[i]->bounds.width, easingFunctions[i]->bounds.height);
            ofSetColor(230, 230, 230);
            //ofDrawBitmapString(easingFunctions[i]->name, easingWindowPosition.x + easingFunctions[i]->bounds.x+10, easingWindowPosition.y + easingFunctions[i]->bounds.y+15);
            keyFramesFont.drawString(easingFunctions[i]->name, easingWindowPosition.x + easingFunctions[i]->bounds.x+10, easingWindowPosition.y + easingFunctions[i]->bounds.y+15);

            ofNoFill();
            ofSetColor(40, 40, 40);
            ofRect(easingWindowPosition.x + easingFunctions[i]->bounds.x, easingWindowPosition.y +easingFunctions[i]->bounds.y,
                   easingFunctions[i]->bounds.width, easingFunctions[i]->bounds.height);

        }

        for(int i = 0; i < easingTypes.size(); i++) {
            if(easingTypes[i] == selectedKeyframe->easeType) {
                ofSetColor(9,147,211);
            }
            else {
                ofSetColor(80, 80, 80);
            }
            ofFill();
            ofRect(easingWindowPosition.x + easingTypes[i]->bounds.x, easingWindowPosition.y + easingTypes[i]->bounds.y,
                   easingTypes[i]->bounds.width, easingTypes[i]->bounds.height);
            ofSetColor(200, 200, 200);
            //ofDrawBitmapString(easingTypes[i]->name, easingWindowPosition.x + easingTypes[i]->bounds.x+10, easingWindowPosition.y + easingTypes[i]->bounds.y+15);
            keyFramesFont.drawString(easingTypes[i]->name, easingWindowPosition.x + easingTypes[i]->bounds.x+10, easingWindowPosition.y + easingTypes[i]->bounds.y+15);
            ofNoFill();
            ofSetColor(40, 40, 40);
            ofRect(easingWindowPosition.x + easingTypes[i]->bounds.x,
                   easingWindowPosition.y + easingTypes[i]->bounds.y,
                   easingTypes[i]->bounds.width, easingTypes[i]->bounds.height);
        }
    }

    ofPopMatrix();
    ofPopStyle();
}
示例#2
0
void ofxTLTicker::draw(){
	
	ofPushStyle();
	
	int textH, textW;
	string text;

    //draw tickers with time
    float startTime = zoomBounds.min * timeline->getDurationInSeconds();
    float endTime = zoomBounds.max * timeline->getDurationInSeconds();
    float durationInview = endTime-startTime;
    float secondsPerPixel = durationInview / bounds.width;
    
	if(viewIsDirty){
		refreshTickMarks();
	}
	
	tickerMarks.setStrokeColor( ofColor(200, 180, 40) );
	tickerMarks.setStrokeWidth(1);
	tickerMarks.draw(0, bounds.y);
		
    if(drawBPMGrid){
		if(viewIsDirty){
	        updateBPMPoints();
		}
        ofPushStyle();
        ofSetColor(255, 255, 255, 50);
        for(int i = 0; i < bpmScreenPoints.size(); i++){
            ofSetLineWidth(bpmScreenPoints[i].weight);
            ofLine(bpmScreenPoints[i].screenX, getBottomEdge(), bpmScreenPoints[i].screenX, totalDrawRect.y+totalDrawRect.height);
        }
        ofPopStyle();
    }

	textH = timeline->getFont().getLineHeight();
	textW = 3;

	//highlite current mouse position
	if(hover){
		//draw background rect
		ofSetColor(timeline->getColors().backgroundColor);
        float screenX = ofClamp(millisToScreenX(hoverTime), bounds.getMinX(), bounds.getMaxX());
		text = timeline->formatTime(hoverTime);
		textW = timeline->getFont().stringWidth(text)+3;
        if(bounds.height > 2){
            int previewTimecodeX = ofClamp(screenX+5, bounds.getMinX(), bounds.getMaxX()-textW-5);
            ofFill();
            ofRect(previewTimecodeX-5, bounds.y+textH, textW, textH);		
            //draw playhead line
            ofSetColor(timeline->getColors().textColor);
            timeline->getFont().drawString(text, previewTimecodeX, bounds.y+textH*2);
        }
		
		ofSetColor(timeline->getColors().highlightColor);
		ofSetLineWidth(1);

        ofLine(screenX, totalDrawRect.y, screenX, totalDrawRect.y+totalDrawRect.height);
	}
	
	//draw current frame
    int currentFrameX;
    if (timeline->getIsFrameBased()) {
        text = ofToString(timeline->getCurrentFrame());
        currentFrameX = screenXForIndex(timeline->getCurrentFrame());
    }
    else{
        text = timeline->formatTime(timeline->getCurrentTime());
        currentFrameX = screenXForTime(timeline->getCurrentTime());
    }
    currentFrameX = ofClamp(currentFrameX, bounds.getMinX(), bounds.getMaxX());
							
    if(bounds.height > 2){
        int timeCodeX = ofClamp(currentFrameX+5, bounds.getMinX(), bounds.getMaxX()-textW-5);
        ofSetColor(timeline->getColors().backgroundColor);
        ofFill();
        ofRect(timeCodeX-5, bounds.y, textW, textH);
        ofSetColor(timeline->getColors().textColor);
        timeline->getFont().drawString(text, timeCodeX, bounds.y+textH);
    }
	
    if(timeline->getIsPlaying()){
        ofSetColor(timeline->getColors().keyColor);
    }
    else{
        ofSetColor(timeline->getColors().outlineColor);
    }
	
	//draw playhead line
	ofSetLineWidth(1);
	ofLine(currentFrameX, totalDrawRect.y, currentFrameX, totalDrawRect.y+totalDrawRect.height);
	//draw bounds 
	ofNoFill();
	ofSetColor(200, 180, 40);
	ofRect(bounds);
		
	ofPopStyle();
}
//--------------------------------------------------------------
void openniTracking::drawContourAnalysis(){

	string temp;

	glPushMatrix();
	glTranslatef(366, 90, 0);
	glScalef(320.0f/_width, 240.0f/_height, 1.0);

	ofEnableAlphaBlending();

	ofFill();

	for(unsigned int i = 0; i < blobTracker.blobs.size(); i++){
		ostringstream docstring;
		docstring << blobTracker.findOrder(blobTracker.blobs[i]._id) << endl;
		temp = docstring.str();
		blobsOrder[i] = atoi(temp.c_str());

		glColor4f(0.847,0.25,0.25,0.4);
		ofRect(_s_blobInfo[i].center.x,_s_blobInfo[i].center.y,_s_blobInfo[i].size.width,_s_blobInfo[i].size.height);

		glColor4f(0.0,0.0,1.0,1.0);
		if(temp != ""){
			ofDrawBitmapString(temp,_s_blobInfo[i].center.x + _s_blobInfo[i].size.width/2.0,_s_blobInfo[i].center.y + _s_blobInfo[i].size.height/2.0);
		}
	}

	glColor4f(1.0,1.0,1.0,1.0);

	for (unsigned int i = 0; i < contourFinder.nBlobs; i++){

		//-------------------  draw the contours
		if(cfDetail == 0){
			glColor4f(0.847,0.25,0.25,1.0);
			ofNoFill();
			drawBlob(0,0,contourFinder.blobs[i]);
		}else if(cfDetail == 1){
			glColor4f(0.847,0.25,0.25,1.0);
			ofNoFill();
			ofBeginShape();
			for(unsigned int j = 0; j < contourSmooth[i].size(); j++){
				ofVertex(contourSmooth[i].at(j).x, contourSmooth[i].at(j).y);
			}
			ofEndShape(true);
		}else if(cfDetail == 2){
			glColor4f(0.847,0.25,0.25,1.0);
			ofNoFill();
			ofBeginShape();
			for(unsigned int k = 0; k < contourSimple[i].size(); k++){
				ofVertex(contourSimple[i].at(k).x, contourSimple[i].at(k).y);
			}
			ofEndShape(true);
		}
		//------------------- fit angle of orientation
		glColor4f(1.0,0.906,0.463,1.0);

		float x1,y1,x2,y2;

		x1 = contourFinder.blobs[i].centroid.x + 25 * cos(blobAngle[i]);
		y1 = contourFinder.blobs[i].centroid.y + 25 * sin(blobAngle[i]);
		x2 = contourFinder.blobs[i].centroid.x - 25 * cos(blobAngle[i]);
		y2 = contourFinder.blobs[i].centroid.y - 25 * sin(blobAngle[i]);

		glPushMatrix();
		glScalef(0.5,0.5,0.0);
		ofLine(x1*2,y1*2,x2*2,y2*2);
		glPopMatrix();

		x1 = contourFinder.blobs[i].centroid.x + 10 * cos(blobAngle[i]+HALF_PI);
		y1 = contourFinder.blobs[i].centroid.y + 10 * sin(blobAngle[i]+HALF_PI);
		x2 = contourFinder.blobs[i].centroid.x - 10 * cos(blobAngle[i]+HALF_PI);
		y2 = contourFinder.blobs[i].centroid.y - 10 * sin(blobAngle[i]+HALF_PI);

		glPushMatrix();
		glScalef(0.5,0.5,0.0);
		ofLine(x1*2,y1*2,x2*2,y2*2);
		glPopMatrix();
		//------------------- fit geometry lines on countour
		if(computeContourGeometry){
			glColor4f(0.1,1.0,0.0,0.8);
			ofNoFill();
			for(unsigned int j = 0; j < geomLines[i].size(); j++){
				ofLine(geomLines[i].at(j).x,geomLines[i].at(j).y,geomLines[i].at(j).z,geomLines[i].at(j).w);
				ofCircle(geomLines[i].at(j).x,geomLines[i].at(j).y,3);
				ofCircle(geomLines[i].at(j).z,geomLines[i].at(j).w,3);
			}
		}
	}

	glPopMatrix();

	ofDisableAlphaBlending();
}
示例#4
0
//--------------------------------------------------------------
void testApp::draw() {
	glEnable( GL_DEPTH_TEST );
	
	camera.begin();
	
	ofSetLineWidth(1.f);
	if(bDrawDebug) world.drawDebug();
	
	ofEnableLighting();
	light.enable();
	light.setPosition(shapes[0]->getPosition());
	ofSetColor(255, 255, 255);
	shapes[0]->draw();
	
	ofSetColor(100., 100., 100.);
	
	if(!bDropBox) {
		boundsMat.begin();
		for(int i = 0; i < bounds.size()-1; i++) {
			bounds[i]->draw();
		}
		boundsMat.end();
	} else {
		ofNoFill();
		btScalar	m[16];
		ofGetOpenGLMatrixFromRigidBody( boundsShape->getRigidBody(), m );
		glPushMatrix(); 
		glMultMatrixf( m );
		ofBox(ofVec3f(0, 0,0), boundsWidth);
		glPopMatrix();
		ofFill();
	}
	
	ofDisableAlphaBlending();
	ofDisableBlendMode();
	
	glPushAttrib(GL_ALL_ATTRIB_BITS);
    glPushClientAttrib(GL_CLIENT_ALL_ATTRIB_BITS);
    glEnable(GL_NORMALIZE);
    glDisable(GL_CULL_FACE);
	ofPoint scale		= assimpModel.getScale();
	
	ofSetColor(0, 0, 0);
	logoMat.begin();
	for(int i = 0; i < logos.size(); i++) {
		btScalar	m[16];
		ofGetOpenGLMatrixFromRigidBody( logos[i]->getRigidBody(), m );
		glPushMatrix(); 
		glMultMatrixf( m );
		glTranslatef(-logos[i]->getCentroid().x, -logos[i]->getCentroid().y, -logos[i]->getCentroid().z);
		ofScale(scale.x,scale.y,scale.z);
		assimpModel.getMesh(0).drawFaces();
		glPopMatrix();
	}
	glPopAttrib();
	logoMat.end();
	
	ofSetColor(15,197,138);
	ofPushStyle();
	shapesMat.begin();
	for(int i = 0; i < shapes.size(); i++) {
		shapes[i]->draw();
	}
	shapesMat.end();
	ofPopStyle();
	
	light.disable();
	ofDisableLighting();
	
	camera.end();
	glDisable(GL_DEPTH_TEST);
	
	int totalShapes = shapes.size() + logos.size();
	ofVec3f gravity = world.getGravity();
	stringstream ss;
	ss << "Draw Debug (d): " << bDrawDebug << endl;
	ss << "Total Shapes: " << totalShapes << endl;
	ss << "Add logos(o)" << endl;
	ss << "add spherers (s)" << endl;
	ss << "add boxes (b)" << endl;
	ss << "Gravity(up/down/left/right): x=" << gravity.x << " y= " << gravity.y << " z= " << gravity.z << endl;
	ofSetColor(255, 255, 255);
	ofDrawBitmapString(ss.str().c_str(), 20, 20);
}
//--------------------------------------------------------------
void testApp::draw(){

	ofDrawBitmapString("test", 10, 10);


	//--
	// Highlight background of selected camera

	glDisable(GL_DEPTH_TEST);
	ofPushStyle();
	ofSetColor(100, 100, 100);
	ofRect(viewGrid[iMainCamera]);
	ofPopStyle();
	glEnable(GL_DEPTH_TEST);

	//
	//--



	//--
	// Draw all viewports

	// draw main viewport
	cameras[iMainCamera]->begin(viewMain);
	drawScene(iMainCamera);

	// calculate mouse ray whilst this camera is active
	updateMouseRay();

	cameras[iMainCamera]->end();

	// draw side viewports
	for(int i = 0; i < N_CAMERAS; i++){
		cameras[i]->begin(viewGrid[i]);
		drawScene(i);
		cameras[i]->end();
	}

	//
	//--



	//--
	// Draw annotations (text, gui, etc)

	ofPushStyle();
	glDepthFunc(GL_ALWAYS); // draw on top of everything

	// draw some labels
	ofSetColor(255, 255, 255);
	ofDrawBitmapString("Press keys 1-4 to select a camera for main view", viewMain.x + 20, 30);
	ofDrawBitmapString("Camera selected: " + ofToString(iMainCamera + 1), viewMain.x + 20, 50);
	ofDrawBitmapString("Press 'f' to toggle fullscreen", viewMain.x + 20, 70);
	ofDrawBitmapString("Press 'p' to toggle parents on OrthoCamera's", viewMain.x + 20, 90);

	ofDrawBitmapString("EasyCam",   viewGrid[0].x + 20, viewGrid[0].y + 30);
	ofDrawBitmapString("Front",     viewGrid[1].x + 20, viewGrid[1].y + 30);
	ofDrawBitmapString("Top",       viewGrid[2].x + 20, viewGrid[2].y + 30);
	ofDrawBitmapString("Left",      viewGrid[3].x + 20, viewGrid[3].y + 30);

	// draw outlines on views
	ofSetLineWidth(5);
	ofNoFill();
	ofSetColor(255, 255, 255);
	//
	for(int i = 0; i < N_CAMERAS; i++){
		ofRect(viewGrid[i]);
	}
	//
	ofRect(viewMain);

	// restore the GL depth function
	glDepthFunc(GL_LESS);
	ofPopStyle();

	//
	//--
}
示例#6
0
void effectFive::draw(float sound,bool defromPerlin,float left[256]){
	offcetTime++;
	if(offcetTime > period){
	
		builtNextBranch();
			offcetTime = 0;
	}
	
	
	
	//ofSetLineWidth(1);
	ofNoFill();
	ofSetColor(255, 255, 255);
	int index = 0;
	
	//Applique l'effet sur toutes les lignes
	
	for(int i=0; i<lines.size(); i++){
		
		int div = 10;
		int posx1 = lines[i].x1;
		int posy1 = lines[i].y1;
		int posx2 = lines[i].x2;
		int posy2 = lines[i].y2;
		
		if(defromPerlin){
			
			float simplexNoiseX1 = (noise->noise3((512.0-(float)posx1)/div,(float)posy1/div,ofGetFrameNum()/3))*sound*15000;
			float simplexNoiseY1 = (noise->noise3((350-(float)posy1)/div,(float)posx1/div,ofGetFrameNum()/3))*sound*15000;
			float simplexNoiseX2 = (noise->noise3((512-(float)posx2)/div,(float)posy2/div,ofGetFrameNum()/3))*sound*15000;
			float simplexNoiseY2 = (noise->noise3((350-(float)posy2)/div,(float)posx2/div,ofGetFrameNum()/3))*sound*15000;
			
			posx1Voulu = posx1 + simplexNoiseX1;
			posy1Voulu = posy1 + simplexNoiseY1;
			posx2Voulu = posx2 + simplexNoiseX2;
			posy2Voulu = posy2 + simplexNoiseY2;
			
			float diffx1 =  posx1Voulu - posx1;
			float diffy1 =  posy1Voulu - posy1;
			float diffx2 =  posx2Voulu - posx2;
			float diffy2 =  posy2Voulu - posy2;
			
			posx1 += diffx1/150;
			posy1 += diffy1/150;
			posx2 += diffx2/150;
			posy2 += diffy2/150;
			
		}
		
		float dist = sqrt(ofDistSquared(posx1, posy1, posx2, posy2 ));
		float coeff = 256.0 / dist;
		float hight = 200.0 / coeff;
		float angle = atan2(double(posy2-posy1) , double(posx2-posx1));
		float mydegreangle = ofRadToDeg(angle);			
		
		glPushMatrix();
		ofTranslate(posx1, posy1,0);
		ofRotateZ(mydegreangle);
	//	glBegin(GL_LINES);

		for(int x = 1; x < dist; x +=20) {
			if(branches.size()>index){
			branches[index].draw();
			index++;
			}
			//ofCircle(x,0, 10);
		
		}
		
		glPopMatrix();
	}
}
//--------------------------------------------------------------
void ofApp::draw(){
    
    Poco::LocalDateTime now; //(2015,5,29,17,38);
    
    if(ofGetKeyPressed(OF_KEY_ALT)) {
        // auto step the time of day to proof changes
        int total_min = fabs(sin(ofGetElapsedTimef()*.05)) * 1440; // 1440 == mins per day  60 * 24
        int hr = floor(total_min/60.0);
        int mn = total_min - (hr*60); //now.minute();
        now.assign(now.year(), now.month(), now.day(), hr, mn);
    }
    
    float sun_brightness = ofxSunCalc::getSunBrightness(todayInfo, now);
    
    if(ofGetKeyPressed(OF_KEY_COMMAND)) {
        sun_brightness = fabs(sin(ofGetElapsedTimef()*.1));
    }
    
    // draw background gradient based on sun_brightness
    
    ofColor nightBG(ofColor::black);
    ofColor nightFG(64);
    
    ofColor dayBG(ofColor::skyBlue);
    ofColor dayFG(ofColor::paleGoldenRod);
    
    ofColor background = nightBG.lerp(dayBG, sun_brightness);
    ofColor foreground = nightFG.lerp(dayFG, sun_brightness);
    
    ofBackgroundGradient(foreground, background);
    
    ofDrawBitmapStringHighlight(date_str, 15, 20, ofColor::paleGoldenRod, ofColor::black);
    
    ofDrawBitmapStringHighlight(min_info_str, 15, 45, ofColor::salmon, ofColor::white);
    
    ofDrawBitmapStringHighlight(max_info_str, 15, 125, ofColor::darkorange, ofColor::white);
    
    ofDrawBitmapStringHighlight(latlon_str, 180, 20, ofColor::gold, ofColor::black);
    
    ofDrawBitmapStringHighlight(pos_str, 180, 45, ofColor::cornsilk, ofColor::black);
    
    ofDrawBitmapStringHighlight("Current Brightness " + ofToString(sun_brightness, 3), 180, 70, ofColor::goldenRod, ofColor::white);
    
    float tx = 10 + 110;
    float ty = 320;
    for(int i = 0; i<timelines.size(); i++) {
        
        ofSetColor(255);
        timelines[i].draw(tx, ty);
        
        ofDrawBitmapStringHighlight(labels[i], 10, ty+13);
        
        if(i == 2) { // today
            ofNoFill();
            ofSetLineWidth(1.0);
            ofSetColor(255);
            ofRect(tx, ty, timelines[i].getWidth(), timelines[i].getHeight());
            
            // Draw a current time mark
            float pixels_per_min = (timelines[i].getWidth() / 24) / 60.0;
            float nx = tx + pixels_per_min * (now.hour() * 60 + now.minute());
            ofSetColor(255, 0, 0);
            ofSetLineWidth(2.0);
            ofLine(nx, ty, nx, ty+timelines[i].getHeight());
        }
        
        ty += timelines[i].getHeight() + 25;
    }
    
}
示例#8
0
void Maho::draw( float x, float y){
    if (!drawing) return;
    //phase0
//    if (lastMaho) {
//        float lastMahoLineNum = line1Num *2;
//        int lastMahoBlobPointNum = blobPointNum * 3;
//        float lastMahoSparkRangeMax = 180.0f;
//        float lastMahoLine2MinLength = 180.0f;//2.0f - 300.0f
//        float lastMahoLine2MaxLength = 500.0f;
//        float mahoLine2MaxLength = 110.5f;//
//        ofPushStyle();
//        ofPushMatrix();
//        ofTranslate(x, y);
//        
//        
//        for (int i = 0; i < lines2.size(); i++) {
//            lines2[i].draw();
//        }
//        ofFill();
//        b.draw();
//        b2.draw();
//        for (int i = 0; i < bunshis.size(); i++) {
//            bunshis[i].draw();
//        }
//        ofNoFill();
//        ofSetLineWidth(4.0f);
//        for (int i = 0; i < lines.size(); i++) {
//            ofPushMatrix();
//            ofRotateZ(lines[i].angle);
//            lines[i].draw();
//            ofPopMatrix();
//        }
//        ofPopMatrix();
//        ofPopStyle();
//        ofPushStyle();
//        lastparticles.draw();
//        ofPopStyle();
//        
//        return;
//    }
    if (mahoPhase == 0){
        ofPushStyle();
        ofPushMatrix();
        ofTranslate(x, y);
        for (int i = 0; i < lines2.size(); i++) {
            lines2[i].draw();
        }
        ofFill();
        b.draw();
        b2.draw();
        for (int i = 0; i < bunshis.size(); i++) {
            bunshis[i].draw();
        }
        ofNoFill();
        ofSetLineWidth(4.0f);
        for (int i = 0; i < lines.size(); i++) {
            ofPushMatrix();
            ofRotateZ(lines[i].angle);
            lines[i].draw();
            ofPopMatrix();
        }
        ofPopMatrix();
        ofPopStyle();
        ofPushStyle();
        lastparticles.draw();
        ofPopStyle();
        
    } else if (mahoPhase == 1){
        if ( currentMahoTime < keenTime) {//Keen
            ofPushStyle();
            ofPushMatrix();
            ofNoFill();
            ofSetColor(mainPink);
            ofSetLineWidth(keenWidth);
            ofPoint v = mahoPos[1] - mahoPos[0];
            ofLine(mahoPos[0], mahoPos[1]);
            ofPopMatrix();
            ofPopStyle();
        } else if ( currentMahoTime > keenTime && currentMahoTime < mahoPhase2Time[0]) {//本棚がグニャグニャ hondana
            //fade
            if (mahoIndex == 1) {
                //gunya1
                ofPushStyle();
                ofPushMatrix();
                ofFill();
                ofSetColor(color);
                ofBeginShape();
                for (int i = 0; i < HONDANA_INDEX_NUM; i++) {
                    ofVertex(hondanaPoints[i]);
                    hondanaPoints[i] += ofRandomf() * hondanaNoiseAmt;
                }
                ofEndShape();
                ofBeginShape();
                for (int i = HONDANA_INDEX_NUM - 1; i >= 0; i--) {
                    ofVertex(hondanaPoints[i]);
                    hondanaPoints[i] += ofSignedNoise(ofGetElapsedTimeMillis()) * hondanaNoiseAmt;
                }
                ofEndShape();
                ofPopMatrix();
                ofPopStyle();
            } 
        }
        
        
        //sera
        if (currentMahoTime > keenTime && mahoIndex == 2) {//sera
            if (!seraDid) {
                if (choicedXtion == 0) {
                    bDrawSeraBlob = true;
                } else {
                    for (int i = 1; i <= XTION_NUM; i++) {
                        if (choicedXtion - 1 == i){
                            bDraw[i] = true;
                        }else bDraw[i] = false;
                    }
                    bOpenCv = true;
                }
                seraDid = true;
            }
            if (bSera) {
                if (bDrawSeraBlob){
                    ofPushStyle();
                    ofFill();
                    if (toggleCvFadeOut) {
                        if (openCvDrawColor.r > 2)openCvDrawColor.r -= 3;
                        if (openCvDrawColor.g > 2)openCvDrawColor.g -= 3;
                        if (openCvDrawColor.b > 2)openCvDrawColor.b -= 3;
                        if (openCvDrawColor.r < 3) {
                            bDrawSeraBlob = false;
                        }
                    }
                    ofSetColor(openCvDrawColor);
                    
//                    ofBeginShape();
//                    for (int i = 0; i < 6; i++) {
//                        ofVertex(seraBlob[i].x + ofRandomf() * 10.0f, seraBlob[i].y + ofRandomf() * 10.0f);
//                    }
//                    ofEndShape();
                    
//                    ofBeginShape();
//                    for (int i = 0; i < 6; i++) {
//                        ofVertex(seraBlob[i].x + ofRandomf() * 10.0f, seraBlob[i].y + ofRandomf() * 10.0f);
//                    }
//                    ofEndShape();
//                    ofPoint centerOfSera(0.0f, 0.0f);
//                    for (int i = 0; i < 6; i++) {
//                        centerOfSera.x += seraBlob[i].x;
//                        centerOfSera.y += seraBlob[i].y;
//                    }
//                    centerOfSera /= 6.0f;
//                    for (int i = 0; i < 100; i++) {
//                        float length = ofRandom(0.0f, 100.0f);
//                        float angle = ofRandom(0.0f, 360.0f);
//                        float xx = length * cos(angle);
//                        float yy = length * sin(angle);
//                        if (sin(angle) < 0) yy *= 0.5f;
//                        
//                        ofRect(2.0f + centerOfSera.x + xx, 2.0f + centerOfSera.y + yy, 8.0f, 8.0f);
//                    }
                    
                    for (int i = 0; i < 100; i++) {
                        float length = ofRandom(0.0f, 100.0f);
                        float angle = ofRandom(0.0f, 360.0f);
                        float xx = length * cos(angle) * 0.4;
                        float yy = length * sin(angle);
                        if (sin(angle) < 0) yy *= 0.5f;
                        
                        ofRect(4.0f + seraHeadPos[0].x + xx, 4.0f + seraHeadPos[0].y + yy, 8.0f, 8.0f);
                    }
                    
                    for (int i = 0; i < 100; i++) {
                        float length = ofRandom(0.0f, 100.0f);
                        float angle = ofRandom(0.0f, 360.0f);
                        float xx = length * cos(angle) * 0.4;
                        float yy = length * sin(angle);
                        if (sin(angle) < 0) yy *= 0.5f;
                        
                        ofCircle(seraHeadPos[0].x + xx, seraHeadPos[0].y + yy, 8.0f);
                    }

//                    float noiseLineLength = 30.0f;
//                    ofNoFill();
//                    ofSetColor(openCvDrawColor);
//                    ofSetLineWidth(2.0f);
//                    ofEnableBlendMode(OF_BLENDMODE_SUBTRACT);
//                    for (int i = 0; i < 50; i++) {
//                        ofLine(centerOfSera.x - noiseLineLength /2.0f, centerOfSera.y + ofNoise(ofGetElapsedTimef() * 100 * i)*noiseLineLength,  centerOfSera.x + noiseLineLength /2.0f, centerOfSera.y + ofNoise(ofGetElapsedTimef() * 100 * i)*noiseLineLength);
//                    }
//                    ofDisableBlendMode();
                    
                }
                sera.draw();
            } else {
                sera.toggleGo();
                bSera = true;
            }
        }
        //harada door
        if (currentMahoTime > keenTime && mahoIndex == 3) {
            //gunya1
            ofPushStyle();
            ofFill();
            ofSetColor(color);
            ofBeginShape();
            for (int i = 0; i < 6; i++) {
                ofVertex(doorPos[i]);
            }
            ofEndShape();
            ofBeginShape();
            for (int i = 0; i < 6; i++) {
                ofVertex(doorPosDamy[i]);
                doorPosDamy[i].x += ofRandomf() * doorGunyaAmt;
            }
            ofEndShape();
            ofBeginShape();
            for (int i = 4 - 1; i >= 0; i--) {
                ofVertex(doorPosDamy[i]);
                doorPosDamy[i].x += ofRandomf() * doorGunyaAmt;
            }
            ofEndShape();
            ofPopStyle();
        }
        //harada fire
        if (currentMahoTime > keenTime && mahoIndex == 6) {
            bHaradaFire = true;
            haradaFire.setup();
            haradaFire.toggleGo();
            mahoIndex = 0;
        }
        //sushi
        if (currentMahoTime > keenTime && mahoIndex == 7) {
            //rokka-
            ofPushStyle();
            ofPushMatrix();
            ofFill();
            ofSetColor(color);
            ofBeginShape();
            for (int i = 0; i < 4; i++) {
                ofVertex(rokkaPos[i]);
            }
            ofEndShape();
            ofBeginShape();
            for (int i = 0; i < 4; i++) {
                ofVertex(rokkaPosDamy[i].x + ofRandomf() * hondanaNoiseAmt, rokkaPosDamy[i].y + ofRandomf() * hondanaNoiseAmt);
            }
            ofEndShape();
            ofBeginShape();
            for (int i = 3; i >= 0; i--) {
                ofVertex(rokkaPosDamy[i].x + ofSignedNoise(ofGetElapsedTimeMillis()) * hondanaNoiseAmt, rokkaPosDamy[i].y + ofSignedNoise(ofGetElapsedTimeMillis()) * hondanaNoiseAmt);
            }
            ofEndShape();
            ofPopMatrix();
            ofPopStyle();
        }
        //gomory
        if (currentMahoTime > keenTime && mahoIndex == 8) {
            ofPushStyle();
            ofPushMatrix();
            ofFill();
            ofSetColor(color);
            ofBeginShape();
            for (int i = 0; i < 6; i++) {
                ofVertex(doorPos[i]);
            }
            ofEndShape();
            ofBeginShape();
            for (int i = 0; i < 6; i++) {
                ofVertex(doorPosDamy[i]);
                doorPosDamy[i].x += ofRandomf() * doorGunyaAmt;
            }
            ofEndShape();
            ofBeginShape();
            for (int i = 4 - 1; i >= 0; i--) {
                ofVertex(doorPosDamy[i]);
                doorPosDamy[i].x += ofRandomf() * doorGunyaAmt;
            }
            ofEndShape();
            ofPopMatrix();
            ofPopStyle();
        }

        
    }
    
}
示例#9
0
void ofxTLLFO::drawModalContent(){
	if(!drawingLFORect){
		return;
	}
	
	ofPushStyle();
	ofSetColor(timeline->getColors().disabledColor, 200);
	
	ofSetLineWidth(1);
	ofFill();
	
	ofRect(sineTypeRect);
	ofRect(noiseTypeRect);
	ofRect(phaseShiftRect);
//    ofRect(phaseMatchRect);
	ofRect(amplitudeRect);
	ofRect(frequencyRect);
	ofRect(seedRect);
	ofRect(centerRect);
	ofRect(interpolateRect);
    ofRect(expInterpolateRect);
	
	ofNoFill();
	ofSetColor(timeline->getColors().keyColor);
	
	ofRect(sineTypeRect);
	ofRect(noiseTypeRect);
	ofRect(phaseShiftRect);
//    ofRect(phaseMatchRect);
	ofRect(amplitudeRect);
	ofRect(frequencyRect);
	ofRect(seedRect);
	ofRect(centerRect);
	ofRect(interpolateRect);
    ofRect(expInterpolateRect);
	
	ofxTLLFOKey* lfokey = (ofxTLLFOKey*)selectedKeyframe;
	ofSetColor(timeline->getColors().highlightColor, 128);
	ofFill();
	if(lfokey->type == OFXTL_LFO_TYPE_SINE){
		ofRect(sineTypeRect);
	}
	else{
		ofRect(noiseTypeRect);
	}
			//TODO: Phase match
//    if(lfokey->phaseMatch){
//		ofRect(phaseMatchRect);
//	}
    
	if(lfokey->interpolate){
		ofRect(interpolateRect);
	}
    
    if (lfokey->expInterpolate){
        ofRect(expInterpolateRect);
    }
    
	
	ofSetColor(timeline->getColors().textColor, 200);
	float lineHeight = timeline->getFont().getLineHeight();
	timeline->getFont().drawString("sine", sineTypeRect.x+10, sineTypeRect.y+lineHeight);
	timeline->getFont().drawString("noise", noiseTypeRect.x+10, noiseTypeRect.y+lineHeight);
	timeline->getFont().drawString("phase: " + ofToString(lfokey->phaseShift, 1), phaseShiftRect.x+10, phaseShiftRect.y+lineHeight);
			//TODO: Phase match
//	timeline->getFont().drawString("phaseMatch", phaseMatchRect.x+10, phaseMatchRect.y+lineHeight);
	timeline->getFont().drawString("amplitude: " + ofToString(lfokey->amplitude, 4), amplitudeRect.x+10, amplitudeRect.y+lineHeight);
	timeline->getFont().drawString("frequency: " + ofToString(lfokey->frequency, 1), frequencyRect.x+10, frequencyRect.y+lineHeight);
	timeline->getFont().drawString("seed: " + ofToString(lfokey->seed, 1), seedRect.x+10, seedRect.y+lineHeight);
	timeline->getFont().drawString("center: " + ofToString(ofMap(lfokey->center, 0, 4, valueRange.min, valueRange.max), 4), centerRect.x+10, centerRect.y+lineHeight);
	timeline->getFont().drawString("interpolate", interpolateRect.x+10, interpolateRect.y+lineHeight);
	timeline->getFont().drawString("expinterpolate", expInterpolateRect.x+10, expInterpolateRect.y+lineHeight);
	
	ofPopStyle();
}
示例#10
0
void FboBlendEdge::draw(){
	if(!enabled) return;
	
	ofPushStyle();
	
	ofPoint point;
	ofNoFill();
	ofSetLineWidth(2);
	
	//ofSetColor(255, 255, 0);
	//point = position;// + blendTangent*width;
	//ofCircle(point.x, point.y, 4);
	
	//point -= blendDirection*width;
	//ofCircle(point.x, point.y, 4);
	
	//draw blend start line
	ofPoint p1, p2;
	p1 = position - blendDirection*width;
	p2 = p1;
	p1 -= blendTangent* height * 0.5;
	p2 += blendTangent* height * 0.5;
	ofLine(p1.x, p1.y, p2.x, p2.y);
	
	
	/*
	point = position - blendTangent*width;
	ofCircle(point.x, point.y, 4);
	point -= blendDirection*width;
	ofCircle(point.x, point.y, 4);
	*/
	
	float angle = atan2(blendDirection.y, blendDirection.x);
	float flip = angle >=   0?-1:1;//flip the way we draw the curve so adjecent edges fit together nicely
	
	ofSetLineWidth(0);
	ofFill();
	float pointSize = 1;
	for(float i = 0; i >= -1; i -= 0.015625){
		
		/*
		ofSetColor(255, 255, 0);			
		point = position + blendDirection*width*i;
		ofCircle(point.x, point.y, pointSize);
		*/
		
		//ofSetColor(255, 0, 255);
		float p = blend(point);
		point = position + blendDirection*width*i + blendTangent*width*p*flip;// - blendTangent*width*0.5;
		ofCircle(point.x, point.y, pointSize);
		
		/*
		float g;
		//float b = blend(point);
		
		g = 1 - gammaR.igammaNormalized(p);
		ofSetColor(255, 0, 0);
		point = position + blendDirection*width*i - blendTangent*width*g*flip;
		ofCircle(point.x, point.y, pointSize);
		
		g = 1 - gammaG.igammaNormalized(p);
		ofSetColor(0, 255, 0);
		point = position + blendDirection*width*i - blendTangent*width*g*flip;
		ofCircle(point.x, point.y, pointSize);
		
		g = 1 - gammaB.igammaNormalized(p);
		ofSetColor(0, 0, 255);
		point = position + blendDirection*width*i - blendTangent*width*g*flip;
		ofCircle(point.x, point.y, pointSize);
		
		*/
	}
	
	ofSetColor(255, 255, 255);
	
	ofPopStyle();
}
示例#11
0
void ofxGuiArrow::drawArrow( int direction ) {
	// TODO
	glPushMatrix();
		glTranslatef( mObjX, mObjY, 0.0f );

		//! No param name output.

		//ofFill();

		////! background
		//glColor4f( mGlobals->mCoverColor.r, mGlobals->mCoverColor.g, mGlobals->mCoverColor.b, mGlobals->mCoverColor.a );
		//ofRect( mCtrX, mCtrY, mCtrWidth, mCtrHeight );

		if ( mValue == true ) {
			//! Handle
			ofFill();
			glColor4f( mGlobals->mButtonColor.r, mGlobals->mButtonColor.g, mGlobals->mButtonColor.b, mGlobals->mButtonColor.a );
		} else {
			ofNoFill();
			glColor4f( mGlobals->mFrameColor.r, mGlobals->mFrameColor.g, mGlobals->mFrameColor.b, mGlobals->mFrameColor.a );
		}

		switch( direction ) {
			case kofxGui_Arrow_Up:
				glBegin( GL_TRIANGLES );
					glVertex3f( mCtrX + mCtrWidth/2, mCtrY + mOffset, 0.0f );
					glVertex3f( mCtrX, mCtrY + mCtrHeight, 0.0f );
					glVertex3f( mCtrX + mCtrWidth, mCtrY + mCtrHeight, 0.0f );
				glEnd();
				break;

			case kofxGui_Arrow_Down:
				glBegin( GL_TRIANGLES );
					glVertex3f( mCtrX, mCtrY, 0.0f );
					glVertex3f( mCtrX + mCtrWidth, mCtrY, 0.0f );
					glVertex3f( mCtrX + mCtrWidth/2, mCtrY + mCtrHeight - mOffset, 0.0f );
				glEnd();
				break;

			case kofxGui_Arrow_Right:
				glBegin( GL_TRIANGLES );
					glVertex3f( mCtrX, mCtrY, 0.0f );
					glVertex3f( mCtrX, mCtrY + mCtrHeight, 0.0f );
					glVertex3f( mCtrX + mCtrWidth - mOffset, mCtrY + mCtrHeight/2, 0.0f );
				glEnd();
				break;
				
			case kofxGui_Arrow_Left:
				glBegin( GL_TRIANGLES );
					glVertex3f( mCtrX + mOffset, mCtrY + mCtrHeight/2, 0.0f );
					glVertex3f( mCtrX + mCtrWidth, mCtrY, 0.0f );
					glVertex3f( mCtrX + mCtrWidth, mCtrY + mCtrHeight, 0.0f );
				glEnd();
				break;

			default:
				ofRect( mCtrX, mCtrY, mCtrWidth, mCtrHeight );
				break;
		}
	glPopMatrix();
}
示例#12
0
//--------------------------------------------------------------
void ofApp::draw(){
    
    int frameDiff;
    
    while (oscReceiver.hasWaitingMessages()) {
        cout << "New msg is coming + ";
        ofxOscMessage m;
        oscReceiver.getNextMessage(&m);
        
        if (m.getAddress() == "/sync/play/FW_SH_02_HBD_A/frameJump") {
            frameJump = m.getArgAsInt32(0);
            cout << "Frame sync, jump(" << frameJump << ") frames\r\n";
            
            // do move forward
            videoPlayers[i]->setFrame(frameJump);
        }
        else if (m.getAddress() == "/sync/play/nowPlayingFile") {
            // can I get all the file list from the beginning?
            loadVideo(m.getArgAsString(0));
        }
        else if (m.getAddress() == "/sync/play/nowPlayingStart") {
            isCellStart = m.getArgAsInt32(0);
        }
        else if (m.getAddress() == "/sync/play/nowPlayingStop") {
            isCellStop = m.getArgAsInt32(0);
        }
        else if (m.getAddress() == "/sync/play/type") {
            mediaType = m.getArgAsString(0);
        }
        else if (m.getAddress() == "/sync/play/nowPlayingKickTime") {
            cellKickTime = m.getArgAsInt32(0);
        }
        //dumpOSC(m);
    }
    
    strFruitString =  strFruitPrefix + ofToString(currentAppleAmount) + strUnit;
    
    if (!videoPause) {
//        if (((videoPlayers[i]->getPosition() * videoPlayers[i]->getDuration()) - videoPlayers[i]->getDuration()) == 0){
//            
//            if (i < N_VIDEO_PLAYERS-1) {
//                i++;
//            }
//            else {
//                i = 0;
//                loopCounter++;
//            }
//        }
        
        //for(auto p : videoPlayers) {
        //        p->draw(ofMap(i++, 0, videoPlayers.size(), 0, ofGetWidth()), ofGetHeight()/2 - 108*2, 192*4, 108*4);
        
        //ofPushMatrix();
        //ofSetColor(ofRandom(255), 0, 0);
//        ofRect(0,0,ofGetWidth(),ofGetHeight());
//        ofEnableAlphaBlending();
//        ofSetColor(255,255,255);
//        
#if 0   // for 1080 x 3840 video
        //---------------------------------------------------------- draw video texture to fullscreen.
        ofRectangle screenRect(0, 0, ofGetWidth(), ofGetHeight());
        ofRectangle videoRect(0, 0, videoPlayers[i]->getWidth(), videoPlayers[i]->getHeight());
        ofRectangle videoFullscreenRect = videoRect;
        videoFullscreenRect.scaleTo(screenRect, OF_ASPECT_RATIO_KEEP_BY_EXPANDING);
        
        videoPlayers[i]->draw(0, 0, videoFullscreenRect.getWidth(), videoFullscreenRect.getHeight());
        
#endif
        
#if 1
        // for 2 1080 x 1920 videos
        //---------------------------------------------------------- draw video texture to fullscreen.
        
        for (int videoNum = 0; videoNum < videoPlayers.size(); videoNum++) {
            if (videoNum == 1) { //top
                ofRectangle screenRect(0, 0, ofGetWidth(), ofGetHeight()/2);
                ofRectangle videoRect(0, 0, videoPlayers[videoNum]->getWidth(), videoPlayers[videoNum]->getHeight());
                ofRectangle videoFullscreenRect = videoRect;
                videoFullscreenRect.scaleTo(screenRect, OF_ASPECT_RATIO_KEEP_BY_EXPANDING);
                videoPlayers[videoNum]->draw(0, 0, videoFullscreenRect.getWidth(), videoFullscreenRect.getHeight());
            }
            else if (videoNum == 0) { //bottom
                ofRectangle screenRect(0, 0, ofGetWidth(), ofGetHeight()/2);
                ofRectangle videoRect(0, 0, videoPlayers[videoNum]->getWidth(), videoPlayers[videoNum]->getHeight());
                ofRectangle videoFullscreenRect = videoRect;
                videoFullscreenRect.scaleTo(screenRect, OF_ASPECT_RATIO_KEEP_BY_EXPANDING);
                videoPlayers[videoNum]->draw(0, ofGetHeight()/2, videoFullscreenRect.getWidth(), videoFullscreenRect.getHeight());
            }
        }

        
        if (i < N_VIDEO_PLAYERS-1) {
            i++;
        }
        else {
            i = 0;
            //loopCounter++;
        }

        
#endif
        
        
        //videoPlayers[i]->draw(0, 0, 900, 1400);
        
        
        //p->draw(ofMap(i++, 0, videoPlayers.size(), 0, ofGetWidth()), ofGetHeight()/2 - 108*2, 192*4, 108*4);
        
        // 2304x4096 sumsung tv @1
        // 2304x8192 ofScreen
        // 2026x3840 video
        
        //        cout << "w:" << w << "\n";
        //        p->draw(0, 0);
        //ofPopMatrix();
        //}
    }
    
    if (imageDisplay) {
        
        ofRectangle screenRect(0, 0, ofGetWidth()/2, ofGetHeight()/2);
        ofRectangle videoRect(0, 0, imgTop->width, imgTop->height);
        ofRectangle videoFullscreenRect = videoRect;
        videoFullscreenRect.scaleTo(screenRect, OF_ASPECT_RATIO_KEEP_BY_EXPANDING);
        
        if (imgTopPosters.size() == 1) {
            ofSetColor(255, 255, 255);  // very important, don't delete set color
            imgTopPosters[0]->draw(0, 0, imgTopPosters[0]->width, imgTopPosters[0]->height);
        }

        
        if (dbgImg) {
            ofSetColor(0, 0, 255);
            imgTop->drawBounds(0, 0, imgTop->width, imgTop->height);
            imgBottom->drawBounds(0, 4096, imgBottom->width, imgBottom->height);
        }
        else {
            
            ofPushMatrix();
                ofEnableAlphaBlending();
                    ofSetColor(255, 255, 255);  // very important, don't delete set color
            
                    // ensure first image is showing
                    //imgTopPosters[0]->draw(0, 0, imgTopPosters[0]->width, imgTopPosters[0]->height);
            
                    if ((ofGetElapsedTimef() - initTime) > 2) {
                        //videoPause = !videoPause;
                        //imageDisplay = !imageDisplay;
                        initTime = ofGetElapsedTimef();
                        
                        if (imgTopx && !isUpdateImg) {
                            //ofColor(255, 0, 0, 100);
                            int size = imgTopPosters.size(); // size limitation is 2 by design
                            if (size > 0) {
                                imgTopPosters[imgRotateIndex]->draw(0, 0, imgTopPosters[imgRotateIndex]->width, imgTopPosters[imgRotateIndex]->height);
                                imgRotateIndex++;
                                if (imgRotateIndex >= size)
                                    imgRotateIndex = 0;
                                
                                //ofSleepMillis(3000);// well...
                            }
                            
                            //                        for (auto i = imgTopPosters.begin(); i!= imgTopPosters.end();  ++i) {
                            //                            //(*i)->draw(0, 0, imgTopx->width, imgTopx->height);
                            //                            (*i)->draw(0, 0, (*i)->width, (*i)->height);
                            //                        }
                            //imgTopx->draw(0, 0, imgTopx->width, imgTopx->height);
                        }
                        else{
                            imgTopPosters[0]->draw(0, 0, imgTopPosters[0]->width, imgTopPosters[0]->height);
                            //imgTop->draw(0, 0, imgTop->width, imgTop->height);
                        }
                    }
            
                    ofNoFill();
                    ofSetColor(100, 0, 100, 100);
                    ofCircle(imgTop->width/2, imgTop->height/3+100, 400);
                ofDisableAlphaBlending();
                
                //ofRectangle bbox;
                float fontSize = 300;
                //ofTranslate(100, 2* ofGetHeight()/3);
                //ofRotateY(50 * ofGetElapsedTimef());
                ofSetColor(100, 0, 100, 128);
                FZLfont.draw(strPoster, fontSize, imgTop->width/2-100+0.1*x, imgTop->height/3+100+0.1*y);
                //bbox = unicodeFont.getStringBoundingBox(strFruitPrefix, 100, 2* ofGetHeight()/3);
                //ofSetColor(0, 200, 0);
                //ofFill();
                //ofRotateZ(-5);
                ofEnableAlphaBlending();
            ofPopMatrix();
            
            // Bottom poster
            //ofColor(255, 255, 255);
            //ofTranslate(0, 4096); // samgung tv
            ofSetColor(255, 255, 255); // very important, don't delete set color
            ofTranslate(0, 7680/2); // pptv
            imgBottom->draw(0, 0, imgBottom->width, imgBottom->height);
        }
    }
    
    ofDrawBitmapStringHighlight("FPS: " + ofToString(fps), 20, 360);
    ofDrawBitmapStringHighlight("Frame " + ofToString(videoPlayers[i]->getCurrentFrame()) + "/" + ofToString(videoPlayers[i]->getTotalNumFrames()), 20, 380);
    ofDrawBitmapStringHighlight("Duration " + ofToString(videoPlayers[i]->getPosition() * videoPlayers[i]->getDuration(), 2) + "/" + ofToString(videoPlayers[0]->getDuration(), 2), 20, 400);
    ofDrawBitmapStringHighlight("Speed " + ofToString(videoPlayers[i]->getSpeed(), 2), 20, 420);
    ofDrawBitmapStringHighlight("Canvas W:" + ofToString(ofGetWidth()) + " H:" + ofToString(ofGetHeight()), 20, 440);

    ofDrawBitmapString("Total Loop #" + ofToString(loopCounter) + " \nClip #" + ofToString(i), 20, 460);
    
    // send out frame number information
    msgSend.setAddress("/sync/play/FW_SH_02_HBD_A/currentFrame");
    msgSend.addIntArg(videoPlayers[i]->getCurrentFrame());
    oscSender.sendMessage(msgSend);
    
    
    
#if 0
#if 0
    ofPushMatrix();
    ofRectangle bbox;
    ofSetColor(255, 0, 0, 32);
    float fontSize = 20 /*134*/;
    //TIME_SAMPLE_START("bbox");
    //ofTranslate(100, 2* ofGetHeight()/3);
    bbox = unicodeFont.getBBox(strFruitString, fontSize, 500, 500);
    //TIME_SAMPLE_STOP("bbox");
    ofRect(bbox);
    ofPopMatrix();
#endif

    ofPushMatrix();
        ofRectangle bbox;
        float fontSize = 134;
        //ofTranslate(100, 2* ofGetHeight()/3);
        //ofRotateY(50 * ofGetElapsedTimef());
        ofSetColor(0xd3, 0xd3, 0xd3, 200);
        unicodeFont.draw(strFruitString, fontSize, 100, 2* ofGetHeight()/3);
        bbox = unicodeFont.getStringBoundingBox(strFruitPrefix, 100, 2* ofGetHeight()/3);
        ofSetColor(0, 200, 0);
        //ofFill();
        ofEnableAlphaBlending();
        ofRect(bbox);
        //ofRotateZ(-5);
    ofPopMatrix();
    
    // text background
    ofSetColor(153, 153, 153, 100);
    ofRect(100, 2* ofGetHeight()/3 - 130, ofGetWidth()-100, 160);
    
    if (isDemoMode) {
        if ((ofGetElapsedTimef() - initTimeDbg) > 3.0) {
            videoPause = !videoPause;
            imageDisplay = !imageDisplay;
            initTimeDbg = ofGetElapsedTimef();
        }
    }
    
    if (isDownloadImg){
        isDownloadImg = !isDownloadImg;
       
        cout << "Downloading..." << "\n";
        ofSetColor(100, 0, 100, 128);
        
        if (isUpdateImg) {
            string str = "Poster Updating...";
            FZLfont.draw(str, 200, ofGetWidth()/2, ofGetHeight()/4*2);
        }
        
        // read file name from iOS client
        char serverPath[512] = "http://192.168.43.155:8080/";
        if (strUpdateFileDate.length() != 0) {
            sprintf(updateURL, "%s%s.jpg", serverPath, strUpdateFileDate.c_str());
            cout << "Update URL: " << updateURL << "\n";
            ofSaveURLAsync(updateURL, "images/L1.jpg");
        }
        else{
            cout << "ERROR: No update date" << "\n";
        }
    }
    
    if (isUpdateImg) {
        // reload image here
        if (imgTopx)
            delete imgTopx;
        
        imgTopx = new ofxGiantImage();
        imgTopx->loadImage("images/L1.jpg");
        imgTopPosters.push_back(imgTopx); // push into image queues
        isUpdateImg = !isUpdateImg;
    }
#endif
    
}
示例#13
0
//--------------------------------------------------------------
void ofApp::draw(){
		// reset screen
		ofSetColor(0, 0, 0, 7);
		ofRect(0, 0, ofGetWidth(), ofGetHeight());
		ofSetColor(255, 255, 255, 255);
		if (toggleDrawImage) {
				image.draw(0, 0, image.width, image.height);
		}
		
		// palse layer
		fbo.begin();
		// screen update
		ofEnableBlendMode(OF_BLENDMODE_ALPHA);
		ofSetColor(0, 0, 0, 2);
		ofRect(0, 0, ofGetWidth(), ofGetHeight());
		ofSetColor(255, 255, 255, 255);
		
		//mesh
		if (toggleLive) {
				//live(manually add or erase)
				addMeshAction(doAdd);
				eraseMeshAction(doErase);
		} else {
				// auto
				addMeshAction(ofGetFrameNum()%60 == 1 && ofRandom(2)>1);
				eraseMeshAction(ofGetFrameNum()%60 == 2 && ofRandom(2)>1.8);
		}
		
		fbo.end();
		ofEnableBlendMode(OF_BLENDMODE_ALPHA);

		// draw mesh
		ofPushStyle();
		toggleFill ? ofFill() : ofNoFill();
		if (doFill) {
				doFill = false;
				ofFill();
		}else{
				ofNoFill();
		}
		ofSetLineWidth(sliderWireLineWidth);
		ofEnableBlendMode(OF_BLENDMODE_ALPHA);
    triangulation.draw();
		ofPopStyle();
		
		//draw fbo(pulse layer)
		fbo.draw(0, 0);
		
		// hide below for live
		if (!hideGui) {
				// gui
				gui.draw();
				
				// debug
				stringstream ss;
				ss << "framerate: " << ofToString(ofGetFrameRate(), 0);
				ofDrawBitmapString(ss.str(), 10, 15);
				
				// guide line
				ofPushStyle();
				ofSetColor(255, 255, 0);
				ofLine(0, ofGetHeight()/2., ofGetWidth(), ofGetHeight()/2.);
				ofLine(ofGetWidth()/2., 0, ofGetWidth()/2., ofGetHeight());
				ofSetColor(255, 0, 255);
				ofLine(image.getWidth(), 0, image.getWidth(), ofGetHeight());
				ofLine(0, image.getHeight(), ofGetWidth(), image.getHeight());
				ofPopStyle();
		}
}
示例#14
0
//--------------------------------------------------------------
void testApp::draw()
{
	
    ofBackgroundGradient(ofColor::white, ofColor::gray);
    
    ofPushStyle();
    ofSetColor(ofColor::black);
    string qStr = "";
    if (thinkGear.getSignalQuality() == 0.0)
    {
        qStr =
		"good";
//		mySerial.writeBytes(bytesToSend, NUM_MSG_BYTES);
//		bytesToSend[0] = ofMap(attention, 0, 100, 0, 254);
//		bytesToSend[1] = 9;
//		bytesToSend[2] = ofMap(blink, 0, 100, 0, 254);
//		bytesToSend[3] = 5;
    }
    else 
    {
        qStr = "poor (" + ofToString(thinkGear.getSignalQuality()) + ")";
    }
    font.drawString("signal quality = " + qStr, 10, 40);    
    ofPopStyle();
	
	//blink
	font.drawString("Blink", 10, (blink)); 
    
	//directions
	if (attention < 1 && meditation < 1) {
		font.drawString("CONCENTRATE ON DOT", ofGetWidth()/2, ofGetHeight()/2);
	}

	
    //attention bar
    ofPushMatrix();
    ofTranslate(0, 30);
    ofPushStyle();
    ofSetColor(ofColor::black);
    font.drawString("Attention", 10, ofGetHeight()/11 - 10);
    ofNoFill();
    ofCircle(ofGetWidth()/2, ofGetHeight()/2, currAw);
//	ofRect(1, ofGetHeight()/11, ofGetWidth() - 2, 60);
    ofSetColor(ofColor::yellow, ofMap(currAw, 0.0, ofGetWidth(), 50, 255));
    ofFill(); 
	ofCircle(ofGetWidth()/2, ofGetHeight()/2, currAw);
//  ofRect(0, ofGetHeight()/11, currAw, 59);
	ofSetColor(ofColor::black, ofMap(currAw, 0.0, ofGetWidth(), 50, 255));
	font.drawString(ofToString(attention), 10, ofGetHeight()/11 + 40);

	
	mySerial.writeBytes(bytesToSend, NUM_MSG_BYTES);
	if (attention > 0 && attention < 100) {	
		bytesToSend[0] = ofMap(attention, 0, 100, 200, 254);
	}
	bytesToSend[1] = 9;
	if (blink > 0 && blink < 200) {
		bytesToSend[2] = ofMap(blink, 0, 100, 0, 254);
	}
	
//	if (attention > 0 && attention < 255) {
//		//mySerial.writeByte(ofMap(attention, 0, 250, 0, 255, true));
////		mySerial.writeByte(attention);
//		int controlVal = ofMap(attention, 0, 100, 255, 0, true);
//		sendToMotor(controlVal);
//	}
	
//    if (attention >= 30.0) {
//		serial.writeByte('H');
//		bSendSerialMessage = true;
//    }
//	else if (attention < 30.0) {
//		bSendSerialMessage = true;
//		serial.writeByte('L');
//	}
	
    ofPopStyle();
    ofPopMatrix();
    
	//key circle
	ofSetColor(ofColor::black);
//	ofTranslate(0, 30);
	ofCircle(ofGetWidth()/2, (ofGetHeight()/2)+30, 2);
	
	//meditation bar
    ofPushMatrix();
    ofTranslate(0, 30);
    ofPushStyle();
    ofSetColor(ofColor::black);
    font.drawString("Meditation", 10, (ofGetHeight()/3.5) - 10); 
    ofNoFill();
	ofCircle(ofGetWidth()/2, ofGetHeight()/2, currMw);
//  ofRect(1, (ofGetHeight()/3.5), ofGetWidth() - 2, 60);    
    ofSetColor(ofColor::cyan, ofMap(currMw, 0.0, ofGetWidth(), 50, 255));
    ofFill();
	ofCircle(ofGetWidth()/2, ofGetHeight()/2, currMw);
//	ofRect(0, (ofGetHeight()/3.5), currMw, 59);
	ofSetColor(ofColor::black, ofMap(currMw, 0.0, ofGetWidth(), 50, 255));
	font.drawString(ofToString(meditation), 10, (ofGetHeight()/3.5) + 40); 
	
//	if (meditation >= 20.0) {
//		serial.writeByte('H');
//		bSendSerialMessage = true;
//    }
//	else if (meditation < 20.0) {
//		bSendSerialMessage = true;
//		serial.writeByte('L');
//	}
	
    ofPopStyle();
    ofPopMatrix();
    
				
    ofSetWindowTitle("fps = " + ofToString(ofGetFrameRate()));
	
	//start serial
	if(!isInitialized)
        ofDrawBitmapString("PRESS 'S' TO SEND KICKOFF BYTE", 50, (ofGetHeight()/2)+200);
    else {
        //draw out current bytesToSend values:
        for(int i=0; i<NUM_MSG_BYTES; i++){
            string whichByte = "bytesToSend["+ofToString(i)+"] = ";
            ofDrawBitmapString(whichByte + ofToString((int)bytesToSend[i]), 50, (ofGetHeight()/2)+30+30*i);
            if     (i == 0) ofDrawBitmapString("(attention)", 225, (ofGetHeight()/2)+30+30*i);
            else if(i == 1) ofDrawBitmapString("(Motor pin)", 225, (ofGetHeight()/2)+30+30*i);
            else if(i == 2) ofDrawBitmapString("(blink speed)", 225, (ofGetHeight()/2)+30+30*i);
			//else if(i == 3) ofDrawBitmapString("(Servo pin)", 225, 30+30*i);
        }
        
        //just for debug
        //ofDrawBitmapString("num messages sent total: "+ ofToString(numMsgSent), 50, ofGetHeight()/2);
       // ofDrawBitmapString("press 'a','b','c','A','B','C', LEFT, or RIGHT arrows to update values", 50, (ofGetHeight()/2)+50);
    }
	
//	for(int i=0; i<NUM_MSG_BYTES; i++){
//        string whichByte = "bytesReceived["+ofToString(i)+"] = ";
//        font.drawString(whichByte+ofToString(bytesReceived[i]), 20, 30+30*i);
//    }
//    
//    //just for debug
//    font.drawString("num messages received total: "+ ofToString(numMsgRecvd), 20, 150);
//    
//    //if we haven't received anything yet
//    if(numMsgRecvd<1)
//        font.drawString("PRESS ANY KEY TO SEND KICK OFF BYTE", 20, 180);
	
	
	//serial.writeByte('H');
	//cout << 'writeByte' << endl;
	
//	if (nBytesRead > 0 && ((ofGetElapsedTimef() - readTime) < 0.5f)){
//		ofSetColor(0);
//	} else {
//		ofSetColor(220);
//	}
	
	//activate to see serial connection
//	string msg;
//	msg += "click to test serial:\n";
//	msg += "nBytes read " + ofToString(nBytesRead) + "\n";
//	msg += "nTimes read " + ofToString(nTimesRead) + "\n";
//	msg += "read: " + ofToString(bytesReadString) + "\n";
//	msg += "(at time " + ofToString(readTime, 3) + ")";
//	font.drawString(msg, ofGetWidth()/1.3, 100);
	//end serial

}
示例#15
0
//--------------------------------------------------------------
void ofApp::draw(){
	if( oneShot ){
		ofBeginSaveScreenAsPDF("screenshot-"+ofGetTimestampString()+".pdf", false);
	}
	
	ofSetColor(54);
	ofDrawBitmapString("PDF OUTPUT EXAMPLE", 32, 32);
	if( pdfRendering ){
		ofDrawBitmapString("press r to stop pdf multipage rendering", 32, 92);
	}else{	
		ofDrawBitmapString("press r to start pdf multipage rendering\npress s to save a single screenshot as pdf to disk", 32, 92);
	}
		
		
	ofFill();		
	ofSetColor(54,54,54);
	ofDrawBitmapString("TTF Font embdedded into pdf as vector shapes", 32, 460);
	
	if( oneShot || pdfRendering ){
		font.drawStringAsShapes("Current Frame: ",  32, 500);
		ofSetColor(245, 58, 135);
		font.drawStringAsShapes( ofToString(ofGetFrameNum()), 32 + font.getStringBoundingBox("Current Frame: ", 0, 0).width + 9, 500);
	}else{
		font.drawString("Current Frame: ",  32, 500);	
		ofSetColor(245, 58, 135);		
		font.drawString( ofToString(ofGetFrameNum()), 32 + font.getStringBoundingBox("Current Frame: ", 0, 0).width + 9, 500);		
	}
	
	
	ofSetColor(54,54,54);
	ofDrawBitmapString("Images can also be embedded into pdf", 32, dropZoneRects[0].y - 18);
	
	ofSetRectMode(OF_RECTMODE_CORNER);
	ofNoFill();
	for(unsigned int k = 0; k < dropZoneRects.size(); k++){
		ofSetColor(54,54,54);
		ofRect(dropZoneRects[k]);
		ofSetColor(245, 58, 135);		
		ofDrawBitmapString("drop images here", dropZoneRects[k].getCenter().x - 70, dropZoneRects[k].getCenter().y);
	}

	ofSetColor(255);
	for(unsigned int j = 0; j < images.size(); j ++){
		if( images[j].width > 0 ){
			
			float tw = 300;
			float th = 200;
			
			if( images[j].getWidth() / images[j].getHeight() < tw / th ){
				tw = th * ( images[j].getWidth() / images[j].getHeight() );
			}else{
				th = tw * ( images[j].getHeight() / images[j].getWidth() );			
			}
			
			images[j].draw(dropZoneRects[j].x, dropZoneRects[j].y, tw, th);
			
		}
	}
	
	//lets draw a box with a trail
    //让我们画一个跟着尾巴的方形
	ofSetColor(245, 58, 135);
	
	ofRectangle boxBounds(32, 500, ofGetWidth()-32, 250);
	
	//lets get a noise value based on the current frame
    //让我们设置噪点值基于现在的桢
	float noiseX = ofNoise(float(ofGetFrameNum())/600.f, 200.0f);
	float noiseY = ofNoise(float(ofGetFrameNum())/800.f, -900.0f);

	ofNoFill();
	ofBeginShape();
	ofVertices(boxTrail);
	ofEndShape(false);
	
	ofFill();
	ofSetRectMode(OF_RECTMODE_CENTER);

	ofPushMatrix();
		float x = ofMap( noiseX, 0, 1, boxBounds.x, boxBounds.x + boxBounds.width, true);
		float y = ofMap( noiseY, 0, 1, boxBounds.y, boxBounds.y + boxBounds.height, true);

		ofTranslate(x, y, 0);
		ofRotate(angle);
		ofRect(0, 0, 30, 30);
	ofPopMatrix();	
	
	if( boxTrail.size() == 0 || ( boxTrail.back() - ofPoint(x, y) ).length() > 1.5 ){
		boxTrail.push_back(ofPoint(x, y));
	}
	
	if(boxTrail.size() > 800 ){
		boxTrail.erase(boxTrail.begin(), boxTrail.begin()+1);
	}
	
	if( oneShot ){
		ofEndSaveScreenAsPDF();
		oneShot = false;
	}	
}
示例#16
0
//----------------------------------------------------------			
void ofxVectorGraphics::noFill(){ 
	bFill = false; ofNoFill();
}
示例#17
0
//--------------------------------------------------------------
void testApp::draw() {

    
    if(face.found > 0) {
        // draw a face
        
        ofPushMatrix();
            ofTranslate(face.posePosition);
            ofScale(face.poseScale, face.poseScale);
            
            ofSetColor(0);
            ofNoFill();
            ofEllipse(-20, face.eyeLeft * -9, 20, 7);
            ofEllipse(20, face.eyeRight * -9, 20, 7);
            ofEllipse(0, 20, face.mouthWidth * 3, face.mouthHeight * 3);
            ofEllipse(-5, face.nostrils * -1, 7, 3);
            ofEllipse(5, face.nostrils * -1, 7, 3);
            
            ofSetRectMode(OF_RECTMODE_CENTER);
            ofFill();
            ofRect(-20, face.eyebrowLeft * -5, 25, 5);
            ofRect(20, face.eyebrowRight * -5, 25, 5);
            ofSetRectMode(OF_RECTMODE_CORNER);
        ofPopMatrix();
        
        
        // catch emotion
        if(face.mouthHeight > 5){
            
            // Tweet
            
            if(!mouth_open) {
                tweet();
                mouth_open = true;
                
                ofDrawBitmapString(requestStr,20,20);
                ofDrawBitmapString(responseStr,20,60);
            }
            
            // fetch Twitter Trend
            if(parsed)
            {
                ofSetHexColor(0x000000);
                
                int n=0;
                ofxJSONElement trends = json[n]["trends"];
                
                for(int i=0; i<trends.size(); i++)
                {
                    string message = trends[i]["query"].asString();
                    message = ofxJSONElement::decodeURL( message );
                    //cout << message << endl;
                    font.drawString(message, 10, 40*i+40);
                    //franklinBook.drawString(message, 10, 40*i+40);
                    
                }
            }
             
        }else{
            mouth_open = false;
        }
    }

}
示例#18
0
void View::Draw(const Model &model) const {
  ofPushMatrix();
  SetupViewpoint();
  ofBackground(ofColor::white);
  //CHASERS-------------------
  for (int i = 0; i < model.nChasers; i++){
    model.topChaser[i]->draw();
    model.botChaser[i]->draw();
    model.rightChaser[i]->draw();
    model.leftChaser[i]->draw();
  }
  DrawGravity(model);
  DrawPlayers(model);
  
  ofColor ball_color = model.last_hit_player == 1 ? color_p1 :
      model.last_hit_player == 2 ? color_p2 : ofColor::white;
  DrawBallTrail(model, model.ball_trail, ball_color);
  DrawStrikeIndicator(model);
  DrawBall(model.ball, ball_color);
  
  for (float x=-10; x<GRID_W; x+=(1.0/6.0)) {
    for (float y=-5; y<GRID_H; y+=(1.0/6.0)) {
      if (ofDist(model.ball->GetPosition().x, model.ball->GetPosition().y, x, y)<0.3) {
        if (ball_color==color_p1){
          ofSetColor(color_p1.r,ofRandom(10,60),color_p1.b, 100);
        }else if(ball_color==color_p2){
          ofSetColor(ofRandom(10,60),color_p2.g,color_p2.b, 100);
        }else{
          ofSetColor(ofRandom(200,250),ofRandom(200,250),ofRandom(200,250), 200);
        }
        ofCircle(x, y, 0.1);
      }
      else if (ofDist(model.player1_top->GetPosition().x, model.player1_top->GetPosition().y, x, y)<0.4 ||
               ofDist(model.player1_bottom->GetPosition().x, model.player1_bottom->GetPosition().y, x, y)<0.4) {
        ofSetColor(color_p1.r,ofRandom(10,60),color_p1.b, 155);
        ofCircle(x, y, 0.12);
      }
      else if (ofDist(model.player2_top->GetPosition().x, model.player2_top->GetPosition().y, x, y)<0.4 ||
               ofDist(model.player2_bottom->GetPosition().x, model.player2_bottom->GetPosition().y, x, y)<0.4) {
        ofSetColor(ofRandom(10,60),color_p2.g,color_p2.b, 155);
        ofCircle(x, y, 0.12);
      }
      else if (ofDist(model.ball->GetPosition().x, model.ball->GetPosition().y, x, y)< model.p1glowMax){
        ofNoFill();
        ofSetColor(color_p1.r,ofRandom(10,60),color_p1.b, 135);
        ofCircle(x, y, 0.12);
        ofFill();
      }
      else if (ofDist(model.ball->GetPosition().x, model.ball->GetPosition().y, x, y)< model.p2glowMax){
        ofNoFill();
        ofSetColor(ofRandom(10,60),color_p2.g,color_p2.b, 135);
        ofCircle(x, y, 0.12);
        ofFill();
      }
      
      
      else {
        ofFill();
        ofSetColor(ofRandom(0,10),ofRandom(0,10),ofRandom(10,20), 20);
        ofTriangle(x, y+0.7, x-0.6, y-0.6, x+0.6, y-0.6);

      }

    }



    
  }
  DrawCourt(model);
  DrawScore(model);
  if (model.show_winning_state) {
    DrawTriangles(model);
  }
  ofPopMatrix();

  //DrawFramesPerSecond(model);
}
//--------------------------------------------------------------
void testApp::draw(){
	
	ofSetColor(225);
	ofDrawBitmapString("AUDIO INPUT EXAMPLE", 32, 32);
	ofDrawBitmapString("press 's' to unpause the audio\n'e' to pause the audio", 31, 92);
	
	ofNoFill();
	
	// draw the left channel:
	ofPushStyle();
		ofPushMatrix();
		ofTranslate(32, 170, 0);
			
		ofSetColor(225);
		ofDrawBitmapString("Left Channel", 4, 18);
		
		ofSetLineWidth(1);	
		ofRect(0, 0, 512, 200);

		ofSetColor(245, 58, 135);
		ofSetLineWidth(3);
					
			ofBeginShape();
			for (unsigned int i = 0; i < left.size(); i++){
				ofVertex(i*2, 100 -left[i]*180.0f);
			}
			ofEndShape(false);
			
		ofPopMatrix();
	ofPopStyle();

	// draw the right channel:
	ofPushStyle();
		ofPushMatrix();
		ofTranslate(32, 370, 0);
			
		ofSetColor(225);
		ofDrawBitmapString("Right Channel", 4, 18);
		
		ofSetLineWidth(1);	
		ofRect(0, 0, 512, 200);

		ofSetColor(245, 58, 135);
		ofSetLineWidth(3);
					
			ofBeginShape();
			for (unsigned int i = 0; i < right.size(); i++){
				ofVertex(i*2, 100 -right[i]*180.0f);
			}
			ofEndShape(false);
			
		ofPopMatrix();
	ofPopStyle();
	
	// draw the average volume:
	ofPushStyle();
		ofPushMatrix();
		ofTranslate(565, 170, 0);
			
		ofSetColor(225);
		ofDrawBitmapString("Scaled average vol (0-100): " + ofToString(scaledVol * 100.0, 0), 4, 18);
		ofRect(0, 0, 400, 400);
		
		ofSetColor(245, 58, 135);
		ofFill();		
		ofCircle(200, 200, scaledVol * 190.0f);
		
		//lets draw the volume history as a graph
		ofBeginShape();
		for (unsigned int i = 0; i < volHistory.size(); i++){
			if( i == 0 ) ofVertex(i, 400);

			ofVertex(i, 400 - volHistory[i] * 70);
			
			if( i == volHistory.size() -1 ) ofVertex(i, 400);
		}
		ofEndShape(false);		
			
		ofPopMatrix();
	ofPopStyle();
	
	drawCounter++;
	
	ofSetColor(225);
	string reportString = "buffers received: "+ofToString(bufferCounter)+"\ndraw routines called: "+ofToString(drawCounter)+"\nticks: " + ofToString(soundStream.getTickCount());
	ofDrawBitmapString(reportString, 32, 589);
		
}
示例#20
0
//--------------------------------------------------------------
void ofApp::draw(){
    
    ofSetColor(ofColor::white);
    
    if (tracker.isInited()) {
        
        depthImg.draw(ofGetWidth() - depthImg.getWidth() / 2., 0, depthImg.getWidth() / 2., depthImg.getHeight() / 2.);
        
        glPointSize(2.0);
        ofPushMatrix();
        camera.begin();
        
        //ofTranslate(ofGetWidth()/2.0, 0.);
        ofEnableDepthTest();
        
        // Draw point cloud
        
        if (drawPointCloud) {
  
            int w = 640;
            int h = 480;
            ofMesh mesh;
            mesh.setMode(OF_PRIMITIVE_POINTS);
            int step = 2;
            for(int y = 0; y < h; y += step) {
                for(int x = 0; x < w; x += step) {
                    if(kinect.getDistanceAt(x, y) > 0) {
                        mesh.addColor(kinect.getColorAt(x,y));
                        mesh.addVertex(kinect.getWorldCoordinateAt(x, y));
                    }
                }
            }
          
            ofPushMatrix();
            // the projected points are 'upside down' and 'backwards'
            ofScale(1, -1, -1);
            //ofTranslate(0, 0, -1000); // center the points a bit
            ofEnableDepthTest();
            mesh.drawVertices();
            ofDisableDepthTest();
            ofPopMatrix();
          
        }
        
        ofScale(1000., -1000., -1000.);
        
        // Draw hitboxes & puts the state back to normal on every frame:
        hitBoxesManager.drawBoxes();
        //hitBoxesManager.clearBoxesActivationState();
        
        // draw blobs
        for (unsigned int i = 0; i < tracker.blobs.size(); i++) {
            
            ofPushMatrix();
            ofColor color;
            color.setSaturation(200);
            color.setBrightness(225);
            color.setHue(ofMap(i, 0, tracker.blobs.size(), 0, 255));
            
            ofSetColor(color);
            // draw blobs
            tracker.blobs[i].draw();
            
            ofPopMatrix();
            
            ofVec3f bbMax = tracker.blobs[i].boundingBoxMax;
            ofVec3f bbMin = tracker.blobs[i].boundingBoxMin;
            
            ofNoFill();
            ofDrawBox(tracker.blobs[i].centroid, tracker.blobs[i].dimensions.x, tracker.blobs[i].dimensions.y, tracker.blobs[i].dimensions.z);
            ofFill();
            
        }
        
        ofSetColor(255);
        ofDisableDepthTest();
        camera.end();
        ofPopMatrix();
        
        // Check hitboxes status
        hitBoxesManager.checkBlobs(tracker.blobs);
        
        if (visible) {
            gui.draw();
            hitBoxesManager.drawHitBoxesGui();
        }
        
    }

}
示例#21
0
void ofxGuiPoints::draw()
{
	glPushMatrix();

		glTranslatef(mObjX, mObjY, 0.0f);

		if(mParamName != "")
			drawParamString(0.0, 0.0, mParamName + ": " + pointToString(mList.activePoint != -1 ? mOutVal : mValue, mDisplay), false);

		ofxPoint2f	p	= fractionToLocal(valueToFraction(mValue));

		float		x	= mCtrWidth * p.x;
		float		y	= mCtrHeight * p.y;

		float		d	= mGlobals->mPointSize;
		float		r	= d / 2.0;

		ofFill();

		//	background
		glColor4f(mGlobals->mCoverColor.r, mGlobals->mCoverColor.g, mGlobals->mCoverColor.b, mGlobals->mCoverColor.a);
		ofRect(mCtrX, mCtrY, mCtrWidth, mCtrHeight);

		ofNoFill();

		//	lines
		glColor4f(mGlobals->mCurveColor.r, mGlobals->mCurveColor.g, mGlobals->mCurveColor.b, mGlobals->mCurveColor.a);
		/*
		ofBeginShape();
			for(int i = 0; i < mList.points.size(); i++)
			{
				ofxPoint2f p = fractionToLocal(valueToFraction(mList.points.at(i)));
				ofVertex(p.x, p.y);
			}
		ofEndShape(false);
		*/

			GLfloat* verts = new GLfloat[(int)mMaxVal.x*2];
			for (int i = 0; i < mMaxVal.x; i++)	{
						ofxPoint2f p = fractionToLocal(valueToFraction(bezier(mList.points, mList.points.size()-1, (float) i / (float) mMaxVal.x)));

						verts[i*2  ] = p.x;
						verts[i*2+1] = p.y;
			}

			glEnableClientState(GL_VERTEX_ARRAY);
			glVertexPointer(2, GL_FLOAT, 0, verts );
			glDrawArrays( GL_LINE_STRIP, 0, mMaxVal.x);
			glDisableClientState(GL_VERTEX_ARRAY);

		//	x-bar
		glColor4f(mGlobals->mAxisColor.r, mGlobals->mAxisColor.g, mGlobals->mAxisColor.b, mGlobals->mAxisColor.a);
		ofLine(p.x + 0.5, mCtrY, p.x + 0.5, mCtrBottom);

		if(mList.activePoint != -1)
		{
			//	y-bar
			glColor4f(mGlobals->mAxisColor.r, mGlobals->mAxisColor.g, mGlobals->mAxisColor.b,mGlobals->mAxisColor.a);
			ofLine(mCtrX, p.y + 0.5, mCtrRight, p.y + 0.5);
		}

		//	handles
		for(int i = 0; i < mList.points.size(); i++)
		{
			glColor4f(mGlobals->mHandleColor.r, mGlobals->mHandleColor.g, mGlobals->mHandleColor.b, mGlobals->mHandleColor.a);

			ofxPoint2f p	= fractionToLocal(valueToFraction(mList.points.at(i)));
			ofRect(p.x - r, p.y - r, d, d);
		}

		//	frame
		glColor4f(mGlobals->mFrameColor.r, mGlobals->mFrameColor.g, mGlobals->mFrameColor.b, mGlobals->mFrameColor.a);
		ofRect(mCtrX, mCtrY, mCtrWidth, mCtrHeight);

	glPopMatrix();
}
示例#22
0
//--------------------------------------------------------------
void testApp::draw() {




    // draw the poly shape that we are about to make
    ofNoFill();
    ofBeginShape();
    for(int i=0; i<polyShape.size(); i++) {
        ofVertex(polyShape[i].x, polyShape[i].y);
    }
    ofEndShape();

    ofNoFill();
    for(int i=0; i<polyShape.size(); i++) {
        ofCircle(polyShape[i].x, polyShape[i].y, 1);
    }


    for(int i=0; i<circles.size(); i++) {
        ofFill();
        ofSetHexColor(0xBFff45);
        circles[i].draw();
    }



    for(int i=0; i<polygons.size(); i++) {
        ofSetHexColor(0xFF2545);
        ofNoFill();
        polygons[i].draw();
    }


    for(int i=0; i<boxes.size(); i++) {
        ofFill();
        ofSetHexColor(0xBF2545);
        boxes[i].draw();
    }



    for(int i=0; i<lines.size(); i++) {
        lines[i].draw();
    }


    /*
    for(int i=0; i<customParticles.size(); i++) {
    	//customParticles[i].draw();
    }

    for(int i=0; i<5; i++) ballJoints[i].draw();
    for(int i=0; i<5; i++) joints[i].draw();
    */


    //lineStrip.draw();
    box2d.drawGround();





    string info = "";
    info += "Press [s] to draw a line strip ["+ofToString(bDrawLines)+"]\n";
    info += "Press [f] to toggle Mouse Force ["+ofToString(bMouseForce)+"]\n";
    info += "Press [c] for circles\n";
    info += "Press [b] for blocks\n";
    info += "Press [z] for custom particle\n";
    info += "Total Bodies: "+ofToString(box2d.getBodyCount())+"\n";
    info += "Total Joints: "+ofToString(box2d.getJointCount())+"\n\n";
    info += "FPS: "+ofToString(ofGetFrameRate())+"\n";
    ofSetColor(255, 255, 255);
    ofDrawBitmapString(info, 30, 30);
}
示例#23
0
文件: ofApp.cpp 项目: Nslaver/Bezier
//--------------------------------------------------------------
void ofApp::draw(){
	
	ofEnableDepthTest();
    
    ofEnableLighting();
    pointLight.enable();
    pointLight2.enable();
    pointLight3.enable();

	cam.lookAt(camObjective);

	//Cam setup
	cam.begin();
	//cam.draw();
	//ofSetColor(0, 255, 0);
	//camObjective.draw();
	//ofDrawAxis(floorLimits);

	//Bezier line with evaluator
	ofFill();
    ofSetColor(pointLight.getDiffuseColor());
    //pointLight.draw();
    ofSetColor(pointLight2.getDiffuseColor());
    //pointLight2.draw();
    ofSetColor(pointLight3.getDiffuseColor());
    //pointLight3.draw();


	ofSetColor(ofColor::red);
	drawBezierLine();		
  
	//ofSetColor(ofColor::mediumPurple);
	//actorNode.draw();
	
	ofSetColor(ofColor::blueSteel);
	myHuman.draw();
		
	
	//daWorld

	ofSetColor(0, 15, 250);
	daWorld.draw();

	//Floor

	
	ofSetColor(0, 100, 25);
	floor.draw();

    /* Quad Floor
	glBegin(GL_QUADS);	
        glVertex3f( floorLimits, 0.0,  floorLimits);
		glVertex3f( floorLimits, 0.0, -floorLimits);
		glVertex3f(-floorLimits, 0.0, -floorLimits);
        glVertex3f(-floorLimits, 0.0,  floorLimits);
    glEnd();
	*/
	

	// draw bzNodes
	for(int i=0; i<kBezierPoints; i++) {
		ofSetColor(255, 128, 255);
		bzPoints[i].draw();
		if(i == 0 || i == 2){
			ofSetColor(255, 255, 0);
			ofVec3f v1 = bzNodes[i].getGlobalPosition();
			ofVec3f v2 = bzNodes[i+1].getGlobalPosition();
			ofLine(v1,v2);
		}
	}

	//glPushMatrix();

		
    //glPopMatrix();
	cam.end();

	
	ofSetColor(ofColor::gray);
	ofVec2f mouse(mouseX, mouseY);
	ofLine(nearestVertex, mouse);
	
	ofNoFill();
	ofSetColor(ofColor::yellow);
	ofSetLineWidth(2);
	ofCircle(nearestVertex, 4);
	ofSetLineWidth(1);

	// Test Mouse Picker
	/*ofVec3f cur2 = cam.worldToScreen(bzNodes[nearestIndex].getGlobalPosition());
	ofVec3f cur1 = cam.screenToWorld(ofVec3f(mouse.x,mouse.y, cur2.z));
	ofVec3f cur3 = cam.screenToWorld(ofVec3f(mouse.x,mouse.y, 1));	
		bool t = false;

		string s2 = string("Cursor") + 
		""+ ofToString(mouse)+
		"\n"+ ofToString(cur1)+
		"\n"+ ofToString(cur2)+
		"\n"+ ofToString(cur3);
	
	

	glDisable(GL_CULL_FACE);
	ofSetColor(255,0,0);
	ofDisableLighting();
	ofDrawBitmapString(s2, ofPoint(20, 40));
	glEnable(GL_CULL_FACE);*/

	

	//MSG

	string s = string("BZ Point: P") + 
		""+ ofToString(nearestIndex+1) + 
		"("+ ofToString(bzNodes[nearestIndex].getGlobalPosition()) + ")";

	ofDrawBitmapString(s, ofPoint(20, 20));	
}
示例#24
0
//--------------------------------------------------------------
void testApp::draw(){
    ofSetColor(255,255,255);

    int zeroCenterW = (ofGetWidth()/2)-(w/2);
    int zeroCenterH = (ofGetHeight()/2)-(h/2);


    
    if(screenDisplay == 0)
    {
        grayImage.draw(zeroCenterW,zeroCenterH);
        myfont.drawString("Gray Image", 100,100);
    }
    else if (screenDisplay == 1)
    {
        ofNoFill();
        
        grayImage.draw(0,0,ofGetWidth(),ofGetHeight());
        for(int i=0; i< keypoints.size();++i)
        {
            ofSetColor(255,0,142);
            float xScale = ofMap(keypoints[i].pt.x,0,w,0,ofGetWidth());
            float yScale = ofMap(keypoints[i].pt.y, 0, h, 0, ofGetHeight());
            ofEllipse(xScale, yScale, keypoints[i].size*1.5, keypoints[i].size*1.5);
            //ofEllipse(keypoints[i].pt.x+zeroCenterW,keypoints[i].pt.y+zeroCenterH,keypoints[i].size,keypoints[i].size);
        }
        ofSetColor(51,255,255);
        myfont.drawString("SURF Image", 100,100);
    }
    else if (screenDisplay == 2)
    {
        std::nth_element(matches.begin(),    // initial position
                         matches.begin()+24, // position of the sorted element
                         matches.end());     // end position
        // remove all elements after the 25th
        matches.erase(matches.begin()+25, matches.end());
        
        ofNoFill();
        grayBg.draw(zeroCenterW-322,zeroCenterH);
        grayImage.draw(zeroCenterW+322,zeroCenterH);
        for(int i=0; i< keypoints.size();++i)
        {
            ofSetColor(255,0,142);
            ofEllipse(keypoints[i].pt.x+zeroCenterW+322,keypoints[i].pt.y+zeroCenterH,keypoints[i].size,keypoints[i].size);
            ofEllipse(keypointsBg[i].pt.x+zeroCenterW-322,keypointsBg[i].pt.y+zeroCenterH,keypointsBg[i].size,keypointsBg[i].size);


           /* float angle = keypoints[i].angle;
            float ptSize = (keypoints[i].size) / 3.0f;
            float r1 = floor(keypoints[i].pt.y+0.5);
            float c1 = floor(keypoints[i].pt.x+0.5);
            float c2 = floor((ptSize * cos(angle))+0.5) + c1;
            float r2 = floor((ptSize * sin(angle))+0.5) + r1;
            
            ofSetColor(0x00ff00);
            ofLine(c1+zeroCenterW+322,r1+zeroCenterH,c2+zeroCenterW+322,r2+zeroCenterH);
            */
        }
        
        for(int i=0; i< matches.size();++i)
        {
            ofSetColor(51,255,255);
           ofLine(keypointsBg[matches[i].trainIdx].pt.x+zeroCenterW-322,keypointsBg[matches[i].trainIdx].pt.y+zeroCenterH,keypoints[matches[i].queryIdx].pt.x+zeroCenterW+322,keypoints[matches[i].queryIdx].pt.y+zeroCenterH);
        }
        ofSetColor(255, 255, 255);
        myfont.drawString("SURF Match", 100,100);

    }
    
    myfont.drawString(">", ofGetWidth()-50,ofGetHeight()/2);

    
   /*
    for(int i = 0 ; i< optflow.points_nextPoints.size();++i)
    {
    //motion vel might be the vel between prev pts and next points? Yes!
    //cout << " " << optflow.getVelPixelAtIndex(i) << endl;
       ofCircle(optflow.points_nextPoints[i].x,optflow.points_nextPoints[i].y,2);
    
 //   motionVec = optflow.getVelPixelAtIndex(i);
    //ps.addtoVecField(motionVec.x/winWidth, motionVec.y/winHeight, motionVec, 0.15);
    }
   */ 
}
void testApp::drawScene(int iCameraDraw){

	nodeSwarm.draw();
	nodeGrid.draw();

	//--
	// Draw frustum preview for ofEasyCam camera

	// This code draws our camera in
	//	the scene (reddy/pink lines)
	//
	// The pyramid-like shape defined
	//	by the cameras view is called
	//	a 'frustum'.
	//
	// Often we refer to the volume
	//	which can be seen by the
	//	camera as 'the view frustum'.


	// First check if we're already drawing the view through the easycam
	// If so, don't draw the frustum preview.
	if(iCameraDraw != 0){

		ofPushStyle();
		ofPushMatrix();

		//--
		// Create transform for box->frustum

		// In 'camera space' the bounds of
		//  the view are defined by a box
		//  with bounds -1->1 in each axis
		//
		// To convert from camera to world
		//  space, we multiply by the inverse
		//  camera matrix of the camera, i.e
		//  inverse of the ViewProjection
		//  matrix.
		//
		// By applying this transformation
		//  our box in camera space is
		//  transformed into a frustum in
		//  world space.
		//

		// The camera's matricies are dependant on
		//  the aspect ratio of the viewport.
		//  (Which is why we use the viewport as
		//  an argument when we begin the camera.
		//
		// If this camera is fullscreen we'll use
		//   viewMain, else we'll use viewGrid[0]
		ofRectangle boundsToUse;
		if(iMainCamera == 0){
			boundsToUse = viewMain;
		}
		else{
			boundsToUse = viewGrid[0];
		}

		// Now lets get the inverse ViewProjection
		//  for the camera
		ofMatrix4x4 inverseCameraMatrix;
		inverseCameraMatrix.makeInvertOf(camEasyCam.getModelViewProjectionMatrix(boundsToUse));

		// By default, we can say
		//	'we are drawing in world space'
		//
		// The camera matrix performs
		//	world->camera
		//
		// The inverse camera matrix performs
		//	camera->world
		//
		// Our box is in camera space, if we
		//	want to draw that into world space
		//	we have to apply the camera->world
		//	transformation.
		//

		// This syntax is a little messy.
		// What it's saying is, send the data
		//  from the inverseCameraMatrix object
		//  to OpenGL, and apply that matrix to
		//  the current OpenGL transform
		glMultMatrixf(inverseCameraMatrix.getPtr());

		//
		//--



		//--
		// Draw box in camera space
		// (i.e. frustum in world space)

		ofNoFill();
		// i.e. a box -1, -1, -1 to +1, +1, +1
		ofBox(0, 0, 0, 2.0f);
		//
		//--

		ofPopStyle();
		ofPopMatrix();
	}

	//
	//--



	//--
	// Draw mouse ray

	// Draw the ray if ofEasyCam is in main view,
	//  and we're not currently drawing in that view
	if(iMainCamera == 0 && iCameraDraw != 0){
		ofPushStyle();
		ofSetColor(100, 100, 255);
		ofLine(ray[0], ray[1]);
		ofPopStyle();
	}

	//
	//--
}
示例#26
0
//--------------------------------------------------------------
void testApp::draw(){
	
	
	ofSetColor(ofColor::lightGreen);
	
	ofPushMatrix();
	ofScale(ofGetWidth()/640, ofGetHeight()/480);
	// draw debug (ie., image, depth, skeleton)
	// openNIDevice.drawDebug();
	
	// use a blend mode so we can see 'through' the mask(s)
	ofEnableBlendMode(OF_BLENDMODE_ALPHA);
	
	// get number of current users
	int numUsers = openNIDevice.getNumTrackedUsers();
	
	// iterate through users
	for (int i = 0; i < numUsers; i++){
		
		// get a reference to this user
		ofxOpenNIUser & user = openNIDevice.getTrackedUser(i);
		
		rightHand = user.getJoint(JOINT_RIGHT_HAND).getProjectivePosition();
		
		leftHand = user.getJoint(JOINT_LEFT_HAND).getProjectivePosition();
		
		// for body
		head = user.getJoint(JOINT_HEAD).getProjectivePosition();
		rightShoulder = user.getJoint(JOINT_RIGHT_SHOULDER).getProjectivePosition();
		leftShoulder = user.getJoint(JOINT_LEFT_SHOULDER).getProjectivePosition();
		rightElbow = user.getJoint(JOINT_RIGHT_ELBOW).getProjectivePosition();
		leftElbow = user.getJoint(JOINT_LEFT_ELBOW).getProjectivePosition();
		torsoJoint = user.getJoint(JOINT_TORSO).getProjectivePosition();
		rightHip = user.getJoint(JOINT_RIGHT_HIP).getProjectivePosition();
		leftHip = user.getJoint(JOINT_LEFT_HIP).getProjectivePosition();
		rightKnee = user.getJoint(JOINT_RIGHT_KNEE).getProjectivePosition();
		leftKnee = user.getJoint(JOINT_LEFT_KNEE).getProjectivePosition();
		rightFoot = user.getJoint(JOINT_RIGHT_FOOT).getProjectivePosition();
		leftFoot = user.getJoint(JOINT_LEFT_FOOT).getProjectivePosition();
		
				
		vel_right = rightHand - prev_rightHand;
		vel_left = leftHand - prev_leftHand;
		
		//		if (vel.length() > 50 && rightHand.z < prev_rightHand.z) {
		//			isThrowing = true;
		//
		//		}else if (vel.length() < 10) {
		//			isThrowing = false;
		//		}
		
		// draw bg
		bg.draw(-200, 0);
	
		
		// draw the silhouette
		

		if(gameStatus == 0, 1, 2) 

			//draw head
			ofCircle(head.x, head.y, 60);
			
			//draw shoulders
			//ofBeginShape();
			int shoulderLength =  ofDist(rightShoulder.x, rightShoulder.y, leftShoulder.x, leftShoulder.y);
			int shoulder_width = shoulderLength/10;
			//ofVertex(rightShoulder.x, (rightShoulder.y - shoulder_width));
//			ofVertex(rightShoulder.x, (rightShoulder.y + shoulder_width));
//			ofVertex(leftShoulder.x, (leftShoulder.y + shoulder_width));
//			ofVertex(leftShoulder.x, (leftShoulder.y - shoulder_width));
//			ofEndShape();
		
//			int shoulderLength =  ofDist(rightShoulder.x, rightShoulder.y, leftShoulder.x, leftShoulder.y);
//			ofRect(rightShoulder.x, rightShoulder.y, -(shoulderLength), (shoulderLength/3));
		
		

		

		
			//draw upper right arm
			ofBeginShape();
			int upperArmLength =  ofDist(rightShoulder.x, rightShoulder.y, rightElbow.x, rightElbow.y);
			int upperArm_width = upperArmLength/8;
			ofVertex((rightShoulder.x + upperArm_width), rightShoulder.y);
			ofVertex((rightShoulder.x + upperArm_width)-10, rightShoulder.y-10);
			ofVertex((rightShoulder.x + upperArm_width)-20, rightShoulder.y-20);
			ofVertex((rightShoulder.x - upperArm_width), rightShoulder.y);
			ofVertex((rightElbow.x - upperArm_width), rightElbow.y);
			ofVertex((rightElbow.x + upperArm_width), rightElbow.y);
			ofEndShape();
		
			//draw upper left arm
			ofBeginShape();
			ofVertex((leftShoulder.x - upperArm_width), leftShoulder.y);
			ofVertex((leftShoulder.x - upperArm_width)+20, leftShoulder.y-20);
			ofVertex((leftShoulder.x - upperArm_width)+10, leftShoulder.y-10);
			ofVertex((leftShoulder.x + upperArm_width), leftShoulder.y);
			ofVertex((leftElbow.x + upperArm_width), leftElbow.y);
			ofVertex((leftElbow.x - upperArm_width), leftElbow.y);
			ofEndShape();
		
			//draw lower right arm
			ofBeginShape();
			int lowerArmLength =  ofDist(rightElbow.x, rightElbow.y, rightHand.x, rightHand.y);
			int lowerArm_width = lowerArmLength/9;
			ofVertex((rightElbow.x + lowerArm_width), rightElbow.y);
			ofVertex((rightElbow.x - lowerArm_width), rightElbow.y);
			ofVertex((rightHand.x - lowerArm_width), rightHand.y);
			ofVertex((rightHand.x + lowerArm_width), rightHand.y);
			ofEndShape();
		
			//draw lower left arm
			ofBeginShape();
			ofVertex((leftElbow.x + lowerArm_width), leftElbow.y);
			ofVertex((leftElbow.x - lowerArm_width), leftElbow.y);
			ofVertex((leftHand.x - lowerArm_width), leftHand.y);
			ofVertex((leftHand.x + lowerArm_width), leftHand.y);
			ofEndShape();
		
			//draw hands
			ofCircle(rightHand.x, rightHand.y, 15);
			ofCircle(leftHand.x, leftHand.y, 15);
		
			//draw torso
			ofBeginShape();
			//shoulders
			ofVertex(rightShoulder.x, rightShoulder.y);
			ofVertex(rightShoulder.x, rightShoulder.y-10);
			ofVertex(rightShoulder.x-10, rightShoulder.y-20);
			
			ofVertex(leftShoulder.x+10, leftShoulder.y-20);	
			ofVertex(leftShoulder.x, leftShoulder.y-10);
			ofVertex(leftShoulder.x, leftShoulder.y);	
		
			ofVertex(leftShoulder.x, leftHip.y);
			ofVertex(leftShoulder.x+20, leftHip.y+40);
			//ofVertex(torsoJoint.x, rightHip.y+35);
			ofVertex(rightShoulder.x-20, rightHip.y+40);	
			ofVertex(rightShoulder.x, rightHip.y);
			
			ofEndShape();
		
			//draw upper right leg
			ofBeginShape();
			int upperLegLength =  ofDist(rightHip.x, rightHip.y, rightKnee.x, rightKnee.y);
			int upperLeg_width = upperLegLength/10;
			ofVertex((rightHip.x + upperLeg_width), rightHip.y);
			ofVertex((rightHip.x - upperLeg_width), rightHip.y);
			ofVertex((rightKnee.x - upperLeg_width), rightKnee.y);
			ofVertex((rightKnee.x + upperLeg_width), rightKnee.y);
			ofEndShape();
		
			//draw upper left leg
			ofBeginShape();
			ofVertex((leftHip.x + upperLeg_width), leftHip.y);
			ofVertex((leftHip.x - upperLeg_width), leftHip.y);
			ofVertex((leftKnee.x - upperLeg_width), leftKnee.y);
			ofVertex((leftKnee.x + upperLeg_width), leftKnee.y);
			ofEndShape();
		
			//draw lower right leg
			ofBeginShape();
			int lowerLegLength =  ofDist(rightKnee.x, rightKnee.y, rightFoot.x, rightFoot.y);
			int lowerLeg_width = lowerLegLength/8;
			ofVertex((rightKnee.x + lowerLeg_width), rightKnee.y);
			ofVertex((rightKnee.x - lowerLeg_width), rightKnee.y);
			ofVertex((rightFoot.x - lowerLeg_width), rightFoot.y);
			ofVertex((rightFoot.x + lowerLeg_width), rightFoot.y);
			ofEndShape();
		
			//draw lower left leg
			ofBeginShape();
			ofVertex((leftKnee.x + lowerLeg_width), leftKnee.y);
			ofVertex((leftKnee.x - lowerLeg_width), leftKnee.y);
			ofVertex((leftFoot.x - lowerLeg_width), leftFoot.y);
			ofVertex((leftFoot.x + lowerLeg_width), leftFoot.y);
			ofEndShape();
		
			//user.drawSkeleton(); //only if we're NOT playing, draw the silhouette... maybe you want it like this?
			
		if (vel_left.length() > vel_right.length()) {
			vel = vel_left;
			hand = leftHand;
			prevHand = prev_leftHand;
		} else {
			vel = vel_right;
			hand = rightHand;
			prevHand = prev_rightHand;
		}
		
		if (gameStatus == 1){ //only check the ball, and then draw ball stuff if we're playing!
			
			myBall.update(hand, prevHand, vel);
			
			if ((target.x - 40) < myBall.pos.x && myBall.pos.x < (target.x + 40) &&
				(target.y - 40) < myBall.pos.y && myBall.pos.y < target.y + 40) {
				
				hasHit = true;
				now = ofGetElapsedTimef();
				lastTarget.x = target.x;
				lastTarget.y = target.y;
				//cout << "wtf" << endl;
                
			}
			
            
			ofNoFill();
			ofSetColor(ofColor::white);		
			ofSetLineWidth(5);
			ofCircle(target.x, target.y, 50);
			
			ofFill();
			
			drawSplat();
			
			for (int i = 0; i < splatList.size(); i++ ) {
				splatList[i].draw();
			}
			
			prev_rightHand = rightHand;
			prev_leftHand = leftHand;
		}
	}
    
    if (gameStatus == 0){
        // this is your start screen !
        
        score = 0; //reset the score?
		bg.draw(-200, 0);
		
        ofSetColor(255);
		//start button
		ofSetColor(ofColor::red);
		ofStyle(smooth);
		ofCircle(WIDTH/1.5, HEIGHT/2, 75);
		// (ballX >= ofGetWidth() || ballX <= 0 )
		
		ofSetColor(ofColor::black);
		verdana.loadFont(ofToDataPath("verdana.ttf"), 30);
		string msgB = "Start";
		verdana.drawString(msgB, (WIDTH/1.5)-50, (HEIGHT/2)+10);
		
		// use code for start button
		int distFromStartCircle = ofDist(WIDTH/1.5, HEIGHT/2, hand.x, hand.y);
		
		if (distFromStartCircle < 75) {
			gameStatus = 1; // set play screen
			score = 0; //reset score
			//reset timer
		}
		
		
		
		ofSetColor(ofColor::white);
			verdana.loadFont(ofToDataPath("verdana.ttf"), 96);
			string msg = "Food Fight!";
			verdana.drawString(msg, WIDTH/16, 100);
        
    }
	
	else if (gameStatus == 1){
		
		myBall.draw(hand);	
		
		ofDisableBlendMode();
		ofPopMatrix();
		
		// draw some info regarding frame counts etc
		//	ofSetColor(0, 255, 0);
		//string msg = " MILLIS: " + ofToString(ofGetElapsedTimeMillis()) + " FPS: " + ofToString(ofGetFrameRate()) + " Device FPS: " + ofToString(openNIDevice.getFrameRate());
		//    
		//	verdana.drawString(msg, 20, openNIDevice.getNumDevices() * 480 - 20);
		
		//cout << vel.length() << endl;
		//draw svg file
		//svg.draw();
		
		
		ofSetColor(255);
		long currTime = ofGetElapsedTimeMillis();
		//int min = 60000;
		
		//if (currTime <= 15000) {
//			verdana.loadFont(ofToDataPath("verdana.ttf"), 75);
//			string msg = "Food Fight!";
//			verdana.drawString(msg, WIDTH/3, 100);
//		}
		
		verdana.loadFont(ofToDataPath("verdana.ttf"), 50);
		string msgC = "Score: "+ofToString(score);
		verdana.drawString(msgC, WIDTH/.9, 150);
		string msgT = "Time(sec): "+ofToString((ofGetElapsedTimeMillis()/1000));
		verdana.drawString(msgT, WIDTH/8, 150);
		
		
	} else if (gameStatus == 2) {
		
		//	ofRect(	//draw rect over background
		
		// draw bg
		bg.draw(-200, 0);
		
		//restart button
		ofSetColor(ofColor::green);
		ofCircle(WIDTH/3, HEIGHT/2, 75);
		// (ballX >= ofGetWidth() || ballX <= 0 )
		
		ofSetColor(ofColor::black);
		verdana.loadFont(ofToDataPath("verdana.ttf"), 20);
		string msgR = "Restart";
		verdana.drawString(msgR, ((WIDTH/3)-55), (HEIGHT/2)+10);
		
		// use code for restart button
		int distFromRestartCircle = ofDist(WIDTH/3, HEIGHT/2, hand.x, hand.y);
		
		if (distFromRestartCircle < 75) {
			gameStatus = 0; // set start screen
			score = 0; //reset score
			//reset timer
		}
		
		//quit button
		ofSetColor(ofColor::red);
		ofCircle(WIDTH/.99, HEIGHT/2, 75);
		
		ofSetColor(ofColor::black);
		verdana.loadFont(ofToDataPath("verdana.ttf"), 20);
		string msgQ = "Quit";
		verdana.drawString(msgQ, ((WIDTH/.99)-35), (HEIGHT/2)+10);
		
		//quit button
		int distFromQuitCircle = ofDist(WIDTH/.99, HEIGHT/2, hand.x, hand.y);
		
		if (distFromQuitCircle < 75) {
			//gameStatus = 1; //set play screen
            score = 0; //reset the score?
			bg.draw(-200, 0);
			
			ofSetColor(ofColor::red);
			verdana.loadFont(ofToDataPath("verdana.ttf"), 80);
			string msgG = "Game Over!";
			verdana.drawString(msgG, (WIDTH/8), HEIGHT/2);
			
		}
		
		ofSetColor(ofColor::aquamarine);
		verdana.loadFont(ofToDataPath("verdana.ttf"), 50);
		string msgF = "Final Score:"+ofToString(score);
		verdana.drawString(msgF, (WIDTH/3)-25, 100);	//final score
		//draw game over screen with final score
	}
}
示例#27
0
void ofxGuiMatrix::draw()
{
	glPushMatrix();
	
	glTranslatef(mObjX, mObjY, 0.0f);
	
	if(mParamName != "")
		drawParamString(0.0, 0.0, mParamName + ": " + ofToString(mValue), false);
	
	ofFill();
	
	//	background
	glColor4f(mGlobals->mCoverColor.r, mGlobals->mCoverColor.g, mGlobals->mCoverColor.b, mGlobals->mCoverColor.a);
	ofRect(mCtrX, mCtrY, mCtrWidth, mCtrHeight);
	
	ofNoFill();

	//	pads
	glColor4f(mGlobals->mFrameColor.r, mGlobals->mFrameColor.g, mGlobals->mFrameColor.b, mGlobals->mFrameColor.a);
	
	int		s	= mSpacing / 2;
	float	x	= mCtrX + s;
	float	y	= mCtrY + s;
	float	w	= (mCtrWidth - mSpacing) / mXGrid;
	float	h	= (mCtrHeight - mSpacing) / mYGrid;
	
	for(int i = 0; i < mYGrid; i++)
	{
		for(int j = 0; j < mXGrid; j++)
		{
			int index = j + (i * mXGrid);
			
			if((mBuffer[index] & kofxGui_Matrix_Set) == kofxGui_Matrix_Set)
			{
				ofFill();
				glColor4f(mGlobals->mButtonColor.r, mGlobals->mButtonColor.g, mGlobals->mButtonColor.b, mGlobals->mButtonColor.a);
				ofRect(x + s, y + s, w - mSpacing, h - mSpacing);
			}
			
			if((mBuffer[index] & kofxGui_Matrix_Selected) == kofxGui_Matrix_Selected)
			{
				ofNoFill();
				glColor4f(mGlobals->mMatrixColor.r, mGlobals->mMatrixColor.g, mGlobals->mMatrixColor.b, mGlobals->mMatrixColor.a);
				ofRect(x + s, y + s, w - mSpacing, h - mSpacing);
			}
			else if(mValue == index)
			{
				ofNoFill();
				glColor4f(mGlobals->mAxisColor.r, mGlobals->mAxisColor.g, mGlobals->mAxisColor.b, mGlobals->mAxisColor.a);
				ofRect(x + s, y + s, w - mSpacing, h - mSpacing);
			}
			else
			{
				ofNoFill();
				glColor4f(mGlobals->mFrameColor.r, mGlobals->mFrameColor.g, mGlobals->mFrameColor.b, mGlobals->mFrameColor.a);
				ofRect(x + s, y + s, w - mSpacing, h - mSpacing);
			}
			
			x += w;
		}
		
		y += h;
		x  = mCtrX + s;
	}
		
	//	frame
	glColor4f(mGlobals->mFrameColor.r, mGlobals->mFrameColor.g, mGlobals->mFrameColor.b, mGlobals->mFrameColor.a);
	ofRect(mCtrX, mCtrY, mCtrWidth, mCtrHeight);
	
	glPopMatrix();
}
示例#28
0
void ofxTLCurves::drawModalContent(){
	
	//****** DRAW EASING CONTROLS
	if(!drawingEasingWindow){
    	return;
    }
	
    ofxTLTweenKeyframe* tweenFrame = (ofxTLTweenKeyframe*) selectedKeyframe;
	if(tweenFrame == NULL){
		if(selectedKeyframes.size() == 0){
			return;
		}
		tweenFrame = (ofxTLTweenKeyframe*)selectedKeyframes[0];
	}
	
	for(int i = 0; i < easingTypes.size(); i++){
        //TODO turn into something like selectionContainsEaseType();
        //so that we can show the multi-selected easies
        if(easingTypes[i] ==  ((ofxTLTweenKeyframe*)selectedKeyframes[0])->easeType){
            ofSetColor(150, 100, 10);
        }
        else{
            ofSetColor(80, 80, 80);
        }
        ofFill();
        ofRect(easingWindowPosition.x + easingTypes[i]->bounds.x, easingWindowPosition.y + easingTypes[i]->bounds.y,
               easingTypes[i]->bounds.width, easingTypes[i]->bounds.height);
        ofSetColor(200, 200, 200);
        timeline->getFont().drawString(easingTypes[i]->name,
									   easingWindowPosition.x + easingTypes[i]->bounds.x+11,
									   easingWindowPosition.y + easingTypes[i]->bounds.y+10);
        ofNoFill();
        ofSetColor(40, 40, 40);
        ofRect(easingWindowPosition.x + easingTypes[i]->bounds.x,
               easingWindowPosition.y + easingTypes[i]->bounds.y,
               easingTypes[i]->bounds.width, easingTypes[i]->bounds.height);
    }

    for(int i = 0; i < easingFunctions.size(); i++){
        //TODO: turn into something like selectionContainsEaseFunc();
        if(easingFunctions[i] == tweenFrame->easeFunc){
            ofSetColor(150, 100, 10);
        }
        else{
            ofSetColor(80, 80, 80);
        }
        ofFill();
        ofRect(easingWindowPosition.x + easingFunctions[i]->bounds.x, easingWindowPosition.y +easingFunctions[i]->bounds.y, 
               easingFunctions[i]->bounds.width, easingFunctions[i]->bounds.height);
        ofSetColor(200, 200, 200);
//        timeline->getFont().drawString(easingFunctions[i]->name,
//                           easingWindowPosition.x + easingFunctions[i]->bounds.x+10, 
//                           easingWindowPosition.y + easingFunctions[i]->bounds.y+15);			
		ofPushMatrix();
		ofTranslate(easingWindowPosition.x + easingFunctions[i]->bounds.x,
					easingWindowPosition.y + easingFunctions[i]->bounds.y);
		if(tweenFrame->easeType->type == ofxTween::easeIn){
			easingFunctions[i]->easeInPreview.draw();
		}
		else if(tweenFrame->easeType->type == ofxTween::easeOut){
			easingFunctions[i]->easeOutPreview.draw();
		}
		else {
			easingFunctions[i]->easeInOutPreview.draw();
		}
		
		ofPopMatrix();
        ofNoFill();
        ofSetColor(40, 40, 40);
        ofRect(easingWindowPosition.x + easingFunctions[i]->bounds.x, easingWindowPosition.y +easingFunctions[i]->bounds.y, 
               easingFunctions[i]->bounds.width, easingFunctions[i]->bounds.height);	
    }
    
}
示例#29
0
//--------------------------------------------------------------
void testApp::draw(){
    ofBackground(10);
    
    int nVerts = 0;
    
    
    ofNoFill();
    ofRectangle rect = verdana200.getStringBoundingBox(text, 0,0);

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

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

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

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

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

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

    ofPopMatrix();
    

    
}
//------------------------------------------------------------------
void demoParticle::drawp(){

	ofNoFill ();
	ofSetColor(103, 160, 237);
	//ofEllipse (ofGetMouseX(), ofGetMouseY(), 40, 40);
	ofVec2f Xaxix; Xaxix.set(1,0);
	float heading = -vel.angle(ofVec2f(1,0));
	heading = heading - PI/2;
	//float theta = vel.angle(Xaxix)-PI/2;
    ofFill();
	ofSetColor(103, 160, 237);

    ofPushMatrix();
    ofTranslate(pos.x,pos.y);
    ofRotateZ(heading);
    ofScale(2,2);

	ofSetColor(0);
    ofFill();
	ofSetColor(103, 160, 237);

    ofRect( -14, 0, 28, 14);

    ofSetColor(0);
    ofFill();
	ofSetColor(0, 128, 0);

    ofEllipse( -14, 0, 10, 10 );  // left wheel
    ofEllipse( -14, 14, 10, 10 ); // right wheel

    /** Experimental Feature */

//    ofFill();
//	ofSetColor(255,0,0);
//
//	if(blink>-90&&blink<=90)
//		ofEllipse( -14, 0, 10, 10 );  // left wheel
//	else  ofEllipse( -14, 14, 10, 10 ); // right wheel

	///


    // show the sensor/wheel connections
    ofNoFill();
	if (mode == aggressive || mode == fear) ofSetColor(0, 128, 0);
	else ofSetColor(128, 0, 0);
    if (mode == templove|| mode == fear) ofBezier(-7*2, 0,  0, 3*2, 0, 3*2, 7*2, 0);
    else ofBezier(-7*2, 0,  0, 5*2, 0, 5*2, 7*2, 7*2);
    
    
    if (mode == templove || mode == fear) ofBezier(-7*2, 7*2,  0, 4*2, 0, 4*2, 7*2, 7*2);
    else ofBezier(-7*2, 7*2, 0, 2*2, 0, 2*2, 7*2, 0);

	ofSetColor(255, 255, 255);
    ofBezier(7*2+7,5,  7*2, 0, 7*2, 0, 7*2+7, -5);
	ofBezier(7*2+7,5+7*2,  7*2, 7*2, 7*2,7*2,  7*2+7, 7*2 -5);
	path.arc(7, 0,  5, 5, PI/2, PI/2+PI);
    path.arc(7, 7, 5, 5, PI/2, PI/2+PI);  


    ofPopMatrix();
}