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


C++ Rect2D类代码示例

本文整理汇总了C++中Rect2D的典型用法代码示例。如果您正苦于以下问题:C++ Rect2D类的具体用法?C++ Rect2D怎么用?C++ Rect2D使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: Vector2

Rect2D App::drawPopup(const char* title) {
    int w = renderDevice->width();
    int h = renderDevice->height();

    // Drop shadow
    renderDevice->pushState();
        renderDevice->setBlendFunc(RenderDevice::BLEND_SRC_ALPHA, RenderDevice::BLEND_ONE_MINUS_SRC_ALPHA);
        Rect2D rect = Rect2D::xywh(w/2 - 20, h/2 - 20, w/2, h/2);
        Draw::rect2D(rect + Vector2(5, 5), renderDevice, Color4(0, 0, 0, 0.15f));
    renderDevice->popState();

    // White box
    Draw::rect2D(rect, renderDevice, Color3::white());
    Draw::rect2DBorder(rect, renderDevice, Color3::black());

    // The close box
    Draw::rect2DBorder(Rect2D::xywh(rect.x1() - 16, rect.y0(), 16, 16), renderDevice, Color3::black());
    renderDevice->setColor(Color3::black());
    renderDevice->beginPrimitive(PrimitiveType::LINES);
        renderDevice->sendVertex(Vector2(rect.x1() - 14, rect.y0() + 2));
        renderDevice->sendVertex(Vector2(rect.x1() - 2, rect.y0() + 14));   
        renderDevice->sendVertex(Vector2(rect.x1() - 2, rect.y0() + 2));
        renderDevice->sendVertex(Vector2(rect.x1() - 14, rect.y0() + 14));   
    renderDevice->endPrimitive();

    float s = w * 0.013;
    titleFont->draw2D(renderDevice, title, Vector2(rect.x0() + 4, rect.y0()), s * 1.5, Color3::black(), Color4::clear(), GFont::XALIGN_LEFT, GFont::YALIGN_TOP);

    return rect;
}
开发者ID:luaman,项目名称:g3d-cvs,代码行数:30,代码来源:main.cpp

示例2: our_penalty

/*!

 */
bool
RoleGoalie::execute( PlayerAgent * agent )
{
    static const Rect2D our_penalty( Vector2D( -ServerParam::i().pitchHalfLength(),
                                               -ServerParam::i().penaltyAreaHalfWidth() + 1.0 ),
                                     Size2D( ServerParam::i().penaltyAreaLength() - 1.0,
                                             ServerParam::i().penaltyAreaWidth() - 2.0 ) );

    //////////////////////////////////////////////////////////////
    // play_on play

    // catchable
    if ( agent->world().time().cycle()
         > agent->world().self().catchTime().cycle() + ServerParam::i().catchBanCycle()
         && agent->world().ball().distFromSelf() < ServerParam::i().catchableArea() - 0.05
         && our_penalty.contains( agent->world().ball().pos() ) )
    {
        dlog.addText( Logger::ROLE,
                      __FILE__": catchable. ball dist=%.1f, my_catchable=%.1f",
                      agent->world().ball().distFromSelf(),
                      ServerParam::i().catchableArea() );
        agent->doCatch();
        agent->setNeckAction( new Neck_TurnToBall() );
    }
    else if ( agent->world().self().isKickable() )
    {
        doKick( agent );
    }
    else
    {
        doMove( agent );
    }

    return true;
}
开发者ID:4SkyNet,项目名称:HFO,代码行数:38,代码来源:role_goalie.cpp

示例3: drawFPSGraph

