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


C++ DrawingContext::get_width方法代码示例

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


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

示例1: int

void
LevelTime::draw(DrawingContext& context)
{
  context.push_transform();
  context.set_translation(Vector(0, 0));

  if ((time_left > TIME_WARNING) || (int(game_time * 2.5) % 2)) {
    std::stringstream ss;
    ss << int(time_left);
    std::string time_text = ss.str();

    if (time_surface)
    {
      float all_width = static_cast<float>(time_surface->get_width()) + Resources::normal_font->get_text_width(time_text);
      context.color().draw_surface(time_surface,
                                   Vector((static_cast<float>(context.get_width()) - all_width) / 2.0f,
                                          BORDER_Y + 1),
                                   LAYER_FOREGROUND1);
      context.color().draw_text(Resources::normal_font, time_text,
                                Vector((static_cast<float>(context.get_width()) - all_width) / 2.0f + static_cast<float>(time_surface->get_width()),
                                       BORDER_Y),
                                ALIGN_LEFT, LAYER_FOREGROUND1, LevelTime::text_color);
    }
  }

  context.pop_transform();
}
开发者ID:brmbrmcar,项目名称:supertux,代码行数:27,代码来源:level_time.cpp

示例2: Copyright

void
PingusMenu::draw_background(DrawingContext& gc)
{
  background->draw(gc);

  gc.draw(logo, Vector2i((gc.get_width()/2) - (logo.get_width()/2),
                         gc.get_height()/2 - 280));

  gc.print_left(Fonts::pingus_small, Vector2i(gc.get_width()/2 - 400 + 25, gc.get_height()-140),
                "Pingus " VERSION " - Copyright (C) 1998-2011 Ingo Ruhnke <[email protected]>\n"
                "See the file AUTHORS for a complete list of contributors.\n"
                "Pingus comes with ABSOLUTELY NO WARRANTY. This is free software, and you are\n"
                "welcome to redistribute it under certain conditions; see the file COPYING for details.\n");

  gc.draw_fillrect(Rect(0,
                        Display::get_height () - 26,
                        Display::get_width (),
                        Display::get_height ()),
                   Color(0, 0, 0, 255));

  gc.print_center(Fonts::pingus_small,
                  Vector2i(gc.get_width() / 2,
                           gc.get_height() - Fonts::pingus_small.get_height() - 8),
                  help);

  if (0) // display hint
  {
    gc.print_center(Fonts::pingus_small,
                    Vector2i(gc.get_width() / 2,
                             gc.get_height() - Fonts::pingus_small.get_height()),
                    hint);
  }
}
开发者ID:drewbug,项目名称:pingus,代码行数:33,代码来源:pingus_menu.cpp

示例3: int

void
SmallMap::draw(DrawingContext& gc)
{
  // FIXME: This is potentially dangerous, since we don't know how
  // long 'gc' will be alive. Should use a DrawingContext for caching.
  gc_ptr = &gc;

  World* const& world  = server->get_world();

  Vector2i of = playfield->get_pos();
  Rect view_rect;

  if (world->get_width() > gc.get_width())
  {
    int rwidth = int(gc.get_width()  * rect.get_width()  / world->get_width());
    view_rect.left  = rect.left + (of.x * rect.get_width()  / world->get_width()) - rwidth/2;
    view_rect.right = view_rect.left + rwidth;
  }
  else
  {
    view_rect.left  = rect.left;
    view_rect.right = rect.left + rect.get_width();
  }

  if (world->get_height() > gc.get_height())
  {
    int rheight = int(gc.get_height() * rect.get_height() / world->get_height());
    view_rect.top    = rect.top + (of.y * rect.get_height() / world->get_height()) - rheight/2;
    view_rect.bottom = view_rect.top + rheight;
  }
  else
  {
    view_rect.top    = rect.top;
    view_rect.bottom = rect.top + rect.get_height();
  }

  gc.draw(image->get_surface(), Vector2i(rect.left, rect.top));
  gc.draw_rect(view_rect, Color(0, 255, 0));

  server->get_world()->draw_smallmap(this);

  // Draw Pingus
  PinguHolder* pingus = world->get_pingus();
  for(PinguIter i = pingus->begin(); i != pingus->end(); ++i)
  {
    int x = static_cast<int>(static_cast<float>(rect.left) + ((*i)->get_x() * static_cast<float>(rect.get_width())
                                                              / static_cast<float>(world->get_width())));
    int y = static_cast<int>(static_cast<float>(rect.top)  + ((*i)->get_y() * static_cast<float>(rect.get_height())
                                                              / static_cast<float>(world->get_height())));

    gc.draw_line(Vector2i(x, y), Vector2i(x, y-2), Color(255, 255, 0));
  }

  gc_ptr = 0;
}
开发者ID:drewbug,项目名称:pingus,代码行数:55,代码来源:smallmap.cpp

