예제 #1
0
void drawMindsetStatus(ofxThinkgearEventArgs& data){
    // ofPushStyle(); // f*****g bug
    ofSetRectMode(OF_RECTMODE_CENTER);
    ofPushMatrix();
    ofTranslate(ofGetWidth() - 100, 100);
    ofFill();
    ofSetCircleResolution(100);
    ofSetColor(0, 0, 0, 128);
    ofCircle(0, 0, 52);
    // Show connection state
    switch (tgState){
        case NONE:
            ofSetColor(0, 0, 0);
            break;
        case CONNECTING:
            ofSetColor(200, 200, 0);
            break;
        case BAD_SIGNAL:
            ofSetColor(200, 0, 0);
            break;
        case READY:
            ofSetColor(0, 200, 0);
            break;
    }
    ofRect(0, 0, 10, 10);
    if (true || tgState == READY){
        // MindSet info pad
        ofSetColor(200, 200, 200);

        float w = smallFont.stringWidth(ofToString(data.raw));
        smallFont.drawString(ofToString(data.raw), -w/2, -38);

        ofSetColor(200+55*(medScore/200), 200, 200);
        ofCircle(20, -20, min(1.0, data.meditation/100.0) * 16);

        ofSetColor(200+55*(attScore/200), 200, 200);
        ofCircle(-20, -20, min(1.0, data.attention/100.0) * 16);

        ofSetColor(200, 200, 200);
        ofRect(40-15*eegData.midGamma.ratio, 0, 30*eegData.midGamma.ratio, 10);
        ofRotate(25.7, 0, 0, 1);
        ofRect(40-15*eegData.lowGamma.ratio, 0, 30*eegData.lowGamma.ratio, 10);
        ofRotate(25.7, 0, 0, 1);
        ofRect(40-15*eegData.highBeta.ratio, 0, 30*eegData.highBeta.ratio, 10);
        ofRotate(25.7, 0, 0, 1);
        ofRect(40-15*eegData.lowBeta.ratio, 0, 30*eegData.lowBeta.ratio, 10);
        ofRotate(25.7, 0, 0, 1);
        ofRect(40-15*eegData.highAlpha.ratio, 0, 30*eegData.highAlpha.ratio, 10);
        ofRotate(25.7, 0, 0, 1);
        ofRect(40-15*eegData.lowAlpha.ratio, 0, 30*eegData.lowAlpha.ratio, 10);
        ofRotate(25.7, 0, 0, 1);
        ofRect(40-15*eegData.theta.ratio, 0, 30*eegData.theta.ratio, 10);
        ofRotate(25.7, 0, 0, 1);
        ofRect(40-15*eegData.delta.ratio, 0, 30*eegData.delta.ratio, 10);
    }
    ofPopMatrix();
    // ofPopStyle(); // f*****g bug
    ofSetRectMode(OF_RECTMODE_CORNER); // f*****g bug
}
예제 #2
0
	// ---------------------------------------------------------------------------------------
	//
	static void drawStringShadowed( ofTrueTypeFont& _font, string _s, float _x, float _y,
								   ofColor _frontColor = ofColor(255,255,255), ofColor _backColor = ofColor(0,0,0) )
	{
		ofSetColor( _backColor );
		_font.drawString( _s, _x + 1, _y + 1 );
		
		ofSetColor( _frontColor );
		_font.drawString( _s, _x, _y );
	}