void EconomyGraph::drawFPSGraph( Painter& painter, Rect2D fpsRect ){ 
    Color grey, blue;
    blue.parse( "blue" );
    grey.parse("#A9A9A9FF");
    int mgX = (int) fpsRect.p1.x;
    int mgY = (int) fpsRect.p1.y;
    int mgW = (int) fpsRect.getWidth(); 
    int mgH = (int) fpsRect.getHeight();

    
    painter.setFillColor( grey );
    painter.fillRectangle( fpsRect );
    
    painter.setClipRectangle( fpsRect ); 
      
    Vector2 a;
    Vector2 b;
    painter.setLineColor( blue );
    
    float scale = (float) mgH / 64; //MONTHGRAPH_H  ;

    b.y = mgY + mgH;
    for( int i = mgW - 1; i >= 0; i-- ){
        a.x = mgX + mgW - i;
        a.y = mgY + mgH - scale * fps[i];
        
        b.x = mgX + mgW - i;
        painter.drawLine( a, b );
    }
    painter.clearClipRectangle();
}
开发者ID:BackupTheBerlios,项目名称:lincity-ng-svn,代码行数:31,代码来源:EconomyGraph.cpp

示例4: theme

void GuiDropDownList::showMenu() {
    // Show the menu
    Rect2D clickRect = theme()->dropDownListToClickBounds(rect(), m_captionWidth);
    Vector2 clickOffset = clickRect.x0y0() - rect().x0y0();
    Vector2 menuOffset(10, clickRect.height() + 10);

    menu()->show(m_gui->manager(), window(), this, toOSWindowCoords(clickOffset + menuOffset), false, m_actionCallback);
}
开发者ID:jackpoz,项目名称:G3D-backup,代码行数:8,代码来源:GuiDropDownList.cpp

示例5: clientRect

void CameraControlWindow::setRect(const Rect2D& r) {
    GuiWindow::setRect(r);
    if (drawerButtonPane) {
        float s = 12;
        const Rect2D& r = clientRect();
        drawerButtonPane->setPosition((r.width() - s) / 2.0f, r.height() - s);
    }
}
开发者ID:Jekls,项目名称:PhantomCore,代码行数:8,代码来源:CameraControlWindow.cpp

示例6:

void App::onGraphics2D(RenderDevice* rd, Array<shared_ptr<Surface2D> >& posed2D) {
    if (notNull(m_qrTexture)) {
        Rect2D rect = Rect2D::xywh(Point2(20, 20), m_qrTexture->vector2Bounds() * 10);
        Draw::rect2D(rect, rd, Color3::white(), m_qrTexture, Sampler::buffer());
        m_font->draw2D(rd, m_addressString, Point2(rect.center().x, rect.y1() + 20), 24, Color3::white(), Color3::black(), GFont::XALIGN_CENTER);
    }

    // Render 2D objects like Widgets.  These do not receive tone mapping or gamma correction.
    Surface2D::sortAndRender(rd, posed2D);
}
开发者ID:jackpoz,项目名称:G3D-backup,代码行数:10,代码来源:App.cpp

示例7: Vector2

void GuiCheckBox::setRect(const Rect2D& rect) {
     if (m_style == GuiTheme::NORMAL_CHECK_BOX_STYLE) {
         // TODO: use the actual font size etc. to compute bounds
         // Prevent the checkbox from stealing clicks very far away
         m_rect = rect;
         m_clickRect = Rect2D::xywh(rect.x0y0(), Vector2(min(rect.width(), 30.0f), rect.height()));
     } else {
         GuiControl::setRect(rect);
     }
}
开发者ID:A7med-Shoukry,项目名称:g3d,代码行数:10,代码来源:GuiCheckBox.cpp

示例8: inertia_final_point

/*!

 */