示例4: snprintf

void
ScreenManager::draw_fps(DrawingContext& context, float fps_fps)
{
  char str[60];
  snprintf(str, sizeof(str), "%3.1f", fps_fps);
  const char* fpstext = "FPS";
  context.color().draw_text(
    Resources::small_font, fpstext,
    Vector(static_cast<float>(context.get_width()) - Resources::small_font->get_text_width(fpstext) - Resources::small_font->get_text_width(" 99999") - BORDER_X,
           BORDER_Y + 20), ALIGN_LEFT, LAYER_HUD);
  context.color().draw_text(Resources::small_font, str, Vector(static_cast<float>(context.get_width()) - BORDER_X, BORDER_Y + 20), ALIGN_RIGHT, LAYER_HUD);
}
开发者ID:maxteufel,项目名称:supertux,代码行数:12,代码来源:screen_manager.cpp

示例5:

void
StoryScreenComponent::draw (DrawingContext& gc)
{
  gc.draw(background, Vector2i(gc.get_width()/2, gc.get_height()/2));

  gc.print_center(Fonts::chalk_large, Display::get_width()/2,
                  Display::get_height()/2 - 200, story->get_title());
  gc.draw(page_surface, Vector2i(gc.get_width()/2, gc.get_height()/2 - 65));

  gc.print_left(Fonts::chalk_normal,
                Display::get_width()/2  - 280,
                Display::get_height()/2 + 35,
                display_text);
}
开发者ID:jinguoliang,项目名称:Maemo-pingus,代码行数:14,代码来源:story_screen.cpp

示例6: switch

void
Credits::draw_background (DrawingContext& gc)
{
  {
    // Paint the background wood panel
    for(int y = 0; y < gc.get_height(); y += background.get_height())
      for(int x = 0; x < gc.get_width(); x += background.get_width())
        gc.draw(background, Vector2i(x, y));
  }

  int x;
  int y;
  int yof;

  x = Display::get_width()/2;
  y = static_cast<int>(offset);

  gc.draw(blackboard, Vector2i(gc.get_width()/2, gc.get_height()/2));

  gc.draw(pingu, Vector2i(gc.get_width()/2, gc.get_height()/2 - 20));

  yof = 0;

  scene_context->clear();
  scene_context->set_cliprect(Rect(gc.get_width()/2 - 685/2, gc.get_height()/2 - 250,
                                   gc.get_width()/2 + 685/2, gc.get_height()/2 + 250));

  for (std::vector<std::string>::iterator i = credits.begin(); i != credits.end(); ++i)
  {
    switch ((*i)[0])
    {
      case '-':
        scene_context->color().print_center(font, Vector2i(x, (y + yof)), i->substr(1));
        yof += font.get_height() + 5;
        break;
      case '_':
        scene_context->color().print_center(font_small, Vector2i(x, (y + yof)), i->substr(1));
        yof += font_small.get_height() + 5;
        break;
      case 'n':
        yof += 50;
        break;
      default:
        log_error("Credits: Syntax error: Unknown format: '%1%'", (*i)[0]);
        break;
    }
  }
  gc.draw(new SceneContextDrawingRequest(scene_context.get(), Vector2i(0,0), 100));
}
开发者ID:drewbug,项目名称:pingus,代码行数:49,代码来源:credits.cpp

示例7:

void
OptionMenu::draw_background(DrawingContext& gc)
{
  gc.fill_screen(Color(0, 0, 0));

  // gc.draw_fillrect(Rect(100, 100, 400, 400), Color(255, 0, 0));
  gc.draw(background, Vector2i(gc.get_width()/2 - background.get_width()/2, gc.get_height()/2 - background.get_height()/2));

  gc.print_center(Fonts::chalk_large,
                  Vector2i(gc.get_width()/2,
                           gc.get_height()/2 - 210),
                  _("Option Menu"));

  gc.print_center(Fonts::chalk_normal, Vector2i(gc.get_width()/2 + 225 + 30, gc.get_height()/2 + 125 - 20), _("Close"));
}
开发者ID:jcs12311,项目名称:pingus,代码行数:15,代码来源:option_menu.cpp

示例8: if

