本文整理汇总了C++中ofRectangle类的典型用法代码示例。如果您正苦于以下问题:C++ ofRectangle类的具体用法?C++ ofRectangle怎么用?C++ ofRectangle使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ofRectangle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rectangle
// 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();
}
示例2: ofPushMatrix
void hlct::LivesDisplay::draw(const ofRectangle& stageRect, const int& livesLeft, const float& scale){
float iconW = full.getWidth() * scale;
float iconH = full.getHeight() * scale;
float rectW = stageRect.getWidth();
float rectH = stageRect.getHeight();
float rectX = rectW - iconW * totalLives;
float rectY = 0;
ofPushMatrix();
ofPushStyle();
ofTranslate(stageRect.getTopRight());
ofTranslate(-iconW * this->totalLives, -iconH / 2);
for (int i = 0; i < this->totalLives; i++){
ofPushMatrix();
ofTranslate(iconW * i, iconH/2);
if (i < livesLeft) {
ofSetColor(ofColor::white, 200);
full.draw(0, 0, iconW, iconH);
} else {
ofSetColor(ofColor::white, 200);
dead.draw(0, 0, iconW, iconH);
}
ofPopMatrix();
}
ofPopStyle();
ofPopMatrix();
}
示例3: rectangle
//----------------------------------------------------------
void ofPath::rectangle(const ofRectangle & r){
moveTo(r.getTopLeft());
lineTo(r.getTopRight());
lineTo(r.getBottomRight());
lineTo(r.getBottomLeft());
close();
}
示例4: distributeHorz
void RectangleUtils::distributeHorz(RectanglePointers& rects,
const ofRectangle& boundingRect,
ofAlignHorz horzAnchor)
{
if(rects.size() >= 3 && horzAnchor != OF_ALIGN_HORZ_IGNORE) {
sortByHorzAnchor(rects,horzAnchor);
float nPos = rects.size() - 1;
// adjust to bounding bounding rect. if bounding rect is based on the group, nothing will change
rects[0]->translateX(boundingRect.getLeft() - rects[0]->getLeft());
rects[nPos]->translateX(boundingRect.getRight() - rects[nPos]->getRight());
float leftX = rects[0]->getHorzAnchor(horzAnchor);
float rightX = rects[nPos]->getHorzAnchor(horzAnchor);
float span = ( rightX - leftX ) / ( nPos );
for(size_t i = 1; i < nPos; i++) {
rects[i]->translateX((leftX - rects[i]->getHorzAnchor(horzAnchor)) + i * span);
}
} else {
if(horzAnchor == OF_ALIGN_HORZ_IGNORE) {
ofLogVerbose("ofDistributeHorizontal") << "OF_ALIGN_HORZ_IGNORE distribute requested, ignoring.";
} else {
ofLogWarning("ofDistributeHorizontal") << "Not enough rectangles to distribute.";
}
}
}
示例5: tensionEffect
void yeseulCooperMessages::tensionEffect(ofRectangle rec1, ofRectangle rec2) {
if (abs((dimensions.width/2+margin-redMove*1.1 - (0-dimensions.width/2-rec1.getWidth()-margin+redMove*1.6))) < rec1.getWidth()) {
redMove+=redTextSpeed/7;
}
else {
redMove+=redTextSpeed;
}
if (abs((dimensions.width/2+margin-greenMove) - (0-dimensions.width/2-rec1.getWidth()-margin+greenMove)) < rec1.getWidth()) {
greenMove+=greenTextSpeed/6;
}
else {
greenMove+=greenTextSpeed;
}
if (abs((0-dimensions.width/2-margin-rec1.getWidth()+purpleMove*1.7) - (dimensions.width/2+margin-150-purpleMove*1.4)) < rec1.getWidth()) {
purpleMove+=purpleTextSpeed/6;
}
else {
purpleMove+=purpleTextSpeed;
}
resetPosition();
}
示例6: R0
void DrawGame::drawScaledStringByFont(
string Txt,
ofTrueTypeFont* pFont,
ofRectangle Rect )
{
// debug
float sh = pFont->stringHeight(Txt);
float sw = pFont->stringWidth(Txt);
ofRectangle R0(0,0,sw,-sh);
ofVec2f Trans = Rect.getCenter()-R0.getCenter();
float sx,sy;
sx = Rect.getWidth()/R0.getWidth();
sy = -Rect.getHeight()/R0.getHeight();
ofMatrix4x4 Mat;
Mat.translate(-R0.getCenter());
Mat.scale(sx,sy,1.0f);
// Mat.translate(Rect.getCenter()/ofVec2f(sx,sy));
Mat.translate(Rect.getCenter());
ofMultMatrix(Mat);
pFont->drawString(Txt,0,0);
ofMatrix4x4 MatI;
MatI = Mat.getInverse();
ofMultMatrix(MatI);
}
示例7: distributeVert
void RectangleUtils::distributeVert(RectanglePointers& rects,
const ofRectangle& boundingRect,
ofAlignVert vertAnchor)
{
if(rects.size() >= 3 && vertAnchor != OF_ALIGN_VERT_IGNORE) {
sortByVertAnchor(rects,vertAnchor);
float nPos = rects.size() - 1;
// adjust to bounding bounding rect. if bounding rect is based on the group, nothing will change
rects[0]->translateY(boundingRect.getTop() - rects[0]->getTop());
rects[nPos]->translateY(boundingRect.getBottom() - rects[nPos]->getBottom());
float topY = rects[0]->getVertAnchor(vertAnchor);
float bottomY = rects[nPos]->getVertAnchor(vertAnchor);
float span = ( bottomY - topY ) / ( nPos );
for(size_t i = 1; i < nPos; i++) {
rects[i]->translateY((topY - rects[i]->getVertAnchor(vertAnchor)) + i * span);
}
} else {
if(vertAnchor == OF_ALIGN_VERT_IGNORE) {
ofLogVerbose("ofDistributeVertical") << "OF_ALIGN_VERT_IGNORE distribute requested, ignoring.";
} else {
ofLogWarning("ofDistributeVertical") << "Not enough rectangles to distribute.";
}
}
}
示例8: drawBrakets
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();
}
示例9: setSensorCrop
OMX_ERRORTYPE ofxRPiCameraVideoGrabber::setSensorCrop(ofRectangle& rectangle)
{
sensorCropConfig.xLeft = ((uint32_t)rectangle.getLeft() << 16)/100;
sensorCropConfig.xTop = ((uint32_t)rectangle.getTop() << 16)/100;
sensorCropConfig.xWidth = ((uint32_t)rectangle.getWidth() << 16)/100;
sensorCropConfig.xHeight = ((uint32_t)rectangle.getHeight() << 16)/100;
OMX_ERRORTYPE error = OMX_SetConfig(camera, OMX_IndexConfigInputCropPercentages, &sensorCropConfig);
OMX_TRACE(error);
if(error != OMX_ErrorNone)
{
ofLogError(__func__) << omxErrorToString(error);
if(error == OMX_ErrorBadParameter)
{
ofLogWarning(__func__) << "resetting cropRectangle to known good params (0, 0, 100, 100)";
cropRectangle.set(0, 0, 100, 100);
return updateSensorCrop();
}
}
return error;
}
示例10: ofVec4f
//----------
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);
}
示例11: drawVertAlignMark
//--------------------------------------------------------------
void testApp::drawVertAlignMark(const ofRectangle& rect, const ofColor& color, ofAlignVert vAlign) {
if(vAlign != OF_ALIGN_VERT_IGNORE) {
float vAnchor = rect.getVertAnchor(vAlign);
ofSetColor(color,120);
ofLine(rect.getLeft() - 13, vAnchor, rect.getLeft() - 3, vAnchor);
ofLine(rect.getRight() + 13, vAnchor, rect.getRight() + 3, vAnchor);
}
}
示例12: drawHorzAlignMark
//--------------------------------------------------------------
void testApp::drawHorzAlignMark(const ofRectangle& rect, const ofColor& color, ofAlignHorz hAlign) {
if(hAlign != OF_ALIGN_HORZ_IGNORE) {
float hAnchor = rect.getHorzAnchor(hAlign);
ofSetColor(color,120);
ofLine(hAnchor, rect.getTop() - 13, hAnchor, rect.getTop() - 3);
ofLine(hAnchor, rect.getBottom() + 13, hAnchor, rect.getBottom() + 3);
}
}
示例13: ofNoFill
void hlct::Game::drawLoadingBar(const ofRectangle& rect, const float& width){
ofNoFill();
ofDrawRectangle(rect);
ofFill();
ofDrawRectangle(rect.getTopLeft(),
rect.getWidth()*width,
rect.getHeight());
}
示例14: growToInclude
//----------------------------------------------------------
void ofRectangle::growToInclude(const ofRectangle& rect){
float x0 = MIN(getMinX(),rect.getMinX());
float x1 = MAX(getMaxX(),rect.getMaxX());
float y0 = MIN(getMinY(),rect.getMinY());
float y1 = MAX(getMaxY(),rect.getMaxY());
float w = x1 - x0;
float h = y1 - y0;
set(x0,y0,w,h);
}
示例15: setKinectROI
void KinectGrabber::setKinectROI(ofRectangle ROI){
minX = static_cast<int>(ROI.getMinX());
maxX = static_cast<int>(ROI.getMaxX());
minY = static_cast<int>(ROI.getMinY());
maxY = static_cast<int>(ROI.getMaxY());
ROIwidth = maxX-minX;
ROIheight = maxY-minY;
resetBuffers();
}