当前位置: 首页>>代码示例>>C++>>正文


C++ ofRectangle::getWidth方法代码示例

本文整理汇总了C++中ofRectangle::getWidth方法的典型用法代码示例。如果您正苦于以下问题:C++ ofRectangle::getWidth方法的具体用法?C++ ofRectangle::getWidth怎么用?C++ ofRectangle::getWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ofRectangle的用法示例。


在下文中一共展示了ofRectangle::getWidth方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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();
}
开发者ID:decebel,项目名称:dayForNightSFPC,代码行数:26,代码来源:yeseulCooperMessages.cpp

示例2: center

//--------------------------------------------------------------
void center(const ofRectangle& rect, int angle) {
  if (angle % 2 == 0) {
    ofTranslate(ofGetWidth()  * 0.5f - rect.getWidth()  * 0.5f,
                ofGetHeight() * 0.5f - rect.getHeight() * 0.5f);
  }
  else {
    ofTranslate(ofGetWidth()  * 0.5f - rect.getHeight() * 0.5f,
                ofGetHeight() * 0.5f - rect.getWidth()  * 0.5f);
  }
}
开发者ID:ragnaringi,项目名称:Periscope,代码行数:11,代码来源:Input.cpp

示例3: detectRectangleCollision

//--------------------------------------------------------------
bool ofApp::detectRectangleCollision( const ofRectangle& firstRectangle,const ofRectangle& secondRectangle){
    //なぜかrectangle.x が不定のデータが入ってくることがあるため緊急的な措置
    if ( firstRectangle.getWidth() > 0 && secondRectangle.getWidth() > 0 && firstRectangle.getHeight() > 0 && secondRectangle.getWidth() > 0) {
        if ( firstRectangle.getWidth() < 1000000 && secondRectangle.getWidth() < 1000000 && firstRectangle.getHeight()  < 1000000 && secondRectangle.getWidth() < 1000000) {
            if (  ( secondRectangle.getPosition().x <  firstRectangle.getPosition().x+ firstRectangle.getWidth() ) &&  ( firstRectangle.getPosition().x < secondRectangle.getPosition().x + secondRectangle.getWidth() )){
                if ( ( secondRectangle.getPosition().y < firstRectangle.getPosition().y + firstRectangle.getHeight() ) && (firstRectangle.getPosition().y < secondRectangle.getPosition().y + secondRectangle.getHeight() ) ){
                    
                    return true;
                }
            }
        }
    }
    
    return false;
}
开发者ID:ootorit,项目名称:ExcitossSensorModule,代码行数:16,代码来源:ofApp.cpp

示例4: ofRectangle

		//----------
		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);
		}
开发者ID:AbdelghaniDr,项目名称:ofxCvGui,代码行数:8,代码来源:Utils.cpp

示例5: ofRandom

void hlct::Helmet::setup(const ofRectangle& stageRect, const ofPixels& helmetPixels, const int& sectionIndex){
    
    this->stageRect.set(stageRect);
    
    img.setFromPixels(helmetPixels);
    
    gravity = ofRandom(-5.f, -4.f);
    float sectionWidth = stageRect.getWidth() / HLCT_HELMET_SECTION_COUNT;
    float sectionX = ofClamp(ofRandom(0, sectionWidth),
                             stageRect.getX() + img.getWidth() / 2,
                             stageRect.getX() + stageRect.getWidth() - img.getWidth());
    position.x = sectionX + sectionWidth * sectionIndex;
    
    alive = true;
    win = false;
}
开发者ID:serkansokmen,项目名称:hlct,代码行数:16,代码来源:Helmet.cpp

示例6: 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();
}
开发者ID:serkansokmen,项目名称:hlct,代码行数:28,代码来源:LivesDisplay.cpp

示例7: drawScaledStringByFont

  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);

  }
开发者ID:magicbrush,项目名称:DrawGame,代码行数:28,代码来源:DrawGameUtils.cpp

示例8: 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;
    
}
开发者ID:AazibSafi,项目名称:ofxRPiCameraVideoGrabber,代码行数:25,代码来源:ofxRPiCameraVideoGrabber.cpp

示例9: ofNoFill