예제 #3
0
void gpuPictoChar::getFinalTarget(ofTrueTypeFont& font, float fontScale, float res, float rand, vector<float>& data){

    firstIndex = gpuPicto::totalPicto;
    
    charProps cp = font.getCharProps(c);
    
    float lineHeight = font.getLineHeight() * fontScale;
    float setWidth   = cp.setWidth * fontScale;
    //float height     = cp.height;
    //float topExtent  = cp.topExtent;
    //float width      = cp.width;
    //float leftExtent = cp.leftExtent;
    
    int pixW = setWidth;
    int pixH = lineHeight * 1.5;
    
//    printf("\n%c\nwidth= %0.1f\nsetWidth= %0.1f\nheight= %0.1f\ntopExtent= %0.1f\nleftExtent%0.1f\n",
//    c, w, fw, fh, te, le);
    
//    ofFbo * fbo = new ofFbo();
    {
        fbo.allocate(pixW, pixH);
        fbo.begin();
        ofFill();
        ofSetColor(0, 0, 0);
        ofRect(0, 0, pixW, pixH);
        ofSetColor(250, 0, 0);
        ofScale(fontScale, fontScale);
        font.drawStringAsShapes(ofToString(c), 0, lineHeight*1.2/fontScale);
        fbo.end();
    }
    
    ofPixels pix;
    ofTexture tex;
    pix.allocate(pixW, pixH, OF_PIXELS_RGBA);
    tex.allocate(pix);
    fbo.readToPixels(pix);
    tex.loadData(pix);
    
    int count = 0;
    for(int sy=res/2; sy<pixH; sy+=res){
        for(int sx=res/2; sx<pixW; sx+=res){
            ofColor col = pix.getColor(sx, sy);
            if(col.r > 50) {
                data.push_back(sx+ ofRandom(-rand, rand));
                data.push_back(sy+ ofRandom(-rand, rand));
                data.push_back(0);
                count++;
//                gpuPicto::totalPicto++;
            }
        }
    }
    
//    delete fbo;

    numPicto = count;
}
예제 #4
0
 void handleDefaultTextFont(float size)
 {
     if( m_currentTextFont.isLoaded() == false )
     {
         m_currentTextFont.load("verdana.ttf", size, true, true);
     }
     else if( m_currentTextFont.getSize() != size)
     {
         m_currentTextFont.load("verdana.ttf", size, true, true);
     }
 }
