Exemplo n.º 1
0
ofPixels_<PixelType> ofPixels_<PixelType>::getPlane(int planeIdx){
	planeIdx = ofClamp(planeIdx,0,getNumPlanes());
	ofPixels_<PixelType> plane;
	switch(pixelFormat){
		case OF_PIXELS_RGB:
		case OF_PIXELS_BGR:
		case OF_PIXELS_RGB565:
		case OF_PIXELS_RGBA:
		case OF_PIXELS_BGRA:
		case OF_PIXELS_GRAY:
		case OF_PIXELS_YUY2:
		case OF_PIXELS_UYVY:
			plane.setFromExternalPixels(pixels,width,height,pixelFormat);
			break;
		case OF_PIXELS_NV12:
			switch(planeIdx){
			case 0:
				plane.setFromExternalPixels(pixels,width,height,OF_PIXELS_Y);
				break;
			case 1:
				plane.setFromExternalPixels(pixels+width*height,width/2,height/2,OF_PIXELS_UV);
				break;
			}
			break;
		case OF_PIXELS_NV21:
			switch(planeIdx){
			case 0:
				plane.setFromExternalPixels(pixels,width,height,OF_PIXELS_Y);
				break;
			case 1:
				plane.setFromExternalPixels(pixels+width*height,width/2,height/2,OF_PIXELS_VU);
				break;
			}
			break;
		case OF_PIXELS_YV12:
			switch(planeIdx){
			case 0:
				plane.setFromExternalPixels(pixels,width,height,OF_PIXELS_Y);
				break;
			case 1:
				plane.setFromExternalPixels(pixels+width*height,width/2,height/2,OF_PIXELS_V);
				break;
			case 2:
				plane.setFromExternalPixels(pixels+int(width*height+width/2*height/2),width/2,height/2,OF_PIXELS_U);
				break;
			}
			break;
		case OF_PIXELS_I420:
			switch(planeIdx){
			case 0:
				plane.setFromExternalPixels(pixels,width,height,OF_PIXELS_Y);
				break;
			case 1:
				plane.setFromExternalPixels(pixels+width*height,width/2,height/2,OF_PIXELS_U);
				break;
			case 2:
				plane.setFromExternalPixels(pixels+int(width*height+width/2*height/2),width/2,height/2,OF_PIXELS_V);
				break;
			}
			break;
		default:
			break;
	}
	return plane;
}
Exemplo n.º 2
0
//--------------------------------------------------------------
void testApp::update(){
    float elapsed = (ofGetElapsedTimef() - startTime);
    
    switch (status) {
        case VISIBLE:
            
            break;
        
        case FORWARD:
            if (elapsed > maxDuration) {
                vector<ofVec3f> verts = mesh.getVertices();
                for (vector<ofVec3f>::iterator it=verts.begin(); it!=verts.end(); ++it) {
                    it->x = clickedPosition.x;
                    it->y = clickedPosition.y;
                }
                status = INVISIBLE;
                break;
            }
            for (int y=0; y<rows; ++y) {
                for (int x=0; x<cols; ++x) {
                    for (int i=0; i<6; ++i) {
                        int index = 6*(y*cols+x) + i;
                        ControlPoint p = controlPoints[index];
                        float easedValue = easingForward(ofClamp(elapsed / p.getDuration(), 0.0, 1.0));
                        ofVec3f v;
                        
                        v.x = p.x + easedValue*(clickedPosition.x - p.x);
                        v.y = p.y + easedValue*(clickedPosition.y - p.y);
                        v.z = 0;
                        
                        mesh.setVertex(index, v);
                    }
                }
            }
            break;
            
        case INVISIBLE:
            break;
            
        case BACKWARD:
            if (elapsed > maxDuration) {
                vector<ofVec3f> verts = mesh.getVertices();
                for(int i=0; i<verts.size(); ++i) {
                    verts[i].x = controlPoints[i].x;
                    verts[i].y = controlPoints[i].y;
                }

                status = VISIBLE;
                break;
            }
            for (int y=0; y<rows; ++y) {
                for (int x=0; x<cols; ++x) {
                    for (int i=0; i<6; ++i) {
                        int index = 6*(y*cols+x) + i;
                        ControlPoint p = controlPoints[index];
                        float easedValue = easingBackward(ofClamp(elapsed / p.getDuration(), 0.0, 1.0));
                        ofVec3f v;
                        
                        v.x = clickedPosition.x + easedValue*(p.x - clickedPosition.x);
                        v.y = clickedPosition.y + easedValue*(p.y - clickedPosition.y);
                        v.z = 0;
                        
                        mesh.setVertex(index, v);
                    }
                }
            }
            break;
    }
}
Exemplo n.º 3
0
		//----------
		void Crossfader::setPosition(float position) {
			this->position = ofClamp(position, -1.0f, 1.0f);
			this->autoFade = AutoFade_None;
		}
