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


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

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


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

示例1: text_rect

void
Menu::draw(DrawingContext& context)
{
  if (!items[active_item]->help.empty())
  {
    int text_width  = (int) Resources::normal_font->get_text_width(items[active_item]->help);
    int text_height = (int) Resources::normal_font->get_text_height(items[active_item]->help);

    Rectf text_rect(pos.x - text_width/2 - 8,
                   SCREEN_HEIGHT - 48 - text_height/2 - 4,
                   pos.x + text_width/2 + 8,
                   SCREEN_HEIGHT - 48 + text_height/2 + 4);

    context.draw_filled_rect(Rectf(text_rect.p1 - Vector(4,4),
                                   text_rect.p2 + Vector(4,4)),
                             Color(0.2f, 0.3f, 0.4f, 0.8f),
                             16.0f,
                             LAYER_GUI-10);

    context.draw_filled_rect(text_rect,
                             Color(0.6f, 0.7f, 0.8f, 0.5f),
                             16.0f,
                             LAYER_GUI-10);

    context.draw_text(Resources::normal_font, items[active_item]->help,
                      Vector(pos.x, SCREEN_HEIGHT - 48 - text_height/2),
                      ALIGN_CENTER, LAYER_GUI);
  }

  for(unsigned int i = 0; i < items.size(); ++i)
  {
    draw_item(context, i);
  }
}
开发者ID:CRS-ECHO51,项目名称:supertux,代码行数:34,代码来源:menu.cpp

示例2: Vector

void
EditorLayersGui::draw(DrawingContext& context) {

  if (object_tip) {
    object_tip->draw_up(context, get_layer_coords(hovered_layer));
  }

  context.draw_filled_rect(Rectf(Vector(0, Ypos), Vector(Width, SCREEN_HEIGHT)),
                           Color(0.9f, 0.9f, 1.0f, 0.6f),
                           0.0f,
                           LAYER_GUI-10);

  switch (hovered_item) {
    case HI_SPAWNPOINTS:
      context.draw_filled_rect(Rectf(Vector(0, Ypos), Vector(Xpos, SCREEN_HEIGHT)),
                               Color(0.9f, 0.9f, 1.0f, 0.6f),
                               0.0f,
                               LAYER_GUI-5);
      break;
    case HI_SECTOR:
      context.draw_filled_rect(Rectf(Vector(Xpos, Ypos), Vector(sector_text_width + Xpos, SCREEN_HEIGHT)),
                               Color(0.9f, 0.9f, 1.0f, 0.6f),
                               0.0f,
                               LAYER_GUI-5);
      break;
    case HI_LAYERS: {
      Vector coords = get_layer_coords(hovered_layer);
      context.draw_filled_rect(Rectf(coords, coords + Vector(32, 32)),
                               Color(0.9f, 0.9f, 1.0f, 0.6f),
                               0.0f,
                               LAYER_GUI-5);
    } break;
    default: break;
  }

  if (!Editor::current()->levelloaded) {
    return;
  }

  context.draw_text(Resources::normal_font, sector_text,
                    Vector(35, Ypos+5),
                    ALIGN_LEFT, LAYER_GUI, ColorScheme::Menu::default_color);

  int pos = 0;
  for(auto it = layers.begin(); it != layers.end(); ++it) {
    LayerIcon* layer_icon = (*it).get();
    if (layer_icon->is_valid()) {
      layer_icon->draw(context, get_layer_coords(pos));
    } else {
      auto it2 = it;
      it++;
      layers.erase(it2);
      it--;
    }
    pos++;
  }

}
开发者ID:kerou,项目名称:supertux,代码行数:58,代码来源:layers_gui.cpp

示例3: Vector

void
ItemBack::draw(DrawingContext& context, Vector pos, int menu_width, bool active) {
  float text_width = Resources::normal_font->get_text_width(text);
  context.draw_text(Resources::normal_font, text,
                    Vector( pos.x + menu_width/2 , pos.y - int(Resources::normal_font->get_height()/2)),
                    ALIGN_CENTER, LAYER_GUI, active ? ColorScheme::Menu::active_color : get_color());
  context.draw_surface(Resources::back,
                       Vector(pos.x + menu_width/2 + text_width/2  + 16, pos.y - 8),
                       LAYER_GUI);
}
开发者ID:CRS-ECHO51,项目名称:supertux,代码行数:10,代码来源:item_back.cpp

示例4: Vector