void hlct::Game::drawLoadingBar(const ofRectangle& rect, const float& width){
    ofNoFill();
    ofDrawRectangle(rect);
    ofFill();
    ofDrawRectangle(rect.getTopLeft(),
                    rect.getWidth()*width,
                    rect.getHeight());
}
开发者ID:serkansokmen,项目名称:hlct,代码行数:8,代码来源:Game.cpp

示例10: drawDevicePointSurface

//--------------------------------------------------------------
void Surface::drawDevicePointSurface(ofRectangle& rect)
{
    ofPushStyle();
    ofSetColor(255,255,255,255);
	ofDisableAlphaBlending();
    
    vector<Device*>::iterator itDevices = m_listDevices.begin();
    ofVec2f posSurface;
    Device* pDevice=0;
    for (;itDevices!=m_listDevices.end();++itDevices)
    {
        pDevice = *itDevices;
        posSurface.set(rect.getX()+pDevice->m_pointSurface.x*rect.getWidth(), rect.getY()+pDevice->m_pointSurface.y*rect.getHeight());

        ofLine(posSurface.x,rect.getY(), posSurface.x, rect.getY()+rect.getHeight());
        ofLine(rect.getX(),posSurface.y, rect.getX()+rect.getWidth(),posSurface.y);
    }

    ofPopStyle();
}
开发者ID:valereA,项目名称:murmur,代码行数:21,代码来源:surface.cpp

示例11: animateText

void yeseulCooperMessages::animateText(ofRectangle rec1, ofRectangle rec2) {
    
    ofRotate(315+rotation);
    ofSetColor(ofColor::fromHsb(7, 255, 100));
    ofFill();
    for (int n = 0; n < 3; n++) {
        font.drawStringAsShapes(text1, dimensions.width/2+margin-redMove*1.2, -rec1.getHeight());
        font.drawStringAsShapes(text2, dimensions.width/2+margin-redMove*1.1, 0);
        font.drawStringAsShapes(text1, 0-dimensions.width/2-rec1.getWidth()-margin+redMove*1.6, rec1.getHeight());
        font.drawStringAsShapes(text2, 0-dimensions.width/2-rec2.getWidth()-margin-50+redMove*1.4, rec2.getHeight()*2);
    }
    
    ofRotate(90);
    ofSetColor(ofColor::fromHsb(90, 255, 20));
    ofFill();
    for (int n = 0; n < 3; n++) {
        font.drawStringAsShapes(text1, dimensions.width/2+margin-greenMove, -rec1.getHeight());
        font.drawStringAsShapes(text2, dimensions.width/2+margin-greenMove, 0);
        font.drawStringAsShapes(text1, 0-dimensions.width/2-rec1.getWidth()-margin+greenMove, rec1.getHeight());
        font.drawStringAsShapes(text2, 0-dimensions.width/2-rec2.getWidth()-margin+greenMove, rec2.getHeight()*2);
    }
    
    ofRotate(90);
    ofSetColor(ofColor::fromHsb(200, 255, 20));
    ofFill();
    for (int n = 0; n < 3; n++) {
        font.drawStringAsShapes(text1, 0-dimensions.width/2-margin-rec1.getWidth()-150+purpleMove*1.7, rec1.getHeight());
        font.drawStringAsShapes(text2, 0-dimensions.width/2-margin-rec2.getWidth()-150+purpleMove*1.5, rec2.getHeight()*2);
        font.drawStringAsShapes(text1, dimensions.width/2+margin-purpleMove-70, -rec1.getHeight());
        font.drawStringAsShapes(text2, dimensions.width/2+margin-purpleMove*1.4, 0); //
        
    }
}
开发者ID:decebel,项目名称:dayForNightSFPC,代码行数:33,代码来源:yeseulCooperMessages.cpp

示例12: scaleIntoMe

//----------------------------------------------------------
ofRectangle ofRectangle::scaleIntoMe(const ofRectangle& toBeScaled) const {

    ofRectangle result;

    // make sure we are dealing with non-zero rects, else divide by zero
    if(fabs(toBeScaled.getWidth())  < FLT_EPSILON ||
       fabs(toBeScaled.getHeight()) < FLT_EPSILON) {
        ofLogWarning() << "ofRectangle: Source rectangle had 0 width or 0 height. Avoiding divide by zero.";
        return result;
    }
    
    // find the scaling factor, fabs for -w and/or -h
    float resultScale = MIN(fabs(width)  / fabs(toBeScaled.getWidth()),
                            fabs(height) / fabs(toBeScaled.getHeight()));
    
    // set the rect from cetner with scaled w/h
    result.setFromCenter(getCenter(),
                         toBeScaled.getWidth()  * resultScale,
                         toBeScaled.getHeight() * resultScale);
    
    return result;
}
开发者ID:Tukamotosan,项目名称:openFrameworks,代码行数:23,代码来源:ofRectangle.cpp