예제 #5
0
void ofARoom::showHandCoord(double xr, double yr, double zr, double xl, double yl, double zl, ofTrueTypeFont	verdana14)
{
    ostringstream s;
    s<<"xr : "<<xr<<" yr : "<<yr<<" zr : "<<zr;
    ofSetColor(0, 0, 0);
    verdana14.drawString(s.str(), 20, 20);

    ostringstream s2;
    s2<<"xl : "<<xl<<" yl : "<<yl<<" zl : "<<zl;
    ofSetColor(0, 0, 0);
    verdana14.drawString(s2.str(), ofGetWidth()-300, 20);

}
예제 #6
0
void Graph::drawString(string text, int x, int y) const {
	ofPushStyle();
	ofFill();
	ofRectangle box = font.getStringBoundingBox(text, x, y);
	box.x -= 1;
	box.y -= 1;
	box.width += 2;
	box.height += 2;
	ofSetColor(noData ? 64 : 0);
	ofRect(box);
	ofSetColor(noData ? 192 : 255);
	font.drawString(text, x, y);
	ofPopStyle();
}
예제 #7
0
void simpleToggle::draw(ofTrueTypeFont &font){
    ofPushStyle();

    ofSetColor(guiColor);
    if (!isOn) {
        ofNoFill();
        ofSetColor(255, 255, 255);
        roundedRect(pos.x, pos.y, width, height,6);
       /* ofFill();
        ofSetColor(150, 150, 150,200);
        roundedRect(pos.x, pos.y, width, height,6);
        ofSetColor(100, 100, 100,200);
        roundedRect(pos.x, pos.y+(height*0.5), width, height*0.5,6);*/

    }
    else{
        ofNoFill();
        ofSetColor(255, 255, 255);
        int rounding = 2;
        roundedRect(pos.x, pos.y, width, height,6);
        ofFill();
        ofSetColor(255, 255, 255,200);
        roundedRect(pos.x, pos.y, width, height,6);
        ofSetColor(150, 150, 150,200);
        roundedRect(pos.x, pos.y+(height*0.5), width, height*0.5,6);
    }
    ofSetColor(255, 255, 255);
    font.drawString(name, pos.x+width+5, pos.y+height);
    ofPopStyle();
    //isOn=false;
}
예제 #8
0
void ofARoom::showMovementName(string movementName,	ofTrueTypeFont	verdana14)
{
    if (movementName=="")
    {
        ofSetColor(245, 58, 135);
        verdana14.drawString("Dernier mouvement effectué : ", 20, ofGetHeight()-50);

    }
    else
    {

        ofSetColor(245, 58, 135);
        verdana14.drawString("Dernier mouvement effectué : "+movementName, 20, ofGetHeight()-50);
    }

}
예제 #9
0
void MindPaint::setup(){
    smallFont.loadFont("Arial.ttf", 10);
    // ofSetBackgroundAuto(false); // disable auto clear, there's a bug there
    ofBackground(230, 220, 220, 255);
    ofEnableAlphaBlending();
    ofEnableSmoothing();
    ofSetFrameRate(FPS);
    //useMouse = false;
    tgState = NONE;
    appState = SELECT_BG;
    tg.addEventListener(this);
    brush = new EllipseBrush();
    screenshotCount = 0;
    back = RYBWheel::pick(backRybAngle);
    back = ofFloatColor(250, 250, 230);
    mood = RYBWheel::pick(backRybAngle - 0.5);
    mood.a = 0.4;
    attBonus = 0;
    attScore = 0;
    medBonus = 0;
    medScore = 0;
    score = 0;
    //setMoverController(new EvadeController());
    setMoverController(new SpiralController());
    tgEmu.setup();
    Buffer::init(buffer, ofColor(220,220,220,255));
}
예제 #10
0
//------------------------------------------------------------------
ofTrueTypeFont::ofTrueTypeFont(const ofTrueTypeFont& mom)
:settings(mom.settings){
#if defined(TARGET_ANDROID)
	if(mom.isLoaded()){
		ofAddListener(ofxAndroidEvents().unloadGL,this,&ofTrueTypeFont::unloadTextures);
		ofAddListener(ofxAndroidEvents().reloadGL,this,&ofTrueTypeFont::reloadTextures);
	}
#endif
	bLoadedOk = mom.bLoadedOk;

	charOutlines = mom.charOutlines;
	charOutlinesNonVFlipped = mom.charOutlinesNonVFlipped;
	charOutlinesContour = mom.charOutlinesContour;
	charOutlinesNonVFlippedContour = mom.charOutlinesNonVFlippedContour;

	lineHeight = mom.lineHeight;
	ascenderHeight = mom.ascenderHeight;
	descenderHeight = mom.descenderHeight;
	glyphBBox = mom.glyphBBox;
	letterSpacing = mom.letterSpacing;
	spaceSize = mom.spaceSize;
	fontUnitScale = mom.fontUnitScale;

	cps = mom.cps; // properties for each character
	settings = mom.settings;
	glyphIndexMap = mom.glyphIndexMap;
	texAtlas = mom.texAtlas;
	face = mom.face;
}
예제 #11
0
//--------------------------------------------------------------
void ofApp::draw()
{
	if (!foundSolution)
	{
		for (int i = 0; i < ArrayCount(population); i++)
		{
			population[i].Fitness();
		}

		vector<DNA> matingPool = vector<DNA>();
		for (int i = 0; i < ArrayCount(population); i++)
		{
			int n = int(population[i].fitness * ArrayCount(population));
			for (int k = 0; k < n; k++)
			{
				matingPool.push_back(population[i]);
			}
		}

		for (int i = 0; i < ArrayCount(population); i++)
		{
			int a = int(ofRandom(0, matingPool.size()));
			int b = int(ofRandom(0, matingPool.size()));

			DNA parentA = matingPool[a];
			DNA parentB = matingPool[b];

			DNA child = parentA.crossover(parentB);
			child.mutate();

			population[i] = child;
		}
	}

	ofClear(ofColor::white);

	ofSetColor(ofColor::black);
	for (int i = 0; i < ArrayCount(population); i++)
	{
		//string str = population[i].genes;
		population[i].genes[ArrayCount(population[i].genes)] = '\0';

		if (population[i].genes == target)
		{
			foundSolution = true;
			ofNoFill();
			ofSetLineWidth(6);
			ofSetCurveResolution(200);
			ofCircle(ofPoint((int(i / POPULATION_PER_COLUMN) * Y_SPACING) + 100, 
								((i % POPULATION_PER_COLUMN) * X_SPACING) + BUFFER_SPACING), 120);
		}
		

		myFont.drawString(population[i].genes, 
							(int(i / POPULATION_PER_COLUMN) * Y_SPACING) + BUFFER_SPACING, 
							((i % POPULATION_PER_COLUMN) * X_SPACING) + BUFFER_SPACING);

	}

}
예제 #12
0
ofxOscilloscope::ofxOscilloscope(ofPoint min, ofPoint max, ofTrueTypeFont legendFont,
	int legendWidth, ofColor outlineColor, ofColor zeroLineColor, ofColor backgroundColor,
	float plotLineWidth, float outlineWidth) {
	_min = min;
	_max = max;
	_legendWidth = legendWidth;

	// Create scopePlot
	min.x = min.x + _legendWidth;
	_scopePlot = ofxScopePlot(min, max, zeroLineColor, plotLineWidth);


	setBackgroundColor(backgroundColor);
	setOutlineColor(outlineColor);
	setOutlineWidth(outlineWidth);

	if(legendFont.isLoaded()) {
		setLegendFont(legendFont);
	} else {
		_legendFont.loadFont("verdana.ttf", 12, true, true);
			//_legendFont.setLineHeight(18.0f);
		//_legendFont.setLetterSpacing(1.037);
		//ofTrueTypeFont::setGlobalDpi(72);
	}

	// Default values
	_legendPadding = 10;
	_textSpacer = 20;
}
예제 #13
0
//--------------------------------------------------------------
void ofApp::setup()
{
    for (int i = 0; i < ArrayCount(population); i++)
    {
        population[i] = DNA();
    }
	myFont.loadFont("LiberationMono-Regular.ttf", 12);
}
예제 #14
0
파일: testApp.cpp 프로젝트: I33N/ofxSick
	void draw() {
		ofPushStyle();
		ofSetColor(255, 128);
		if(messages.size()) {
			font.drawString(joined.str(), 10, 20);
		}
		ofPopStyle();
	}