void
LevelDot::draw_hover(DrawingContext& gc)
{
  int pos_correction = 0;

  if (accessible())
  {
    int length = Fonts::pingus_small.bounding_rect(0, 0, _(get_plf().get_levelname())).get_width() / 2;
    int realpos = gc.world_to_screen(Vector2i(static_cast<int>(pos.x), static_cast<int>(pos.y))).x;
    if (realpos - length < 0)
      pos_correction = realpos - length;
    else if (realpos + length > gc.get_width())
      pos_correction = realpos + length - static_cast<int>(gc.get_width());
      
    gc.print_center(Fonts::pingus_small,
                    Vector2i(static_cast<int>(pos.x) - pos_correction,
                             static_cast<int>(pos.y) - 44),
                    _(get_plf().get_levelname()), 
                    10000);
  }
  else
  {
    int length  = Fonts::pingus_small.bounding_rect(0, 0, _("locked")).get_width() / 2;
    int realpos = gc.world_to_screen(Vector2i(static_cast<int>(pos.x), static_cast<int>(pos.y))).x;
    if (realpos - length < 0)
      pos_correction = realpos - length;
    else if (realpos + length > gc.get_width())
      pos_correction = realpos + length - static_cast<int>(gc.get_width());
        
    gc.print_center(Fonts::pingus_small,
                    Vector2i(static_cast<int>(pos.x) - pos_correction,
                             static_cast<int>(pos.y) - 30),
                    _("locked"), 
                    10000);
  }

  if (globals::maintainer_mode)
  {
    gc.print_center(Fonts::pingus_small,
                    Vector2i(static_cast<int>(pos.x), static_cast<int>(pos.y) - 56),
                    get_plf().get_resname(), 
                    10000);
  }
}
开发者ID:jcs12311,项目名称:pingus,代码行数:44,代码来源:level_dot.cpp

示例9:

void
AddOnMenu::draw_background(DrawingContext& gc)
{
  // gc.draw_fillrect(Rect(100, 100, 400, 400), Color(255, 0, 0));
  gc.draw(background, Vector2i(gc.get_width()/2, gc.get_height()/2));

  gc.print_center(Fonts::chalk_large, Vector2i(gc.get_width()/2, 90), "Add-On Menu");

  gc.print_left(Fonts::chalk_normal, Vector2i(120, 145), "X-Mas Pingus Sprites");
  gc.print_left(Fonts::chalk_small,  Vector2i(140, 170), "christmas look for penguins");
  gc.print_left(Fonts::chalk_small,  Vector2i(140, 190), "Author: John Foo <[email protected]>");

  gc.print_center(Fonts::chalk_normal, Vector2i(gc.get_width()/2, gc.get_height()/2 + 160), "Update Online [ ]");

  gc.print_center(Fonts::chalk_normal, Vector2i(gc.get_width()/2 + 245 + 30, gc.get_height()/2 + 150 - 20), _("Close"));
  gc.draw(ok_button, Vector2i(gc.get_width()/2 + 245, gc.get_height()/2 + 150));

  gc.draw(ok_button, Vector2i(610, 145));
}
开发者ID:AMDmi3,项目名称:pingus,代码行数:19,代码来源:addon_menu.cpp

示例10:

void
StoryScreenComponent::draw (DrawingContext& gc)
{
  // Paint the background wood panel
  for(int y = 0; y < gc.get_height(); y += background.get_height())
    for(int x = 0; x < gc.get_width(); x += background.get_width())
      gc.draw(background, Vector2i(x, y));

  gc.draw(blackboard, Vector2i(gc.get_width()/2, gc.get_height()/2));

  gc.print_center(Fonts::chalk_large, 
                  Vector2i(gc.get_width()/2, gc.get_height()/2 - 200), 
                  story->get_title());
  gc.draw(page_surface, Vector2i(gc.get_width()/2, gc.get_height()/2 - 65));

  gc.print_left(Fonts::chalk_normal,
                Vector2i(gc.get_width()/2  - 280,
                         gc.get_height()/2 + 35),
                display_text);
}
开发者ID:jcs12311,项目名称:pingus,代码行数:20,代码来源:story_screen.cpp

示例11: Vector

void
PlayerStatus::draw(DrawingContext& context)
{
  int player_id = 0;

  if ((displayed_coins == DISPLAYED_COINS_UNSET) ||
      (std::abs(displayed_coins - coins) > 100)) {
    displayed_coins = coins;
    displayed_coins_frame = 0;
  }
  if (++displayed_coins_frame > 2) {
    displayed_coins_frame = 0;
    if (displayed_coins < coins) displayed_coins++;
    if (displayed_coins > coins) displayed_coins--;
  }
  displayed_coins = std::min(std::max(displayed_coins, 0), MAX_COINS);

  std::stringstream ss;
  ss << displayed_coins;
  std::string coins_text = ss.str();

  context.push_transform();
  context.set_translation(Vector(0, 0));

  if (coin_surface)
  {
    context.color().draw_surface(coin_surface,
                                 Vector(static_cast<float>(context.get_width()) - BORDER_X - static_cast<float>(coin_surface->get_width()) - Resources::fixed_font->get_text_width(coins_text),
                                        BORDER_Y + 1.0f + (Resources::fixed_font->get_text_height(coins_text) + 5) * static_cast<float>(player_id)),
                                   LAYER_HUD);
  }
  context.color().draw_text(Resources::fixed_font,
                            coins_text,
                            Vector(static_cast<float>(context.get_width()) - BORDER_X - Resources::fixed_font->get_text_width(coins_text),
                                   BORDER_Y + (Resources::fixed_font->get_text_height(coins_text) + 5.0f) * static_cast<float>(player_id)),
                            ALIGN_LEFT,
                            LAYER_HUD,
                            PlayerStatus::text_color);

  context.pop_transform();
}
开发者ID:maxteufel,项目名称:supertux,代码行数:41,代码来源:player_status.cpp

