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(); }
//---------------------------------------------------------- void ofPath::rectangle(const ofRectangle & r){ moveTo(r.getTopLeft()); lineTo(r.getTopRight()); lineTo(r.getBottomRight()); lineTo(r.getBottomLeft()); close(); }
// 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(); }
/* 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; }
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; }
//-------------------------------------------------------------- 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() ); }
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; }
/* ** 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); } }
//-------------------------------------------------------------- //текстурированные прямоугольники 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() ); }
//-------------------------------------------------------------- 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() ); }
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); } } }
void ofxOscilloscope::setPosition(ofRectangle scopeArea) { setPosition(scopeArea.getTopLeft(), scopeArea.getBottomRight()); }
void ofxScopePlot::setPosition(ofRectangle plotArea) { setPosition(plotArea.getTopLeft(), plotArea.getBottomRight()); }