void
ItemStringSelect::draw(DrawingContext& context, const Vector& pos, int menu_width, bool active) {
  float roff = Resources::arrow_left->get_width();
  float sel_width = Resources::normal_font->get_text_width(list[*selected]);
  // Draw left side
  context.draw_text(Resources::normal_font, text,
                    Vector(pos.x + 16, pos.y - int(Resources::normal_font->get_height()/2)),
                    ALIGN_LEFT, LAYER_GUI, active ? ColorScheme::Menu::active_color : get_color());

  // Draw right side
  context.draw_surface(Resources::arrow_left,
                       Vector(pos.x + menu_width - sel_width - 2*roff - 8, pos.y - 8),
                       LAYER_GUI);
  context.draw_surface(Resources::arrow_right,
                       Vector(pos.x + menu_width - roff - 8, pos.y - 8),
                       LAYER_GUI);
  context.draw_text(Resources::normal_font, list[*selected],
                    Vector(pos.x + menu_width - roff - 8, pos.y - int(Resources::normal_font->get_height()/2)),
                    ALIGN_RIGHT, LAYER_GUI, active ? ColorScheme::Menu::active_color : get_color());
}
开发者ID:leper,项目名称:supertux,代码行数:20,代码来源:item_stringselect.cpp

示例5: Vector

void
TitleScreen::draw(DrawingContext& context)
{
  Sector* sector  = titlesession->get_current_sector();
  sector->draw(context);

  // FIXME: Add something to scale the frame to the resolution of the screen
  //context.draw_surface(frame, Vector(0,0),LAYER_FOREGROUND1);

  context.draw_text(Resources::small_font, "SuperTux " PACKAGE_VERSION "\n",
                    Vector(5, SCREEN_HEIGHT - 50), ALIGN_LEFT, LAYER_FOREGROUND1);
  context.draw_text(Resources::small_font,
                    _(
                      "Copyright (c) 2003-2010 SuperTux Devel Team\n"
                      "This game comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to\n"
                      "redistribute it under certain conditions; see the file COPYING for details.\n"
                      ),
                    Vector(5, SCREEN_HEIGHT - 50 + Resources::small_font->get_height() + 5),
                    ALIGN_LEFT, LAYER_FOREGROUND1);
}
开发者ID:ed00m,项目名称:supertux,代码行数:20,代码来源:title_screen.cpp

示例6: Vector

void
ItemScriptLine::draw(DrawingContext& context, Vector pos, int menu_width, bool active) {
  std::string r_input = *input;
  auto font = Console::current()->get_font();
  bool fl = active && (int(real_time*2)%2);
  if ( fl ) {
    r_input += "_";
  }
  context.draw_text(font, r_input, Vector(pos.x + 16, pos.y - int(font->get_height()/2)),
                    ALIGN_LEFT, LAYER_GUI, ColorScheme::Menu::field_color);
}
开发者ID:ChristophKuhfuss,项目名称:supertux,代码行数:11,代码来源:item_script_line.cpp

示例7: Vector

void
Statistics::draw_message_info(DrawingContext& context, std::string title)
{
  // skip draw if level was never played
  // TODO: do we need this?
  if (coins == nv_coins) return;

  // skip draw if stats were declared invalid
  if (!valid) return;

  const float width = white_small_text->get_text_width("Max coins collected: 1111 / 1111");
  const float left = (SCREEN_WIDTH - width) / 2;
  const float right = (SCREEN_WIDTH + width) / 2;

  context.draw_text(gold_text, title, Vector(SCREEN_WIDTH/2, 410), CENTER_ALLIGN, LAYER_GUI);

  char stat_buf[128];
  int py = 450 + 18;

  snprintf(stat_buf, sizeof(stat_buf), "%d/%d", coins, total_coins);
  context.draw_text(white_small_text, _("Max coins collected:"), Vector(left, py), LEFT_ALLIGN, LAYER_GUI);
  context.draw_text(white_small_text, "%d / %d", Vector(right, py), RIGHT_ALLIGN, LAYER_GUI);
  py+=18;

  snprintf(stat_buf, sizeof(stat_buf), "%d/%d", badguys, total_badguys);
  context.draw_text(white_small_text, _("Max fragging:"), Vector(left, py), LEFT_ALLIGN, LAYER_GUI);
  context.draw_text(white_small_text, "%d / %d", Vector(right, py), RIGHT_ALLIGN, LAYER_GUI);
  py+=18;

  int csecs = (int)(time * 100);
  int mins = (int)(csecs / 6000);
  int secs = (csecs % 6000) / 100;
  snprintf(stat_buf, sizeof(stat_buf), "%02d:%02d", mins,secs);
  context.draw_text(white_small_text, _("Min time needed:"), Vector(left, py), LEFT_ALLIGN, LAYER_GUI);
  context.draw_text(white_small_text, "%02d:%02d", Vector(right, py), RIGHT_ALLIGN, LAYER_GUI);
  py+=18;

  snprintf(stat_buf, sizeof(stat_buf), "%d/%d", secrets, total_secrets);
  context.draw_text(white_small_text, _("Max secrets found:"), Vector(left, py), LEFT_ALLIGN, LAYER_GUI);
  context.draw_text(white_small_text, "%d / %d", Vector(right, py), RIGHT_ALLIGN, LAYER_GUI);
  py+=18;
}
开发者ID:BackupTheBerlios,项目名称:supertux-svn,代码行数:42,代码来源:statistics.cpp