Exemplo n.º 4
0
//--------------------------------------------------------------
void testApp::draw(){
	ofBackground(0);
	
	string s = string("") + 
	"\n" + 
	"Purple boxes (4 of them) are generic nodes with simple circular motion, linked in a hierarchy (with ofNode::setParent).\n" + 
	"Yellow boxes (2 of them) are cameras. You are looking through one of them so can only see one box on screen.\n" + 
	"\n" + 
	"KEYS:\n" + 
	"\n" + 
	"z reset transforms\n" + 
	"\n" + 
	"v switch camera to view: " + ofToString(camToView) + "\n" +
	"\n" + 
	
	"o toggle mouse orbit for cam\n" + 
	
	"\n" + 
	"c switch camera to configure: " + ofToString(camToConfigure) + "\n" +
	" t cycle lookat\n" + 
	" p cycle parent\n" +
	" LEFT pan left\n" + 
	" RIGHT pan right\n" + 
	" UP tilt up\n" + 
	" DOWN tilt down\n" + 
	" , roll left\n" + 
	" . roll right\n" + 
	" a truck left\n" + 
	" d truck right\n" + 
	" w dolly forward\n" + 
	" s dolly backward\n" + 
	" r boom up\n" + 
	" f boom down\n";
	glDisable(GL_CULL_FACE);
	ofSetColor(255);
	ofDisableLighting();
	ofDrawBitmapString(s, ofPoint(20, 20));
	
	glEnable(GL_CULL_FACE);
	ofEnableLighting();
	// update camera transforms
	for(int i=0; i<kNumCameras; i++) {
		
		// lookat node if it has one
		if(lookatIndex[i] >= 0) cam[i].lookAt(testNodes[lookatIndex[i]]);
		
		// mouse orbit camera
		if(doMouseOrbit[i] && ofGetMousePressed(0)) {
			static float lon = 0;
			static float lat = 0;
			
			lon = ofClamp(lon + mouseX - ofGetPreviousMouseX(), -180, 180);
			lat = ofClamp(lat + mouseY - ofGetPreviousMouseY(), -90, 90);
			
			if(lookatIndex[i] < 0) {
				cam[i].orbit(lon, lat, orbitRadius);
			} else {
				cam[i].orbit(lon, lat, orbitRadius, testNodes[lookatIndex[1]]);
			}
		}
		
	} 
	
	// activate camera
	cam[camToView].begin();
	
	
	// draw world axis
	ofDrawAxis(100);
	
	// draw testNodes
	for(int i=0; i<kNumTestNodes; i++) {
		ofSetColor(255, 128, 255);
		testNodes[i].draw();
	}
	
	// draw cameras
	for(int i=0; i<kNumCameras; i++) {
		ofSetColor(255, 255, 0);
		cam[i].draw();
		
		// draw line from cam to its lookat
		if(lookatIndex[i] >= 0) {
			ofSetColor(0, 255, 255);
			glBegin(GL_LINES);
			ofVec3f v1 = cam[i].getGlobalPosition();
			ofVec3f v2 = testNodes[lookatIndex[i]].getGlobalPosition();
			glVertex3f(v1.x, v1.y, v1.z);
			glVertex3f(v2.x, v2.y, v2.z);
			glEnd();
		}
		
		// draw line from cam to its parent
		if(parentIndex[i] >= 0) {
			ofSetColor(255, 255, 0);
			glBegin(GL_LINES);
			ofVec3f v1 = cam[i].getGlobalPosition();
			ofVec3f v2 = testNodes[parentIndex[i]].getGlobalPosition();
			glVertex3f(v1.x, v1.y, v1.z);
			glVertex3f(v2.x, v2.y, v2.z);
			glEnd();
		}
	}
	
	// restore view to previous state (default openFrameworks view)
	cam[camToView].end();
}
Exemplo n.º 5
0
//--------------------------------------------------
float ofNormalize(float value, float min, float max){
	return ofClamp( (value - min) / (max - min), 0, 1);
}
ofxAssimpAnimation & ofxAssimpModelLoader::getAnimation(int animationIndex) {
    animationIndex = ofClamp(animationIndex, 0, animations.size()-1);
    return animations[animationIndex];
}
ofxAssimpMeshHelper & ofxAssimpModelLoader::getMeshHelper(int meshIndex) {
    meshIndex = ofClamp(meshIndex, 0, modelMeshes.size()-1);
    return modelMeshes[meshIndex];
}
Exemplo n.º 8
0
//--------------------------------------------------------------
void ofApp::keyPressed(int key){
    switch (key) {
        case ' ':
            bThreshWithOpenCV = !bThreshWithOpenCV;
            break;
            
        case'p':
            bDrawPointCloud = !bDrawPointCloud;
            break;
            
        case '>':
        case '.':
            farThreshold ++;
            if (farThreshold > 255) farThreshold = 255;
            break;
            
        case '<':
        case ',':
            farThreshold --;
            if (farThreshold < 0) farThreshold = 0;
            break;
            
        case '+':
        case '=':
            nearThreshold ++;
            if (nearThreshold > 255) nearThreshold = 255;
            break;
            
        case '-':
            nearThreshold --;
            if (nearThreshold < 0) nearThreshold = 0;
            break;
            
        case 'w':
            kinect.enableDepthNearValueWhite(!kinect.isDepthNearValueWhite());
            break;
            
        case 'o':
            kinect.setCameraTiltAngle(angle); // go back to prev tilt
            kinect.open();
            break;
            
        case 'c':
            kinect.setCameraTiltAngle(0); // zero the tilt
            kinect.close();
            break;
            
        case '1':
            kinect.setLed(ofxKinect::LED_GREEN);
            break;
            
        case '2':
            kinect.setLed(ofxKinect::LED_YELLOW);
            break;
            
        case '3':
            kinect.setLed(ofxKinect::LED_RED);
            break;
            
        case '4':
            kinect.setLed(ofxKinect::LED_BLINK_GREEN);
            break;
            
        case '5':
            kinect.setLed(ofxKinect::LED_BLINK_YELLOW_RED);
            break;
            
        case '0':
            kinect.setLed(ofxKinect::LED_OFF);
            break;
            
        case OF_KEY_UP:
            angle++;
            if(angle>30) angle=30;
            kinect.setCameraTiltAngle(angle);
            break;
            
        case OF_KEY_DOWN:
            angle--;
            if(angle<-30) angle=-30;
            kinect.setCameraTiltAngle(angle);
            break;
        case OF_KEY_RIGHT:
            currentFace++;
            break;
        case OF_KEY_LEFT:
            currentFace--;
            break;
    }
    
    currentFace = ofClamp(currentFace,0,faces.size());
    if(faces.size()!=0){
        loadFace(faces.getPath(currentFace));
    }

}
Exemplo n.º 9
0
void ofxSimpleGuiComboBox::setValue(int index) {
	m_selectedChoice = ofClamp(index, 0, m_choices.size());
}
Exemplo n.º 10
0
void ofxSlitScan::setTimeWidth(int _timeWidth){
	timeWidth = ofClamp(_timeWidth, 1, capacity - timeDelay);
	outputIsDirty = true;
}
Exemplo n.º 11
0
void Counter::update(){
	Model::update();
	Poco::Timespan span(ofClamp(70000000-(long)audioClock->getElapsedTimeMicros(),0,70000000));
	now = Poco::DateTimeFormatter::format(span,"%M %S %i");
}
Exemplo n.º 12
0
void ofxSlitScan::setTimeDelay(int _timeDelay){
	timeDelay = ofClamp(_timeDelay, 0, capacity - timeWidth - 1);
	outputIsDirty = true;
}
Exemplo n.º 13
0
ofVec3f BoundsController::clampPoint(const ofVec3f &position) const {
  float bound = _params.size.get() / 2;
  return ofVec3f(ofClamp(position.x, -bound, bound),
                 ofClamp(position.y, -bound, bound),
                 ofClamp(position.z, -bound, bound));
}
Exemplo n.º 14
0
void VideoManager::setVideoPath() {
    int curVidIndex = ofClamp(videoSelect, 0, videoPaths.size() - 1);
    
    curVideo = videoPaths[curVidIndex];
}
//------------------------------------
ofColor ofxKinect::getCalibratedColorAt(int x, int y){
	ofxVec3f texcoord3d;
	texcoord3d.set(x,y,0);
	texcoord3d = rgbDepthMatrix * texcoord3d;
	return getColorAt(ofClamp(texcoord3d.x,0,640),ofClamp(texcoord3d.y,0,480));
}
//--------------------------------------------------------------
void ofxEasyFboGlitch::setGlichResetProbability (float _probability){
    glitchResetProbability=ofClamp(_probability,0,1);;
}
Exemplo n.º 17
0
//--------------------------------------------------------------
void testApp::moveThreshold(int distance){ 
	decoder.setThreshold(ofClamp((int)decoder.getThreshold() + distance, 0, 255));
	ofLogNotice() << "Threshold set at " << (int)decoder.getThreshold();
}
Exemplo n.º 18
0
//-----------------------------------------------
bool guiTypePanel::selectColumn(int which){
	col = ofClamp(which, 0, columns.size()-1);
	return true;
}
// DEPRECATED.
void ofxAssimpModelLoader::setAnimation(int animationIndex) {
    if(!hasAnimations()) {
        return;
    }
    currentAnimation = ofClamp(animationIndex, 0, getAnimationCount() - 1);
}
Exemplo n.º 20
0
void SmartViewportManager::setviewportPreviewAlpha(int previewAlpha){
    viewportPreviewAlpha = (int)ofClamp(viewportPreviewAlpha, 0, 255);
}
Exemplo n.º 21
0
void ofxGSTT::setVolumeThreshold(float volumeThreshold){
	this->volumeThreshold = ofClamp(volumeThreshold,0,1);
}
Exemplo n.º 22
0
void XBScene1::drawPiano()
{
    XBScene1GUI *myGUI = (XBScene1GUI *) gui;
    // draw expanding stones from piano
    for (int i = 0; i < stonesToDraw.size(); i++) {
        expandingPolyLine &e = stonesToDraw[i];
        ofPushMatrix();
        ofTranslate(e.centroid);
        //             ofScale(e.life * myGUI->stoneGrowFactor, e.life * myGUI->stoneGrowFactor);
        ofScale(1 + e.amplitude * sin(myGUI->stoneFrequency * e.life),
                1 + e.amplitude * sin(myGUI->stoneFrequency * e.life));
        e.path.setFillColor(ofColor(myGUI->rgbColorPianoR, myGUI->rgbColorPianoG, myGUI->rgbColorPianoB, ofClamp(myGUI->colorPianoA - e.life * myGUI->stoneAlphaDecrease, 0, 255)));
        e.path.draw();
        ofPopMatrix();
    }
}
Exemplo n.º 23
0
void MantaController::drawStats(int x, int y, int w)
{
    int h = w * 310.0 / 400.0;
    statsDrawRect = ofRectangle(x, y, w, h);
    
    ofPushStyle();
    ofPushMatrix();
    
    ofTranslate(x, y);
    
    ofSetColor(0);
    ofFill();
    ofRect(0, 0, w, h);
    
    // draw convex hull
    ofNoFill();
    ofSetColor(0, 255, 0);
    ofSetLineWidth(1);
    ofBeginShape();
    for (int i=0; i<fingersHull.size(); i++)
    {
        float x = ofMap(fingersHull[i].x, 0, 1, 0, w);
        float y = ofMap(fingersHull[i].y, 0, 1, 0, h);
        ofVertex(x, y);
    }
    ofEndShape();
    
    // draw fingers
    ofFill();
    ofSetColor(255, 0, 0);
    ofSetLineWidth(0);
    for (int i=0; i<fingers.size(); i++)
    {
        float x = ofMap(fingers[i].x, 0, 1, 0, w);
        float y = ofMap(fingers[i].y, 0, 1, 0, h);
        float r = ofMap(fingerValues[i], 0, 196, 0, 10);
        ofCircle(x, y, r);
    }
    
    // draw centroids
    float cx = ofMap(centroidX, 0, 1, 0, w);
    float cy = ofMap(centroidY, 0, 1, 0, h);
    float wcx = ofMap(weightedCentroidX, 0, 1, 0, w);
    float wcy = ofMap(weightedCentroidY, 0, 1, 0, h);
    ofNoFill();
    ofSetColor(150);
    ofSetLineWidth(2);
    ofLine(cx-4, cy-4, cx+4, cy+4);
    ofLine(cx+4, cy-4, cx-4, cy+4);
    ofSetColor(255);
    ofLine(wcx-4, wcy-4, wcx+4, wcy+4);
    ofLine(wcx+4, wcy-4, wcx-4, wcy+4);
    
    // draw stats
    ofSetColor(255);
    ofDrawBitmapString("pad sum", 3, 12);
    ofDrawBitmapString("pad avg", 3, 28);
    ofDrawBitmapString("perimeter", 3, 44);
    ofDrawBitmapString("bw fingers", 3, 60);
    ofSetColor(0, 255, 0);
    ofSetLineWidth(0);
    ofFill();
    ofRect(75,  1, ofClamp(ofMap(padSum, 0, 1024, 0, w-80), 0, w-80), 14);
    ofRect(75, 17, ofClamp(ofMap(padAverage, 0, 196, 0, w-80), 0, w-80), 14);
    ofRect(75, 33, ofClamp(ofMap(perimeter, 0, 2, 0, w-80), 0, w-80), 14);
    ofRect(75, 49, ofClamp(ofMap(averageInterFingerDistance, 0, 1, 0, w-80), 0, w-80), 14);
    
    ofPopMatrix();
    ofPopStyle();
}
Exemplo n.º 24
0
void XBScene1::drawWindows()
{
    XBScene1GUI *myGUI = (XBScene1GUI *) gui;
    // if cello is under a window, paint it
    if (fakeCelloEvent || celloEnergy > energyThreshold) {
        for (int i = 0; i < windowsOutlines.size(); i++) {
            if (windowsOutlines[i].inside(xEmitter.positionStart)) {
                if(celloInsideWindow != i)
                    celloWindowAlpha = 0;
                else
                    celloWindowAlpha+= myGUI->windowAttack;
                if(celloWindowAlpha > 1) celloWindowAlpha = 1;
                ofPushStyle();
                ofSetLineWidth(myGUI->windowOutlineWidth);
                ofSetColor(ofColor(myGUI->rgbColorCelloR, myGUI->rgbColorCelloG, myGUI->rgbColorCelloB, myGUI->colorCelloA * celloWindowAlpha));
                windowsOutlines[i].draw();
                ofPopStyle();
                //                    if(celloInsideWindow != -1 && celloInsideWindow != i)
                //    cout << "Fade en otra ventana" << endl;
                celloInsideWindow = i;
                break;
            }
            // reached the end of the loop, wich means is not under any window
            if (i == windowsOutlines.size() - 1) {
                if (celloInsideWindow > -1)
                    addFadingWindow(celloInsideWindow, fadingCelloWindowsToDraw, celloWindowAlpha, myGUI->colorCelloA);
                celloInsideWindow = -1;
            }
        }
    }
    else {
        if (celloInsideWindow > -1)
            addFadingWindow(celloInsideWindow, fadingCelloWindowsToDraw, celloWindowAlpha, myGUI->colorCelloA);
        celloInsideWindow = -1;
    }

    // if violin is under a window, paint it
    if (fakeEvent || violinEnergy > energyThreshold) {
        for (int i = 0; i < windowsOutlines.size(); i++) {
            if (windowsOutlines[i].inside(vEmitter.positionStart)) {
                if(violinInsideWindow != i)
                    violinWindowAlpha = 0;
                else
                    violinWindowAlpha+= myGUI->windowAttack;
                if(violinWindowAlpha > 1) violinWindowAlpha = 1;
                ofPushStyle();
                ofSetLineWidth(myGUI->windowOutlineWidth);
                ofSetColor(ofColor(myGUI->rgbColorViolinR, myGUI->rgbColorViolinG, myGUI->rgbColorViolinB, myGUI->colorViolinA * violinWindowAlpha));
                windowsOutlines[i].draw();
                ofPopStyle();
                violinInsideWindow = i;
                break;
            }
            // reached the end of the loop, wich means is not under any window
            if (i == windowsOutlines.size() - 1) {
                if (violinInsideWindow > -1) {
                    addFadingWindow(violinInsideWindow, fadingViolinWindowsToDraw, violinWindowAlpha, myGUI->colorViolinA);
                }
                violinInsideWindow = -1;
            }
        }
    }
    else {
        if (violinInsideWindow > -1)
            addFadingWindow(violinInsideWindow, fadingViolinWindowsToDraw, violinWindowAlpha, myGUI->colorViolinA);
        violinInsideWindow = -1;
    }

//    draw fading window outlines
    ofPushStyle();
    ofSetLineWidth(myGUI->windowOutlineWidth);
    for (int i = 0; i < fadingViolinWindowsToDraw.size(); i++) {
        expandingPolyLine &e = fadingViolinWindowsToDraw[i];
        ofSetColor(ofColor(myGUI->rgbColorViolinR, myGUI->rgbColorViolinG, myGUI->rgbColorViolinB, ofClamp(myGUI->colorViolinA - e.life * myGUI->windowFade, 0, 255)));
        e.line.draw();
    }

    for (int i = 0; i < fadingCelloWindowsToDraw.size(); i++) {
        expandingPolyLine &e = fadingCelloWindowsToDraw[i];
        ofSetColor(ofColor(myGUI->rgbColorCelloR, myGUI->rgbColorCelloG, myGUI->rgbColorCelloB, ofClamp(myGUI->colorCelloA - e.life * myGUI->windowFade, 0, 255)));
        e.line.draw();
    }
    ofPopStyle();
}
Exemplo n.º 25
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(bounds.x, 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 = millisToScreenX(hoverTime);
		text = timeline->formatTime(hoverTime);
		textW = timeline->getFont().stringWidth(text)+3;
        if(bounds.height > 2){
            int previewTimecodeX = ofClamp(screenX+5, bounds.x, bounds.x+bounds.width-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
    //TIMECODE
    int currentFrameX;
    if (timeline->getIsFrameBased()) {
        text = ofToString(timeline->getCurrentFrame());
        currentFrameX = screenXForIndex(timeline->getCurrentFrame());
    }
    else{
        text = timeline->formatTime(timeline->getCurrentTime());
        currentFrameX = screenXForTime(timeline->getCurrentTime());
    }
    
    if(bounds.height > 2){
        int timeCodeX = ofClamp(currentFrameX+5, bounds.x, bounds.x+bounds.width-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();
}
Exemplo n.º 26
0
void Bike::draw(){
    
    float imageScaleDown = 0.35;
    ofPoint frontWheel(25 * imageScaleDown, 326 * imageScaleDown);
    ofPoint backWheel(768 * imageScaleDown, 326 * imageScaleDown);
    
    if(animateBike){
        
        ofPushMatrix();{
            
            
            ofTranslate(pos);
            
            if(flip){
                ofTranslate(bike -> width * 0.5 * scale, -bike -> height * 0.62 * scale);
                ofScale(-1, 1);
            } else {
                ofTranslate(-bike -> width * 0.5 * scale, -bike -> height * 0.62 * scale);
            }
            
            
            ofScale(scale, scale);
            
            //Add an extra translate so the reference position is below the rear wheel
            //i.e. where the dust will be coming from
            ofRotate(bikePitch);
            //        ofTranslate( -backWheel.x, -backWheel.y - wheel -> height * 0.42);
            
            //translate to front wheel and draw
            ofPushMatrix();{
                ofTranslate(-bike -> width * 0.48, bike -> height * 0.25);
                ofRotate(wheelAngle);
                ofSetColor(255);
                wheel -> draw(0, 0);
            }ofPopMatrix();
            
            //translate to back wheel and draw
            ofPushMatrix();{
                ofTranslate(bike -> width * 0.45, bike -> height * 0.25);
                ofRotate(wheelAngle);
                wheel -> draw(0, 0);
            }ofPopMatrix();
            
            ofSetColor(col);
            bike -> draw(-bike -> width/2, -bike -> height/2);
            
            
            
        }ofPopMatrix();
        
        
        //draw the regular dust
        for(int i = 0; i < dustList.size(); i++){
            dustList[i].draw();
        }
    }

    
    
    //draw the letter dust
    if(segment == 2 && pos.x < ofGetWindowWidth() - 100){
        for(vector<LetterDust>::iterator it = letterDust -> begin(); it != letterDust -> begin() + ofClamp(dustToRelease, 0, letterDust -> size()); it++){
            it -> draw();
        }        
    }
    
}
Exemplo n.º 27
0
void QuadWarp::setCorner(ofPoint p, int cornerIndex) {
    cornerIndex = ofClamp(cornerIndex, 0, 3);
    dstPoints[cornerIndex].set(p);
}
Exemplo n.º 28
0
void Bike::update(){


    if(segment == 0){
        
        vel.set(-6, 0);
        groundLevel = 740;
        scale = 0.4;
        drawBehind = true;
        flip = false;
        
        if(pos.x < -500){
            segment++;
        }
        
    } else if(segment == 1){
        
        vel.set(10, 0);
        groundLevel = 770;
        scale = 0.8;
        drawBehind = false;
        flip = true;
        
        if(pos.x > ofGetWindowWidth() + 700){
            segment++;
        }
        
    } else if(segment == 2){
        
        
        vel.set(-12, 0);
        groundLevel = 850;
        scale = 1.8;
        drawBehind = false;
        flip = false;
        
        if(pos.x < -1000){
            animateBike = false;
        }
        
        
        //release a few at a time
        if(ofGetElapsedTimeMillis() - dustReleaseTimer > 50 && dustToRelease < letterDust -> size()){
            dustToRelease += 3;
            dustReleaseTimer = ofGetElapsedTimeMillis();
            
        }
        
        
        //update the letterdust if the bike is past a certain point on screen
        if(pos.x < ofGetWindowWidth() - 100){
            
            for(vector<LetterDust>::iterator it = letterDust -> begin(); it != letterDust -> begin() + ofClamp(dustToRelease, 0, letterDust -> size()); it++){
                
                if(it -> released == false){
                    it -> pos.set(pos);
                    it -> released = true;
                }
                it -> update();
            }

        
        }
        
        
        //go through and see if all the letters have "hit" their spots
        //then make them all leave at once at different rates
        if(letterFall == false){
        
            for(vector<LetterDust>::iterator it = letterDust -> begin(); it != letterDust -> end(); it++){
                if(it -> hit == false){
                    break;
                }
                
                //if we're at the end of the list and we're still
                //checking then make them fall
                if(it == letterDust -> end() - 1){
                    letterFall = true;

                    endTime = ofGetElapsedTimeMillis();
                    
                }
            }

        } else {
            
            if(ofGetElapsedTimeMillis() - endTime > 12000){
                
                //if letterFall is true, go tell each letter to fade and fall away
                for(vector<LetterDust>::iterator it = letterDust -> begin(); it != letterDust -> end(); it++){
                    
                    it -> letterFall = true;
                    
                }

                
            }
            
            if(ofGetElapsedTimeMillis() - endTime > 14000){
                done = true;

            }
            
            
        }
        
        
    }

    
    
    //only move if we're to the right of the stopping area
    if(animateBike){
        
        //add noise to y position
        float amplitudeY = 5;
        if(segment == 2){
            amplitudeY = 3;
        }
        float noiseSpeedY = abs(vel.x) * 0.8;
        float noiseY = ofMap(ofNoise(ofGetElapsedTimef() * noiseSpeedY), 0, 1, -amplitudeY, amplitudeY);
        
        pos.y = groundLevel + noiseY;
        
        float amplitudePitch = amplitudeY/2;
        float noiseSpeedPitch = abs(vel.x) * 0.8;
        bikePitch = ofMap(ofNoise(ofGetElapsedTimef() * noiseSpeedPitch), 0, 1, -amplitudePitch, amplitudePitch);
        
        
        pos += vel;
        vel += acc;
        acc.set(0);
        
        wheelAngle -= wheelSpeed;
        
        
        
        
        
        //update the regular dust
        
        bool moving;
        if(vel.x != 0){
            moving = true;
        } else {
            moving = false;
        }
        
        for(int i = 0; i < dustList.size(); i++){
            dustList[i].update(pos, scale);
        }
    }
    
    
    
    
//    change it so it only updates the regular dust when on screen


    
    
    
}
Exemplo n.º 29
0
void ofxSimpleSlider::setPercent (float p){
	// Set the slider's percentage from the outside. 
	p = ofClamp(p, 0,1);
	percent	= p;
}
Exemplo n.º 30
0
//--------------------------------------------------------------
void ofApp::update(){	
  float dt = ofGetLastFrameTime();

  pRetryBtn->update();  
  pHpBar->update();

  if(bGameRunning)
  {
    randBornEnemy(dt);
    updateEnemies(dt);

    deque<ofPtr<DrawGame::CircleSprite> >::iterator itEnemy;  
    for(itEnemy=Enemies.begin();
      itEnemy!=Enemies.end();
      itEnemy++)
    {
      ofPtr<DrawGame::CircleSprite> En = *itEnemy;     
      if(pPlayer->isSameColor(*En)&&pPlayer->encompass(*En))
      {      
        HP += HPEatAmt;
        eraseEnemy(itEnemy, "Eat");
        break;
      }
      if(!pPlayer->isSameColor(*En)&&En->encompass(*pPlayer))
      {
        eraseEnemy(itEnemy,"Coin");  
        HP+= CoinValue;
        break;
      }     
      if(pPlayer->isSameColor(*En)&&En->encompass(*pPlayer))
      {
        HP-=HPBeatAmt; 
        eraseEnemy(itEnemy,"Beat");        
        if(HP<=0.0f)
        {
          GameOverString = "You're Exhausted!";
          gameOver();           
        }   
        break;
      }    
      if(En->getSize()<25.0f&&En->getbWhite())
      {
        eraseEnemy(itEnemy," ");
        break;
      }
    }

    if(KeysState['a'])
    {
      pPlayer->changeRot(-360.0f*dt);
    }
    else if(KeysState['d'])
    {
      pPlayer->changeRot(360.0f*dt);
    }

    if(MouseKeyState[0])
    {
      HP+= dt*HPIncSpd;     
    }    
  } 
  HP = ofClamp(HP,0,HPMax);

  // 根据是否按住GUI来判断是否显示光标
  bool bPressGUI = GUI_Debug.getShape().inside(
    ofVec2f(ofGetMouseX(),ofGetMouseY()));
  if(bPressGUI&&bShowDebug)
  {
    ofShowCursor();
  }
  else
  {
    ofHideCursor();
  }
  
}