int
TackleGenerator::predictOpponentsReachStep( const WorldModel & wm,
                                            const Vector2D & first_ball_pos,
                                            const Vector2D & first_ball_vel,
                                            const AngleDeg & ball_move_angle )
{
    int first_min_step = 50;

#if 1
    const ServerParam & SP = ServerParam::i();
    const Vector2D ball_end_point = inertia_final_point( first_ball_pos,
                                                         first_ball_vel,
                                                         SP.ballDecay() );
    if ( ball_end_point.absX() > SP.pitchHalfLength()
         || ball_end_point.absY() > SP.pitchHalfWidth() )
    {
        Rect2D pitch = Rect2D::from_center( 0.0, 0.0, SP.pitchLength(), SP.pitchWidth() );
        Ray2D ball_ray( first_ball_pos, ball_move_angle );
        Vector2D sol1, sol2;
        int n_sol = pitch.intersection( ball_ray, &sol1, &sol2 );
        if ( n_sol == 1 )
        {
            first_min_step = SP.ballMoveStep( first_ball_vel.r(), first_ball_pos.dist( sol1 ) );
#ifdef DEBUG_PRINT
            dlog.addText( Logger::CLEAR,
                          "(predictOpponent) ball will be out. step=%d reach_point=(%.2f %.2f)",
                          first_min_step,
                          sol1.x, sol1.y );
#endif
        }
    }
#endif

    int min_step = first_min_step;
    for ( AbstractPlayerCont::const_iterator
              o = wm.theirPlayers().begin(),
              end = wm.theirPlayers().end();
          o != end;
          ++o )
    {
        int step = predictOpponentReachStep( *o,
                                             first_ball_pos,
                                             first_ball_vel,
                                             ball_move_angle,
                                             min_step );
        if ( step < min_step )
        {
            min_step = step;
        }
    }

    return ( min_step == first_min_step
             ? 1000
             : min_step );
}
开发者ID:Aanal,项目名称:RobosoccerAttack-Athena,代码行数:58,代码来源:tackle_generator.cpp

示例9: drawHistoryLineGraph

void EconomyGraph::drawHistoryLineGraph( Painter& painter, Rect2D mg ){ 
    // see oldgui/screen.cpp do_history_linegraph 
    Vector2 a;
    Vector2 b;

    Color red, yellow, blue, brown, grey;
    red.parse( "red");
    yellow.parse( "yellow" );
    blue.parse( "blue" );
    brown.parse( "brown" );
    grey.parse("#A9A9A9FF");

    painter.setClipRectangle( mg ); 
    painter.setFillColor( grey );
    painter.fillRectangle( mg );
    int mgX = (int) mg.p1.x;
    int mgY = (int) mg.p1.y;
    int mgW = (int) mg.getWidth(); 
    int mgH = (int) mg.getHeight();
    
    float scale = (float) mgH / 64; //MONTHGRAPH_H  ;
    
    b.y = mgY + mgH;
    for( int i = mgW - 1; i >= 0; i-- ){
        painter.setLineColor( yellow );
        a.x = mgX + mgW - i;
        a.y = mgY + mgH - scale * monthgraph_nojobs[i];
        
        b.x = mgX + mgW - i;
        painter.drawLine( a, b );
        painter.setLineColor( red );
        a.y = mgY + mgH - scale * monthgraph_starve[i];
        painter.drawLine( a, b );
    }                  
    for( int i = mgW - 1; i > 0; i-- ){
        painter.setLineColor( brown );
        a.x = mgX + mgW - i;
        a.y = mgY + mgH - scale * monthgraph_pop[ i ];
        b.x = mgX + mgW - i-1;
        b.y = mgY + mgH - scale * monthgraph_pop[ i-1 ];
        painter.drawLine( a, b );
        a.y = mgY + mgH - scale * monthgraph_ppool[ i ];
        b.y = mgY + mgH - scale * monthgraph_ppool[ i-1 ];
        painter.setLineColor( blue );
        painter.drawLine( a, b );
    }
    painter.clearClipRectangle();


}
开发者ID:BackupTheBerlios,项目名称:lincity-ng-svn,代码行数:50,代码来源:EconomyGraph.cpp

示例10: setDirty

void
Component::setChildDirty(Component* childComponent, const Rect2D& area)
{
    for(Childs::const_iterator i = childs.begin(); i != childs.end(); ++i) {
        const Child& child = *i;
        if(child.getComponent() != childComponent)
            continue;

        Rect2D rect = area;
        rect.move(child.position);
        setDirty(rect);
        return;
    }

    assert(false);
}
开发者ID:SirIvanMoReau,项目名称:lincity-ng,代码行数:16,代码来源:Component.cpp

