Example #1
0
/*
ofxOscilloscope::ofxOscilloscope() {
	_variableNames = NULL;
	//ofTrueTypeFont::setGlobalDpi(72);

	_legendFont.loadFont("verdana.ttf", 12, true, true);
	//_legendFont.setLineHeight(18.0f);
	//_legendFont.setLetterSpacing(1.037);

	_min=ofPoint(0,0);
	_max=ofGetWindowSize();
	_legendWidth=100;
}
*/
ofxOscilloscope::ofxOscilloscope(ofRectangle scopeArea, ofTrueTypeFont legendFont,
	int legendWidth, ofColor outlineColor, ofColor zeroLineColor, ofColor backgroundColor,
	float plotLineWidth, float outlineWidth) {
	_min = scopeArea.getTopLeft();
	_max = scopeArea.getBottomRight();
	_legendWidth = legendWidth;

	// Create scopePlot
	ofPoint min = _min;
	ofPoint max = _max;
	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;
}
Example #2
0
void TextWriter::drawFixedSize(ofRectangle box, string text, float glyphScaleFactor, bool centred) {
    text = ofToUpper(text);
    
	if(box.height<=0) box.height = 1;
	if(box.width<=0) box.width = 1;
    
    ofPushStyle();

    ofEnableAlphaBlending();
    ofEnableBlendMode(OF_BLENDMODE_ADD);
    ofSetLineWidth(glyphLineWeight);
    
    
    vector<string> lines;
    
    if( text.find('\n') == string::npos)  {
        lines.push_back(text);
    } else {
        lines = ofSplitString(text, "\n");
    }
    
	ofMesh writingMesh = getMesh(lines, box.getTopLeft(), glyphScaleFactor, centred);
	
	writingMesh.setMode(OF_PRIMITIVE_LINES);
    writingMesh.draw(); 
    
    ofPopStyle();
}
Example #3
0
// Temporary fix until OF 0.8.0
static void rectangle(ofPath & path, const ofRectangle & r){
	path.moveTo(r.getTopLeft());
	path.lineTo(r.getTopRight());
	path.lineTo(r.getBottomRight());
	path.lineTo(r.getBottomLeft());
	path.close();
}
Example #4
0
		//----------
		ofRectangle operator*(const ofRectangle & rectangle, const ofMatrix4x4 & transform) {
			auto topLeft = rectangle.getTopLeft();
			auto scale = ofVec4f(rectangle.getWidth(), rectangle.getHeight(), 0.0f, 0.0f); // w = 0 so no translate
			topLeft = topLeft * transform;
			scale = scale * transform;
			return ofRectangle(topLeft.x, topLeft.y, scale.x, scale.y);
		}
void Dimentions::drawBrakets(ofRectangle _rect, float size, float margin){
    
    ofPushStyle();
    ofSetLineWidth(2);
    
    ofPushMatrix();
    ofTranslate(_rect.getTopLeft() + ofPoint(-margin,-margin));
    ofLine(0, 0, size, 0);
    ofLine(0, 0, 0, size);
    ofPopMatrix();
    
    ofPushMatrix();
    ofTranslate(_rect.getTopRight() + ofPoint(margin,-margin));
    ofLine(0, 0, -size, 0);
    ofLine(0, 0, 0, size);
    ofPopMatrix();
    
    ofPushMatrix();
    ofTranslate(_rect.getBottomLeft() + ofPoint(-margin,margin));
    ofLine(0, 0, size, 0);
    ofLine(0, 0, 0, -size);
    ofPopMatrix();
    
    ofPushMatrix();
    ofTranslate(_rect.getBottomRight() + ofPoint(margin,margin));
    ofLine(0, 0, -size, 0);
    ofLine(0, 0, 0, -size);
    ofPopMatrix();
    
    ofPopStyle();
}
Example #6
0
//----------------------------------------------------------
void ofPath::rectangle(const ofRectangle & r){
	moveTo(r.getTopLeft());
	lineTo(r.getTopRight());
	lineTo(r.getBottomRight());
	lineTo(r.getBottomLeft());
	close();
}
Example #7
0
void hlct::Game::drawLoadingBar(const ofRectangle& rect, const float& width){
    ofNoFill();
    ofDrawRectangle(rect);
    ofFill();
    ofDrawRectangle(rect.getTopLeft(),
                    rect.getWidth()*width,
                    rect.getHeight());
}
Example #8
0
ofRectangle ofRectangleLerp(const ofRectangle & rectFrom,
                            const ofRectangle & rectTo,
                            float progress) {
    
    ofVec3f r00 = rectFrom.getTopLeft();
    ofVec3f r01 = rectFrom.getBottomRight();

    ofVec3f r10 = rectTo.getTopLeft();
    ofVec3f r11 = rectTo.getBottomRight();
    
    ofVec3f r20 = r00.interpolate(r10, progress);
    ofVec3f r21 = r01.interpolate(r11, progress);
    
    ofRectangle rect;
    rect.set(r20, r21);
    
    return rect;
}
Example #9
0
			//----------
			const ofxCvGui::PanelPtr Patch::View::findScreen(const ofVec2f & xy, ofRectangle & currentPanelBounds) {
				auto xyLocal = xy - currentPanelBounds.getTopLeft();

				auto nodeUnderCursor = this->getNodeHostUnderCursor();
				if (nodeUnderCursor) {
					return nodeUnderCursor->getNodeInstance()->getView(); // also this will return PanelPtr() if no screen available
				}

				return ofxCvGui::PanelPtr();
			}
