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); //
        
    }
}
示例#2
0
//--------------------------------------------------------------
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);
  }
}
示例#3
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);
		}
示例#4
0
  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);

  }
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;
    
}
示例#6
0
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();
}
示例#7
0
void hlct::Game::drawLoadingBar(const ofRectangle& rect, const float& width){
    ofNoFill();
    ofDrawRectangle(rect);
    ofFill();
    ofDrawRectangle(rect.getTopLeft(),
                    rect.getWidth()*width,
                    rect.getHeight());
}
//----------------------------------------------------------
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;
}
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);
}
示例#10
0
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 ;

    }
}
示例#11
0
//--------------------------------------------------------------
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;
}
示例#12
0
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());
}
//----------------------------------------------------------
void ofRectangle::scaleTo(const ofRectangle& targetRect,
                          ofAspectRatioMode aspectRatioMode,
                          ofAlignHorz modelHorzAnchor,
                          ofAlignVert modelVertAnchor,
                          ofAlignHorz thisHorzAnchor,
                          ofAlignVert thisVertAnchor) {

    float tw = targetRect.getWidth();    // target width
    float th = targetRect.getHeight();   // target height
    float sw = getWidth();   // subject width
    float sh = getHeight();  // subject height

    if(aspectRatioMode == OF_ASPECT_RATIO_KEEP_BY_EXPANDING ||
            aspectRatioMode == OF_ASPECT_RATIO_KEEP) {
        if(fabs(sw) >= FLT_EPSILON || fabs(sh) >= FLT_EPSILON) {
            float wRatio = fabs(tw) / fabs(sw);
            float hRatio = fabs(th) / fabs(sh);
            if(aspectRatioMode == OF_ASPECT_RATIO_KEEP_BY_EXPANDING) {
                scale(MAX(wRatio,hRatio));
            } else if(aspectRatioMode == OF_ASPECT_RATIO_KEEP) {
                scale(MIN(wRatio,hRatio));
            }
        } else {
            ofLogWarning("ofRectangle") << "scaleTo(): no scaling applied to avoid divide by zero, rectangle has 0 width and/or height: " << sw << "x" << sh;
        }
    } else if(aspectRatioMode == OF_ASPECT_RATIO_IGNORE) {
        width  = tw;
        height = th;
    } else {
        ofLogWarning("ofRectangle") << "scaleTo(): unknown ofAspectRatioMode = " << aspectRatioMode << ", using OF_ASPECT_RATIO_IGNORE";
        width  = tw;
        height = th;
    }

    // now align if anchors are not ignored.
    alignTo(targetRect,
            modelHorzAnchor,
            modelVertAnchor,
            thisHorzAnchor,
            thisVertAnchor);

}
示例#14
0
//--------------------------------------------------------------
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();
}
示例#15
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);
}
示例#16
0
//--------------------------------------------------------------
void Surface::drawDevicePointSurface(ofRectangle& rect)
{
    ofPushStyle();
    ofSetColor(255,255,255,255);
	ofEnableAlphaBlending();
    
    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());

		if (GLOBALS->mp_deviceManager->getDeviceCurrent() == pDevice)
		{
			ofSetColor(255,255,255,255);
    	}
		else
			ofSetColor(255,255,254,100);
	 
			ofLine(posSurface.x,posSurface.y-40, posSurface.x, posSurface.y+40);
        	ofLine(posSurface.x-40,posSurface.y, posSurface.x+40,posSurface.y);
			ofDrawBitmapString(pDevice->m_id, posSurface.x+4, posSurface.y-4);

	}

    ofPopStyle();
}