示例8: Vector

void
LayerIcon::draw(DrawingContext& context, Vector pos) {
  if (!is_valid()) return;

  ObjectIcon::draw(context,pos);
  int l = get_zpos();
  if (l != std::numeric_limits<int>::min()) {
    context.draw_text(Resources::small_font, std::to_string(l),
                      pos + Vector(16,16),
                      ALIGN_CENTER, LAYER_GUI, ColorScheme::Menu::default_color);
    if (is_tilemap) if (((TileMap*)layer)->editor_active) {
      context.draw_surface(selection, pos, LAYER_GUI - 1);
    }
  }
}
开发者ID:ChristophKuhfuss,项目名称:supertux,代码行数:15,代码来源:layer_icon.cpp

示例9: Vector

void
ItemToggle::draw(DrawingContext& context, const Vector& pos, int menu_width, bool active) {
  context.draw_text(Resources::normal_font, text,
                    Vector(pos.x + 16, pos.y - (Resources::normal_font->get_height()/2)),
                    ALIGN_LEFT, LAYER_GUI, active ? ColorScheme::Menu::active_color : get_color());

  if(*toggled) {
    context.draw_surface(Resources::checkbox_checked,
                         Vector(pos.x + menu_width-16 - Resources::checkbox->get_width(), pos.y - 8),
                         LAYER_GUI + 1);
  } else {
    context.draw_surface(Resources::checkbox,
                         Vector(pos.x + menu_width-16 - Resources::checkbox->get_width(), pos.y - 8),
                         LAYER_GUI + 1);
  }
}
开发者ID:christ2go,项目名称:supertux,代码行数:16,代码来源:item_toggle.cpp

示例10: Vector

void
ScreenManager::draw_player_pos(DrawingContext& context)
{
  if (auto session = GameSession::current())
  {
    auto sector = session->get_current_sector();
    if (sector == NULL)
      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.draw_text(Resources::small_font, pos_text,
                      Vector(SCREEN_WIDTH - Resources::small_font->get_text_width("99999x99999") - BORDER_X,
                             BORDER_Y + 40), ALIGN_LEFT, LAYER_HUD);
  }
}
开发者ID:Karkus476,项目名称:supertux,代码行数:16,代码来源:screen_manager.cpp

示例11: int

void
FloatingText::draw(DrawingContext& context)
{
  // make an alpha animation when disappearing
  int alpha;
  if(timer.get_timeleft() < FADING_TIME)
    alpha = int(timer.get_timeleft() * 255 / FADING_TIME);
  else
    alpha = 255;

  context.push_transform();
  context.set_alpha(alpha);

  context.draw_text(Resources::normal_font, text, position, ALIGN_LEFT, LAYER_OBJECTS+1, FloatingText::text_color);

  context.pop_transform();
}
开发者ID:CRS-ECHO51,项目名称:supertux,代码行数:17,代码来源:floating_text.cpp

示例12: 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.draw_surface(coin_surface,
                         Vector(SCREEN_WIDTH - BORDER_X - coin_surface->get_width() - Resources::fixed_font->get_text_width(coins_text),
                                BORDER_Y + 1 + (Resources::fixed_font->get_text_height(coins_text) + 5) * player_id),
                         LAYER_HUD);
  }
  context.draw_text(Resources::fixed_font,
                    coins_text,
                    Vector(SCREEN_WIDTH - BORDER_X - Resources::fixed_font->get_text_width(coins_text),
                           BORDER_Y + (Resources::fixed_font->get_text_height(coins_text) + 5) * player_id),
                    ALIGN_LEFT,
                    LAYER_HUD,
                    PlayerStatus::text_color);

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

示例13: if