示例12:

void
OptionMenu::draw_background(DrawingContext& gc)
{
  // Paint the background wood panel
  for(int y = 0; y < gc.get_height(); y += m_background.get_height())
    for(int x = 0; x < gc.get_width(); x += m_background.get_width())
      gc.draw(m_background, Vector2i(x, y));

  // gc.draw_fillrect(Rect(100, 100, 400, 400), Color(255, 0, 0));
  gc.draw(m_blackboard, Vector2i(gc.get_width()/2, gc.get_height()/2));

  gc.print_center(Fonts::chalk_large,
                  Vector2i(gc.get_width()/2,
                           gc.get_height()/2 - 240),
                  _("Option Menu"));

  gc.print_center(Fonts::chalk_normal, Vector2i(gc.get_width()/2 + 245 + 30, gc.get_height()/2 + 150 - 20), _("Close"));

  gc.print_left(Fonts::chalk_normal, 
                Vector2i(gc.get_width()/2 - 320, gc.get_height()/2 + 200),
                _("Some options require a restart of the game to take effect."));
}
开发者ID:xarnze,项目名称:pingus,代码行数:22,代码来源:option_menu.cpp

示例13: Vector

void
EditorToolboxWidget::draw(DrawingContext& context)
{
  //SCREEN_WIDTH SCREEN_HEIGHT
  context.color().draw_filled_rect(Rectf(Vector(static_cast<float>(m_Xpos), 0),
                                         Vector(static_cast<float>(context.get_width()),
                                                static_cast<float>(context.get_height()))),
                                     Color(0.9f, 0.9f, 1.0f, 0.6f),
                                     0.0f, LAYER_GUI-10);
  if (m_dragging) {
    context.color().draw_filled_rect(selection_draw_rect(), Color(0.2f, 0.4f, 1.0f, 0.6f),
                                       0.0f, LAYER_GUI+1);
  }

  if (m_hovered_item != HoveredItem::NONE)
  {
    context.color().draw_filled_rect(get_item_rect(m_hovered_item),
                                       Color(0.9f, 0.9f, 1.0f, 0.6f),
                                       0.0f, LAYER_GUI - 5);
  }

  context.color().draw_text(Resources::normal_font, _("Tilegroups"),
                            Vector(static_cast<float>(context.get_width()), 0),
                            ALIGN_RIGHT, LAYER_GUI, ColorScheme::Menu::default_color);
  context.color().draw_text(Resources::normal_font, _("Objects"),
                            Vector(static_cast<float>(context.get_width()), 24),
                            ALIGN_RIGHT, LAYER_GUI, ColorScheme::Menu::default_color);

  m_rubber->draw(context);
  m_select_mode->draw(context);
  m_move_mode->draw(context);
  m_settings_mode->draw(context);

  draw_tilegroup(context);
  draw_objectgroup(context);
}
开发者ID:pelya,项目名称:supertux,代码行数:36,代码来源:toolbox_widget.cpp

示例14: Vector

void
Thunderstorm::draw(DrawingContext& context)
{
  if (!flash_display_timer.started()) return;

  float alpha = 0.33f;
  context.push_transform();
  context.set_translation(Vector(0, 0));
  context.color().draw_filled_rect(Vector(0, 0),
                                   Vector(static_cast<float>(context.get_width()),
                                          static_cast<float>(context.get_height())),
                                   Color(1, 1, 1, alpha), layer);
  context.pop_transform();

}
开发者ID:maxteufel,项目名称:supertux,代码行数:15,代码来源:thunderstorm.cpp

示例15: Vector

void
ScreenManager::draw_player_pos(DrawingContext& context)
{
  if (auto session = GameSession::current())
  {
    auto sector = session->get_current_sector();
    if (sector == nullptr)
      return;
    auto pos = sector->get_players()[0]->get_pos();
    auto pos_text = "X:" + std::to_string(int(pos.x)) + " Y:" + std::to_string(int(pos.y));

    context.color().draw_text(
      Resources::small_font, pos_text,
      Vector(static_cast<float>(context.get_width()) - Resources::small_font->get_text_width("99999x99999") - BORDER_X,
             BORDER_Y + 40.0f), ALIGN_LEFT, LAYER_HUD);
  }
}
开发者ID:maxteufel,项目名称:supertux,代码行数:17,代码来源:screen_manager.cpp


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