示例13: drawSkeleton_doEffect

void app::drawSkeleton_doEffect(Skeleton * s, ofRectangle boundingbox)
{
	//Draw a single skeleton in the bounding box
	//All points in the skeleton are with a 0,0 point at the center
	//And a range of -1 to 1 on both the x and y axis
	//Need to know multiplier and constant
	float multiplierX = boundingbox.getWidth()/2.0;
	float constantX = boundingbox.x + (boundingbox.getWidth()/2.0);
	float multiplierY = -1.0 * boundingbox.getHeight()/2.0; //Negative since 0 is at top of window
	float constantY = boundingbox.y + (boundingbox.getHeight()/2.0);
	ofPoint m = ofPoint(multiplierX, multiplierY);
	ofPoint c = ofPoint(constantX, constantY);

	//Loop through each bone and draw them
	int num_bones = s->bones.size();
	for(int i = 0; i < num_bones; ++i)
	{
		drawBone_doEffect(&(s->bones[i]),m,c,s);
	}

	//Do this level's effect as seperate function
	doSkeletonEffect(s);
}
开发者ID:JulianKemmerer,项目名称:Drexel-SeniorDesign,代码行数:23,代码来源:app+(Julian+Kemmerer's+conflicted+copy+2013-05-11).cpp

示例14: normalize

void LaserGroup::normalize(const ofRectangle& boundingBox)
{
    for(auto laser: m_lasers)
    {
        ofPoint pos = laser->getPosition();
        pos.x = (pos.x - boundingBox.getX()) / boundingBox.getWidth();
        pos.y = (pos.y - boundingBox.getY()) / boundingBox.getHeight();
        pos.y = 1 - pos.y;
        laser->setPosition(pos);
        
        //ofLogNotice() <<"LaserGroup::normalize -> id " << getId()<< ", channel = "  << getChannel()  << ", x = "  << laser->getPosition().x << ", y = "  << laser->getPosition().y << ", z = " << laser->getPosition().z ;

    }
}
开发者ID:ImanolGo,项目名称:LedCostume,代码行数:14,代码来源:LaserGroup.cpp

示例15:

DrawGame::GUIDataSlot::GUIDataSlot(  
  ofParameter<float>& p,
  ofParameter<float>& pmax,
  string tag,
  string title, 
  ofRectangle R,
  float TitleWdRatio,
  ofTrueTypeFont* font,
  float MaxValue,  
  float BarEdgeWidth,  
  ofColor CrTxt,
  ofColor CrBarEmpty,
  ofColor CrBarFill,
  ofColor CrBarEdge):
dataSrc(&p),
dataMaxSrc(&pmax),
GUIBase(tag),
pFont(font),
Title(title),
maxVal(MaxValue),
titleWdRatio(TitleWdRatio),
edgeWd(BarEdgeWidth),
CrText(CrTxt),
CrBG(CrBarEmpty),
CrFill(CrBarFill),
CrEdge(CrBarEdge)
{
  if(Crs.size()==0)
  {
    ofColor defCrs[10] = {
      ofColor::yellow,
      ofColor::green, 
      ofColor::darkGreen,
      ofColor::skyBlue,
      ofColor::cyan, 
      ofColor::blue, 
      ofColor::blueViolet,
      ofColor::violet,
      ofColor::chocolate,
      ofColor::black};
    for(int i=0;i<10;i++)
    {
      Crs.push_back(defCrs[i]);
    }
  }
  Rect.setFromCenter(ofVec2f(0,0),R.getWidth(),R.getHeight());
  ofNode::setPosition(R.getCenter());
}
开发者ID:magicbrush,项目名称:DrawGame,代码行数:48,代码来源:GUIDataSlot.cpp


注:本文中的ofRectangle::getWidth方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。