void
TileSet::draw_tile(DrawingContext& context, uint32_t id, const Vector& pos,
                   int z_pos, Color color) const
{
  if (id == 0) return;
  Tile* tile;
  if (id >= m_tiles.size()) {
    tile = NULL;
  } else {
    tile = m_tiles[id].get();
  }

  if (tile) {
    tile->load_images();
    tile->draw(context, pos, z_pos, color);
  } else if (Editor::is_active()) { // Draw a notile sign
    context.draw_surface(notile_surface, pos, 0, color, Blend(), z_pos);
    context.draw_text(Resources::small_font, std::to_string(id),
                      pos + Vector(16, 16), ALIGN_CENTER, z_pos, color);
  }
}
开发者ID:ChristophKuhfuss,项目名称:supertux,代码行数:21,代码来源:tile_set.cpp

示例14: 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 = time_surface->get_width() + Resources::normal_font->get_text_width(time_text);
      context.draw_surface(time_surface, Vector((SCREEN_WIDTH - all_width)/2, BORDER_Y + 1), LAYER_FOREGROUND1);
      context.draw_text(Resources::normal_font, time_text,
                        Vector((SCREEN_WIDTH - all_width)/2 + time_surface->get_width(), BORDER_Y),
                        ALIGN_LEFT, LAYER_FOREGROUND1, LevelTime::text_color);
    }
  }

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

示例15: bg_rect

void
Dialog::draw(DrawingContext& ctx)
{
  Rectf bg_rect(Vector(SCREEN_WIDTH/2 - m_text_size.width/2,
                       SCREEN_HEIGHT/2 - m_text_size.height/2),
                Sizef(m_text_size.width,
                      m_text_size.height + 44));

  // draw background rect
  ctx.draw_filled_rect(bg_rect.grown(12.0f),
                       Color(0.2f, 0.3f, 0.4f, 0.8f),
                       16.0f,
                       LAYER_GUI-10);

  ctx.draw_filled_rect(bg_rect.grown(8.0f),
                       Color(0.6f, 0.7f, 0.8f, 0.5f),
                       16.0f,
                       LAYER_GUI-10);

  // draw text
  ctx.draw_text(Resources::normal_font, m_text,
                Vector(bg_rect.p1.x + bg_rect.get_width()/2.0f,
                       bg_rect.p1.y),
                ALIGN_CENTER, LAYER_GUI);

  // draw HL line
  ctx.draw_filled_rect(Vector(bg_rect.p1.x, bg_rect.p2.y - 35),
                       Vector(bg_rect.get_width(), 4),
                       Color(0.6f, 0.7f, 1.0f, 1.0f), LAYER_GUI);
  ctx.draw_filled_rect(Vector(bg_rect.p1.x, bg_rect.p2.y - 35),
                       Vector(bg_rect.get_width(), 2),
                       Color(1.0f, 1.0f, 1.0f, 1.0f), LAYER_GUI);

  // draw buttons
  for(int i = 0; i < static_cast<int>(m_buttons.size()); ++i)
  {
    float segment_width = bg_rect.get_width() / m_buttons.size();
    float button_width = segment_width;
    float button_height = 24.0f;
    Vector pos(bg_rect.p1.x + segment_width/2.0f + i * segment_width,
               bg_rect.p2.y - 12);

    if (i == m_selected_button)
    {
      float blink = (sinf(real_time * M_PI * 1.0f)/2.0f + 0.5f) * 0.5f + 0.25f;
      ctx.draw_filled_rect(Rectf(Vector(pos.x - button_width/2, pos.y - button_height/2),
                                 Vector(pos.x + button_width/2, pos.y + button_height/2)).grown(2.0f),
                           Color(1.0f, 1.0f, 1.0f, blink),
                           14.0f,
                           LAYER_GUI-10);
      ctx.draw_filled_rect(Rectf(Vector(pos.x - button_width/2, pos.y - button_height/2),
                                 Vector(pos.x + button_width/2, pos.y + button_height/2)),
                           Color(1.0f, 1.0f, 1.0f, 0.5f),
                           12.0f,
                           LAYER_GUI-10);
    }

    ctx.draw_text(Resources::normal_font, m_buttons[i].text,
                  Vector(pos.x, pos.y - int(Resources::normal_font->get_height()/2)),
                  ALIGN_CENTER, LAYER_GUI,
                  i == m_selected_button ? ColorScheme::Menu::active_color : ColorScheme::Menu::default_color);
  }
}
开发者ID:huzongyao,项目名称:AndroidSuperTux,代码行数:63,代码来源:dialog.cpp


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