예제 #15
0
파일: view.cpp 프로젝트: bmt/photobooth
void drawArgs(ofTrueTypeFont font, vector<string> args) {
    string allArgs = "Args: ";
    for(string arg : args) {
        allArgs += arg;
        allArgs += "\n";
    }
    font.drawString(allArgs, GUTTER, TEXT_Y);
}
예제 #16
0
void drawStimulus(string letter, bool showInstructions) {
	ofBackground(backgroundColor);
	ofSetColor(textColor);
	Draw::centeredString(Disp.getCenter(), letter, bigFont);

	if (showInstructions) {
		smallFont.drawString(keyReminderInstructions, 30, Disp.getResolution().y - 30);
	}
}
예제 #17
0
	// ---------------------------------------------------------------------------------------
	//
	void setup()
	{
		ofSetFrameRate(60);
		ofSetVerticalSync(true);
		ofBackground(0);
		
		ofxCL::Context::listDevices();
		
		ocl.setup( 0, true );
				
		noiseProgram.load("NoiseKernel.cl");
		
		methodNames.push_back( "GradientNoiseImage2d" );
		methodNames.push_back( "RidgedMultiFractalImage2d" );
		methodNames.push_back( "MonoFractalImage2d" );
		methodNames.push_back( "TurbulenceImage2d" );
		
		Resolution.addListener(this, &ofApp::resolutionChanged);
		
		gui.setup("Settings", "Settings.xml");

		gui.add( methodIndex.set( "methodIndex", 3, 0, methodNames.size()-1 ) );
		
		gui.add( Resolution.set( "Resolution", 1024, 2, 4096 ) );
		
		gui.add( Scale.set( "Scale", 1.0, 0.0, 1.0 ) );
		gui.add( ScaleMultiplier.set( "Scale Multiplier", 3.0, 0.001, 100.0f ) );
	
		gui.add( Lacunarity.set( "Lacunarity", 2.02f, 0.001f, 10.0f ) );
		gui.add( Increment.set( "Increment", 1.0f, -1.0, 1.0f ) );
		gui.add( Octaves.set( "Octaves", 3.3f, 0.001, 20.0f ) );
		gui.add( Amplitude.set( "Amplitude", 1.0f, 0.001, 10.0f ) );

		gui.add( AutoMove.set( "AutoMove", true ) );
		gui.add( AutoMoveMagnitude.set( "AutoMoveMagnitude", 0.5f, 0.001, 10.0f ) );
		
		drawGui = true;
				
		fontSmall.loadFont("DIN.otf", 8 );
	}