示例11: allocateTextures

    void allocateTextures(const Rect2D& screenRect) {
        if (depth.isNull() || 
            (depth->vector2Bounds() != screenRect.wh())) {
        
            Texture::Parameters parameters;
            parameters.autoMipMap = false;
            parameters.maxAnisotropy = 1;
            parameters.wrapMode = Texture::CLAMP;
            parameters.interpolateMode = Texture::NO_INTERPOLATION;

            depth = Texture::createEmpty("Depth Buffer", screenRect.width(), screenRect.height(),
                TextureFormat::depth(), Texture::DIM_2D_NPOT, parameters);

            shader->args.set("depth", depth);
        }
    }
开发者ID:luaman,项目名称:g3d-cpp,代码行数:16,代码来源:showdepth.cpp

示例12: glGetFloatv

void
PainterGL::setClipRectangle(const Rect2D& rect)
{
    GLfloat matrix[16];
    glGetFloatv(GL_MODELVIEW_MATRIX, matrix);

    int screenHeight = SDL_GetVideoSurface()->h;
    glViewport((GLint) (rect.p1.x + matrix[12]),
               (GLint) (screenHeight - rect.getHeight() - (rect.p1.y + matrix[13])),
               (GLsizei) rect.getWidth(),
               (GLsizei) rect.getHeight());
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrthof(rect.p1.x + matrix[12], rect.p1.x + matrix[12] + rect.getWidth(),
            rect.p1.y + matrix[13] + rect.getHeight(),
            rect.p1.y + matrix[13], -1, 1);
}
开发者ID:kobr4,项目名称:Lincity4droid,代码行数:17,代码来源:PainterGL.cpp

示例13: theme

void GuiRadioButton::setRect(const Rect2D& rect) {
    if (m_style == GuiTheme::NORMAL_RADIO_BUTTON_STYLE) {
        // Prevent the radio button from stealing clicks very far away
        m_rect = rect;
        m_clickRect = Rect2D::xywh(rect.x0y0(), theme()->bounds("AA"));
    } else {
        GuiControl::setRect(rect);
    }
}
开发者ID:jackpoz,项目名称:G3D-backup,代码行数:9,代码来源:GuiRadioButton.cpp

示例14: setDimensions

void SDLWindow::setDimensions(const Rect2D& dims) {
    #ifdef G3D_WIN32
        int W = screenWidth();
        int H = screenHeight();

        int x = iClamp((int)dims.x0(), 0, W);
        int y = iClamp((int)dims.y0(), 0, H);
        int w = iClamp((int)dims.width(), 1, W);
        int h = iClamp((int)dims.height(), 1, H);

        SetWindowPos(_Win32HWND, NULL, x, y, w, h, SWP_NOZORDER);
        // Do not update settings-- wait for an event to notify us
    #endif

	#ifdef G3D_LINUX
		//TODO: Linux
	#endif 

    // TODO: OS X
}
开发者ID:luaman,项目名称:g3d-cpp,代码行数:20,代码来源:SDLWindow.cpp

示例15: theme

GuiPane* GuiPane::addPane(const GuiText& text, GuiTheme::PaneStyle style) {
    Rect2D minRect = theme()->clientToPaneBounds(Rect2D::xywh(0,0,0,0), text, style);

    Vector2 pos = nextControlPos();

    // Back up by the border size
    pos -= minRect.x0y0();

    // Ensure the width isn't negative due to a very small m_clientRect
    // which would push the position off the parent panel
    float newRectWidth = max(m_clientRect.width() - pos.x * 2, 0.0f);

    Rect2D newRect = Rect2D::xywh(pos, Vector2(newRectWidth, minRect.height()));

    GuiPane* p = new GuiPane(this, text, newRect, style);

    containerArray.append(p);
    increaseBounds(p->rect().x1y1());

    return p;
}
开发者ID:A7med-Shoukry,项目名称:g3d,代码行数:21,代码来源:GuiPane.cpp


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