Example #10
0
ofRectangle ofRectangleTransform(const ofRectangle & rect, const ofMatrix4x4 & mat) {
    ofVec3f tl = rect.getTopLeft();
    ofVec3f br = rect.getBottomRight();
    
    tl = mat.preMult(tl);
    br = mat.preMult(br);
    
    ofRectangle r;
    r.setPosition(tl);
    r.growToInclude(br);
    
    return r;
}
Example #11
0
/*
** ofxMultiScope 
*/
ofxMultiScope::ofxMultiScope(int numScopes, ofRectangle scopeArea, ofTrueTypeFont legendFont, 
	int legendWidth, ofColor outlineColor, ofColor zeroLineColor, ofColor backgroundColor) {
		_min = scopeArea.getTopLeft();
		_max = scopeArea.getBottomRight();
		_numScopes = numScopes;
		scopes.resize(_numScopes);
		for (int i=0; i<_numScopes; i++) {
			ofPoint sMin(_min.x, _min.y + i*(_max.y - _min.y)/_numScopes);
			ofPoint sMax(_max.x, _min.y + (i+1)*(_max.y - _min.y)/_numScopes);
			scopes.at(i) = ofxOscilloscope(sMin, sMax, legendFont, legendWidth, 
				outlineColor, zeroLineColor);
		}
}
Example #12
0
//--------------------------------------------------------------
void pbPushRect( const ofPoint &p1, const ofPoint &p2, const ofPoint &p3, const ofPoint &p4,
                const ofRectangle &texRect,
                vector<ofPoint> &points, vector<ofVec2f> &texs ) {
    points.push_back( p1 );
    points.push_back( p2 );
    points.push_back( p3 );
    points.push_back( p4 );
    
    texs.push_back( texRect.getTopLeft() );
    texs.push_back( texRect.getTopRight() );
    texs.push_back( texRect.getBottomRight() );
    texs.push_back( texRect.getBottomLeft() );
}
Example #13
0
//--------------------------------------------------------------
//текстурированные прямоугольники
void pbPushRect( const ofPoint &p, const ofPoint &w, const ofPoint &h,
                const ofRectangle &texRect,
                vector<ofPoint> &points, vector<ofVec2f> &texs )
{
    points.push_back( p );
    points.push_back( p + w );
    points.push_back( p + w + h );
    points.push_back( p + h );
    
    texs.push_back( texRect.getTopLeft() );
    texs.push_back( texRect.getTopRight() );
    texs.push_back( texRect.getBottomRight() );
    texs.push_back( texRect.getBottomLeft() );
}
Example #14
0
//--------------------------------------------------------------
void pbPushRect( float x, float y, float z, float w, float h,
                const ofRectangle &texRect,
                vector<ofPoint> &points, vector<ofVec2f> &texs )
{
    points.push_back( ofPoint( x, y, z ) );
    points.push_back( ofPoint( x + w, y, z ) );
    points.push_back( ofPoint( x + w, y + h, z ) );
    points.push_back( ofPoint( x, y + h, z ) );
    
    texs.push_back( texRect.getTopLeft() );
    texs.push_back( texRect.getTopRight() );
    texs.push_back( texRect.getBottomRight() );
    texs.push_back( texRect.getBottomLeft() );
    
}
Example #15
0
void LaserManager::renderLaserPath(ofRectangle previewRectangle, bool overrideSettings) {
	
	ofPushStyle();
	
	
	if((showLaserPath)||(overrideSettings)) {
		
		ofPushMatrix();
		
		ofTranslate(previewRectangle.getTopLeft());
		float scale =  previewRectangle.width / appWidth;
		ofScale(scale, scale);
		
		//ofDisableBlendMode();
		ofNoFill();
		ofSetLineWidth(1);
		ofSetColor(0,0,255);
		pathMesh.setMode(OF_PRIMITIVE_LINE_LOOP);
		pathMesh.draw();
		
		
		ofSetColor(255,255,255);
		pathMesh.setMode(OF_PRIMITIVE_POINTS);
		pathMesh.draw();
		ofPopMatrix();
		
		if(ildaPoints.size()>0) {
			int pointindex = floor(ofMap(ofGetMouseX(), previewRectangle.x, previewRectangle.getRight(), 0, (int)ildaPoints.size(), true));
			if(pointindex>=ildaPoints.size()) pointindex =ildaPoints.size();
			
			ofPoint p = ildaPointToOfPoint(ildaPoints[pointindex]);
			ofSetColor(0,255,0); 
			ofCircle(ofMap(p.x, 0, appWidth, previewRectangle.x, previewRectangle.getRight()), ofMap(p.y, 0, appHeight, previewRectangle.y, previewRectangle.getBottom()), 5);

		}
	}
	
	// TODO - this needs to go somewhere else!
	warp.visible = showWarpPoints || (overrideSettings);
	warp.draw();

	ofPopStyle();

}
Example #16
0
void  ofxScopePlot::setPosition(ofRectangle plotArea) {
	setPosition(plotArea.getTopLeft(), plotArea.getBottomRight());
}
Example #17
0
void  ofxOscilloscope::setPosition(ofRectangle scopeArea) {
	setPosition(scopeArea.getTopLeft(), scopeArea.getBottomRight());
}
Example #18
0
void hlct::Game::setup(const ofRectangle& rect){
    
    this->resize(rect);
    setupInfoScreens(rect);
    
    background.setup(rect, imgPack.background->getPixels());
    
    helmets.clear();
    
    state = GAME_STATE_TITLE;
    
    ofRectangle stageRect(rect.getTopLeft(), rect.getWidth(), rect.getHeight());
    
    gameStartTimer.setDuration(HLCT_USER_POSE_DURATION);
    gameStartTimer.setCurve(LINEAR);
    
    gameTimer.setRepeatType(PLAY_ONCE);
    gameTimer.setRepeatTimes(0);
    gameTimer.setCurve(LINEAR);
    
    gameEndTimer.setDuration(HLCT_GAME_END_TO_TITLE_DURATION);
    gameEndTimer.setCurve(LINEAR);
    
    livesDisplay.setup(imgPack, HLCT_LIVES);
    
    params.setName("Game");
    
    ofParameterGroup stageParams;
    stageParams.setName("Stage");
    stageParams.add(bDebug.set("Debug Mode", false));
    stageParams.add(stagePos.set("Top Left", ofVec2f(HLCT_CLAMP_STAGE, 40), ofVec2f::zero(), ofGetWindowRect().getBottomRight()));
    stageParams.add(stageWidth.set("Width", ofGetWidth() - HLCT_CLAMP_STAGE * 2, ofGetWidth()/2, ofGetWidth()*2));
    stageParams.add(stageHeight.set("Height", ofGetHeight() - 200, ofGetHeight()/2, ofGetHeight()*2));
    stageParams.add(dropX.set("Drop Left", 0, 0, ofGetWidth()/2));
    stageParams.add(dropWidth.set("Drop Width", 0, 0, ofGetWidth()));
    stageParams.add(loadingBarOffsetBottom.set("Loadingbar Offset", 120, -500, 500));
    
    ofParameterGroup alignParams;
    alignParams.setName("Scaling and Alignment");
    alignParams.add(scaleHero.set("Hero Scale", .5f, HLCT_HERO_SCALE_MIN, HLCT_HERO_SCALE_MAX));
    alignParams.add(scaleBait.set("Dropping Scale", .3f, HLCT_BAIT_SCALE_MIN, HLCT_BAIT_SCALE_MAX));
    alignParams.add(scaleBaitWin.set("Win Scale", .3f, HLCT_BAIT_SCALE_MIN, HLCT_BAIT_SCALE_MAX));
    alignParams.add(offsetBaitWin.set("Win Offset", 70, HLCT_BAIT_WIN_OFFSET_MIN, HLCT_BAIT_WIN_OFFSET_MAX));
    alignParams.add(diffBaitWin.set("Win Diff", .05f, HLCT_BAIT_WIN_DIFF_MIN, HLCT_BAIT_WIN_DIFF_MAX));
    alignParams.add(scaleLive.set("Live Scale", .75f, HLCT_LIVE_SCALE_MIN, HLCT_LIVE_SCALE_MAX));
    
    ofParameterGroup gameParams;
    gameParams.setName("Game Settings");
    gameParams.add(bStart.set("New", false));
    gameParams.add(endTime.set("Duration", 50, HLCT_MIN_DURATION, HLCT_MAX_DURATION));
    gameParams.add(currentTimeStr.set("Curent Time", "0"));
    gameParams.add(bPaused.set("Paused", false));
    
    params.add(stageParams);
    params.add(alignParams);
    params.add(gameParams);
    params.add(score.set("Score", 0, 0, HLCT_MAX_CATCH));
    
    params.add(bUserExists.set("User Exists", false));
    params.add(bUserPosing.set("User Posing", false));
    useOsc.set("Use Osc", true);
    bAddHelmet.set("Add Helmet", false);
    helmetSection.set("Helmet Section", 0, 0, HLCT_HELMET_SECTION_COUNT);
    
    scaleHero.addListener(this, &Game::handleScaleHero);
    scaleBait.addListener(this, &Game::handleScaleBait);
    scaleBaitWin.addListener(this, &Game::handleScaleBaitWin);
    bUserExists.addListener(this, &Game::handleUserExists);
    bUserPosing.addListener(this, &Game::handlePosing);
    bStart.addListener(this, &Game::handleGameStart);
    bAddHelmet.addListener(this, &Game::handleAddHelmet);
    
    receiver.setup(HLCT_OSC_PORT);
}
Example #19
0
void ofxParticle::constrainToRect(ofRectangle bounds, const float k, const float dist, const float drag)
{
    ofPoint minPoint = bounds.getTopLeft();
    ofPoint maxPoint = bounds.getBottomRight();
    float inverse_drag = 1.0f / drag;
    float inverse_mass = 1.0f / mass;
    float spring_constant = inverse_mass * inverse_drag;
    float force;
    ofVec3f dir;
    float dis;
    
    // left side
    if (position.x < minPoint.x) {
        velocity.x = minPoint.x - position.x;
        position.x = minPoint.x+1;
    }
    if (position.x < minPoint.x + dist) {
        dir = ofVec3f(1,0,0);
        dis = position.x - minPoint.x;
        dis = dist - dis;
        force = -k * dis * spring_constant;
        acceleration += dir*(-force);
    } else {
        // right side
        if (position.x > maxPoint.x) {
            velocity.x = maxPoint.x - position.x;
            position.x = maxPoint.x-1;
        }
        if (position.x > maxPoint.x - dist) {
            dir = ofVec3f(-1,0,0);
            dis = maxPoint.x - position.x;
            dis = dist - dis;
            force =  -k * dis * spring_constant;
            acceleration += dir*(-force);
        }
    }
    
    // top side
    if (position.y < minPoint.y) {
        velocity.y = minPoint.y - position.y;
        position.y = minPoint.y+1;
    }
    if (position.y < minPoint.y + dist) {
        dir = ofVec3f(0,1,0);
        dis = position.y - minPoint.y;
        dis = dist - dis;
        force = -k * dis * spring_constant;
        acceleration += dir*(-force);
    } else {
        // bottom side
        if (position.y > maxPoint.y) {
            velocity.y = maxPoint.y - position.y;
            position.y = maxPoint.y-1;
        }
        if (position.y > maxPoint.y - dist) {
            dir = ofVec3f(0,-1,0);
            dis = maxPoint.y - position.y;
            dis = dist - dis;
            force =  -k * dis * spring_constant;
            acceleration += dir*(-force);
        }
    }
}