예제 #18
0
//------------------------------------------------------------
string wrapString(string text, ofTrueTypeFont &ofttf_object, int width) {
	
	string typeWrapped = "";
	string tempString = "";
	vector <string> words = ofSplitString(text, " ");
	for(int i=0; i<words.size(); i++) {
		
		string wrd = words[i];
		//cout << wrd << endl;
		
		tempString += wrd + " ";
		int stringwidth = ofttf_object.stringWidth(tempString);
		if(stringwidth >= width) {
			tempString = "";
			typeWrapped += "\n";
		}
		
		typeWrapped += wrd + " ";
	}
	
	return typeWrapped;
	
}
예제 #19
0
void BossBattle::draw( ofTrueTypeFont _font ) {
    _font.drawString( "This is not yet fully implemented. :(\nCheck back later.", iScaler * 8, iScaler * 4 );
}
예제 #20
0
파일: testApp.cpp 프로젝트: I33N/ofxSick
	LogOverlay()
	:maxSize(10) {
		font.loadFont(OF_TTF_MONO, 8, false);
	}
예제 #21
0
void MovingFont::setWord(string keyword, ofTrueTypeFont& ttf) {
    vecTtf = ttf.getStringAsPoints(keyword);
    
    x = ofRandom(ofGetWidth());
    y = -50;
}
예제 #22
0
void PMSc10Thanks::drawRightAlignString(ofTrueTypeFont &font, string s, int x, int y)
{
    int halfStringHeight = font.stringHeight(s) / 2;
    int stringWidth = font.stringWidth(s);
    font.drawString(s, x - stringWidth, y + halfStringHeight);
}
예제 #23
0
void setupResources() {
	if(!ready) {
		font.loadFont("uni05_53.ttf", 6, false);
		ready = true;
	}
}
예제 #24
0
void ofApp::draw(){

	font.drawString(appInfo, 2, 12);	
	drawTrunk(frameNumber, rotationAngle);
}
예제 #25
0
//------------------------------------------------------------------
void uiPresent::draw(ofTrueTypeFont& basicFont) {

    sprintf (timeString, "time: %0.2i:%0.2i:%0.2i \nelapsed time %i", ofGetHours(), ofGetMinutes(), ofGetSeconds(), ofGetElapsedTimeMillis());
	
    ofSetHexColor(0x000000);
	basicFont.drawString(timeString, 10,ofGetHeight()-90);
	basicFont.drawString(eventString, 10,ofGetHeight()-20);
    
    ofEnableAlphaBlending();
    
    ofSetColor(170, 170, 170);
    ofRect(*pencilBox);
    ofRect(*fontBox);
    ofRect(*tableBox);
    ofRect(*okSaveBox);
    
    ofSetHexColor(0x000000);

    pencil->draw(10, 310);
    font->draw(10, 355);
    table->draw(10, 400);
    okSave->draw(10, 445);

    if (*fontSelected) {
        basicFont.drawString(theText, 40, 40);
        thisText->draw(basicFont);
        basicFont.drawString("text selected", 10, ofGetHeight()/3);
        
        for (int i = 0; i < drawThese.size(); i++) {
            drawThese[i].draw();
        }

    }
    
    if (*pencilSelected) {

        basicFont.drawString(theText, 40, 40);
        thisText->draw(basicFont);
        basicFont.drawString("pencil selected", 10, ofGetHeight()/3);
        
        for (int i = 0; i < drawThese.size(); i++) {
            drawThese[i].draw();
        }
        
        if (currentDrawing.size()>0) {
            for (int i = 1; i < currentDrawing.size(); i++) {
                ofLine(currentDrawing[i-1].x, currentDrawing[i-1].y, currentDrawing[i].x, currentDrawing[i].y);
            }
        }
    }
    
    if (*tableSelected) {
        basicFont.drawString(theText, 40, 40);
        thisText->draw(basicFont);
        for (int i = 0; i < drawThese.size(); i++) {
            drawThese[i].draw();
        }
        basicFont.drawString("table selected", 10, ofGetHeight()/3);
    }

    if (*okSaveSelected) {
        basicFont.drawString(theText, 40, 40);
        thisText->draw(basicFont);
        for (int i = 0; i < drawThese.size(); i++) {
            drawThese[i].draw();
        }

        basicFont.drawString("ok save selected", 10, ofGetHeight()/3);
    }

    
    ofDisableAlphaBlending();

}
예제 #26
0
void PMSc10Thanks::drawLeftAlignString(ofTrueTypeFont &font, string s, int x, int y)
{
    int halfStringHeight = font.stringHeight(s) / 2;
    font.drawString(s, x, y + halfStringHeight);
}
예제 #27
0
void kinectCapture::setup(bool _bTwoKinects) {
    
    bTwoKinects = _bTwoKinects;
    
    bMovementDetection = true;
    
    // SETUP KINECT ONE
    
    fKin1Angle = 0;
    
    bool success = false;
    int counter = 0;
    
    kinect1.init(false, false);
    kinect1.open(0);
    
    if(bTwoKinects) {
        fKin2Angle = 0;
        
        kinect2.init(false, false);
        kinect2.open(1);
    
    }
    
    kinect1.update();
    kinect1.setCameraTiltAngle(0);
    kinect1.close();
    
    if(bTwoKinects) {
        kinect2.update();
        kinect2.setCameraTiltAngle(0);
        kinect2.close();
    }
    
    kinect1.init(false, false);
    success = kinect1.open(0);
    
    while (!success && counter < 10) {
        cout << "Problems found in connecting with Kinect 1. Trying again!" << endl;
        kinect1.close();
        kinect1.init(false, false);
        success = kinect1.open(0);
        counter++;
    }
    
    kinect1.setCameraTiltAngle(fKin1Angle);
    cvGrayKin1.allocate(640, 480);
    cvGrayKin1Prev.allocate(640,480);
    
    bKin1Refreshed = false;
    
    //IF USING TWO KINECTS, SETUP KINECT TWO
	
    if(bTwoKinects) {
    
        fKin2Angle = 0;
        
        success = false;
        counter = 0;
        
        kinect2.init(false, false);
        success = kinect2.open(1);
        
        kinect2.update();
        kinect2.close();
        
        kinect2.init(false, false);
        
        success = kinect2.open(1);
        
        while (!success && counter < 10) {
            cout << "Problems found in connecting with Kinect 2. Trying again!" << endl;
            kinect2.close();
            kinect2.init(false, false);
            success = kinect2.open(1);
            counter++;
        }
        
        kinect2.setCameraTiltAngle(fKin2Angle);
        cvGrayKin2.allocate(640, 480);
        cvGrayKin2Prev.allocate(640, 480);
        
        bKinectsStarted = false;
        bKin2Refreshed = false;
        
        vector<ofPoint> allocator(KIN_H * KIN_OUTPUT_W, ofPoint(0,0,0));
        
        for (int i = 0; i < iBufferSize; i++) {
            pointCloudBuffer.push_back(allocator);
        }
        
        allocator.clear();
        
    }
    
    else {
        
        vector<ofPoint> allocator(KIN_H * KIN_W, ofPoint(0,0,0));
        
        for (int i = 0; i < iBufferSize; i++) {
            pointCloudBuffer.push_back(allocator);
        }
        
        allocator.clear();
        
    }
    
    iNearThreshold  = 0;
    iFarThreshold   = 255;
    iMinBlobSize    = 20;
    iMaxBlobSize    = 20000;
    iMaxNumBlobs    = 10;
        
    font.loadFont("Ruda-Regular.ttf", 32); 
}
예제 #28
0
void Player::draw( ofTrueTypeFont _font, vector< Object > _recordedList ) {
    
    // We want to do something when the vector is empty, but not during the action that empties it, so we use a boolean that activates only after that last action is complete.
    if ( _recordedList.size() > 0 ) {
        bIsEmpty = false;
    } else if ( !bIsActing ) {
        bIsEmpty = true;
    }
    // We want to do something when the vector is full, but not during the action that fills it, so we use a boolean that activates only after that last action is complete.
    if ( _recordedList.size() < capacity ) {
        bIsFull = false;
    } else if ( !bIsActing ) {
        bIsFull = true;
    }
    
    // Display an outline of the next replayable note (drawn from the center).
    if ( _recordedList.size() > 0 ) {
        
        ofSetRectMode( OF_RECTMODE_CENTER );
        ofNoFill();
        ofRect( pos.x, _recordedList[ 0 ].pos.y, _recordedList[ 0 ].wide, _recordedList[ 0 ].tall );
        ofFill();
    }
    
    // Draw the player.
    ofSetRectMode( OF_RECTMODE_CENTER );
    ofSetColor( 0 );
    //ofRect( pos, wide, tall );
    
    // Draw the health. Taken from my Space Odyssey 2 code.
    ofPushMatrix();{
        
        ofTranslate( pos.x, pos.y);
        
        
        { // Matt
            // Draw the health bar
            ofSetRectMode( OF_RECTMODE_CORNER );
            float offset = 1;
            float offsetBar = 10;
            float barHeight = 10;
            float barLength = wide * 2;
            float currentHealth = ofMap( fHealth, 0, fHealthMax, 0, barLength - offset * 2 );
            // The border.
            ofSetColor( 255 );
            ofNoFill();
            ofRect( -wide, wide / 2 + offsetBar, barLength, barHeight );
            ofFill();
            // The current health.
            ofSetColor( 0, 255, 0 );
            ofRect( -wide + offset, wide / 2 + offsetBar + offset, currentHealth, barHeight - offset * 2 );
        } // End Matt
         
        
    }ofPopMatrix();
    
    ofSetColor( 255 );
    ofSetRectMode( OF_RECTMODE_CORNER );
    //headphones.draw( pos, 50, 50 );
    hand.draw( pos.x - wide / 2, pos.y - tall / 2, wide, tall );
    
    // Display a visual indicator of recorded capacity.
    if ( _recordedList.size() > 1 ) {
        for ( int i = 0; i < _recordedList.size(); i++ ) {
            float rad, tmpPosX, tmpPosY, hOffset, vOffset;
            rad = 3;
            //hOffset = ( wide - ( rad * 3 ) ) / 4;
            hOffset = wide / 4;
            vOffset = tall / 4;
            if ( i < 3 ) {
                tmpPosX = pos.x - wide / 2 + hOffset + hOffset * i;
                tmpPosY = pos.y - tall / 2 + vOffset;
            } else if ( i >= 3 && i < 6 ) {
                tmpPosX = pos.x - wide / 2 + hOffset + hOffset * ( i - 3 );
                tmpPosY = pos.y - tall / 2 + vOffset * 2;
            } else if ( i >= 6 && i < 9 ) {
                tmpPosX = pos.x - wide / 2 + hOffset + hOffset * ( i - 6 );
                tmpPosY = pos.y - tall / 2 + vOffset * 3;
            }
            ofNoFill();
            ofSetColor( 255 );
            ofCircle( tmpPosX, tmpPosY, rad );
            ofFill();
        }
    }
    
    // Draw the action if called, orbiting around the player's pos.
    if ( bIsActing ) {
        if ( bIsRecording ) {
            // Feedback for no capacity.
            if ( bIsFull ) {
                ofSetColor( 0 );
                _font.drawString("X", pos.x + 30, pos.y - 30 );
            }
            ofSetColor( 0, 255, 0 );
        }
        else if ( bIsReplaying ) {
            // Feedback for nothing to replay.
            if ( bIsEmpty ) {
                ofSetColor( 0 );
                _font.drawString("?", pos.x + 30, pos.y - 30 );
            }
            ofSetColor( 0, 0, 255 );
        }
        ofCircle( actPos, 10 );
    }
}
예제 #29
0
void runExperiment(void) {

	//When checking the timing of things, make sure to try it in full screen mode as well, because
	//timing errors happen a lot more when experiments is windowed rather than full screen.
	Disp.setFullscreen(false);

	if (Disp.isFullscreen()) {
		//If going to full screen, sometimes its good to wait a little while for things to settle before drawing stuff.
		Clock.sleep(CX_Seconds(1));
	}

	Log.levelForFile(CX_Logger::Level::LOG_ALL, "Last run.txt");
	Log.level(CX_Logger::Level::LOG_ALL, "CX_SlidePresenter");

	Log.notice() << "Frame period: " << Disp.getFramePeriod() << " (" << Disp.getFramePeriodStandardDeviation() << ")";
	
	Input.setup(true, false); //Use keyboard, not mouse.

	bigFont.loadFont(OF_TTF_SANS, 26);
	smallFont.loadFont(OF_TTF_SANS, 12);

	stringstream s;
	s << "Press '" << targetKey << "' for targets and '" << nonTargetKey << "' for non-targets";
	keyReminderInstructions = s.str();

	generateTrials();

	//In this example, more of the configuration settings for the slide presenter are used.
	//See the documentation for CX_SlidePresenter::Configuration for more information.
	CX_SlidePresenter::Configuration config;
	config.display = &Disp;
	config.swappingMode = CX_SlidePresenter::SwappingMode::SINGLE_CORE_BLOCKING_SWAPS;
	config.finalSlideCallback = &finalSlideFunction;
	config.deallocateCompletedSlides = useFramebuffersForStimuli; //Only deallocate if using framebuffers

	config.preSwapCPUHoggingDuration = CX_Millis(3);
	config.useFenceSync = true;
	config.waitUntilFenceSyncComplete = false;

	SlidePresenter.setup(config);

	for (int i = 3; i > 0; i--) {
		if (useFramebuffersForStimuli) {
			//Note that regardless of whether drawing functions are used later, you can use the standard framebuffer approach as well.
			//To be clear: You can mix and match framebuffers with drawing functions in a single presentation of slides.
			SlidePresenter.beginDrawingNextSlide(1000, "fixation");
			drawFixationSlide(i);
		} else {
			//std::bind sort of "bakes in" the value of i to drawFixationSlide, and the resulting function
			//takes no arguments, so it can be given to the slide presenter as a drawing function.
			SlidePresenter.appendSlideFunction( std::bind(drawFixationSlide, i), 1000, "fixation" );
		}
	}

	for (unsigned int i = 0; i <= nBack; i++) {
		//Depending on whether using the framebuffer approach or the drawing function approach, call a different setup function.
		if (useFramebuffersForStimuli) {
			drawStimuliToFramebuffers(SlidePresenter, i);
		} else {
			appendDrawingFunctions(SlidePresenter, i);
		}
	}
	trialNumber = nBack;

	Log.flush();

	SlidePresenter.startSlidePresentation();

	while (SlidePresenter.isPresentingSlides()) {
		SlidePresenter.update();
		Input.pollEvents();
	}

	df.printToFile("N-Back output.txt");

	Log.notice() << "Slide presentation information: " << endl << SlidePresenter.printLastPresentationInformation();


	vector<CX_SlidePresenter::Slide>& slides = SlidePresenter.getSlides();
	CX_Millis startMinusCopySum = 0;
	for (int i = 0; i < slides.size(); i++) {
		startMinusCopySum += slides[i].actual.startTime - slides[i].copyToBackBufferCompleteTime;
	}
	Log.notice() << "Average difference between back buffer copy completion and slide start: " << startMinusCopySum / slides.size();
	
	if (Disp.isFullscreen()) {
		Disp.setFullscreen(false);
	}

	if (Disp.isAutomaticallySwapping()) {
		Disp.setAutomaticSwapping(false);
	}

	Disp.beginDrawingToBackBuffer();
	ofBackground(backgroundColor);
	Draw::centeredString(Disp.getCenter(), "Experiment complete!\nPress any key to exit.", bigFont);
	Disp.endDrawingToBackBuffer();
	Disp.swapBuffers();

	Log.flush();

	Input.Keyboard.waitForKeypress(-1);
}
예제 #30
0
 void text(string& text, float x, float y)
 {
     handleDefaultTextFont(m_textSize);
     m_currentTextFont.drawString(text, x, y);
 }