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


C++ BitmapRef::Clear方法代码示例

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


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

示例1: GenerateAutotiles

BitmapScreenRef TilemapLayer::GenerateAutotiles(int count, const std::map<uint32_t, TileXY>& map) {
	int rows = (count + TILES_PER_ROW - 1) / TILES_PER_ROW;
	BitmapRef tiles = Bitmap::Create(TILES_PER_ROW * TILE_SIZE, rows * TILE_SIZE);
	tiles->Clear();
	Rect rect(0, 0, TILE_SIZE/2, TILE_SIZE/2);

	std::map<uint32_t, TileXY>::const_iterator it;
	for (it = map.begin(); it != map.end(); ++it) {
		uint32_t quarters_hash = it->first;
		TileXY dst = it->second;

		// unpack the quarters data
		for (int j = 0; j < 2; j++) {
			for (int i = 0; i < 2; i++) {
				int x = quarters_hash >> 28;
				quarters_hash <<= 4;
				
				int y = quarters_hash >> 28;
				quarters_hash <<= 4;
				
				rect.x = (x * 2 + i) * (TILE_SIZE/2);
				rect.y = (y * 2 + j) * (TILE_SIZE/2);
				tiles->Blit((dst.x * 2 + i) * (TILE_SIZE/2), (dst.y * 2 + j) * (TILE_SIZE/2), *chipset, rect, 255);
			}
		}
	}

	return BitmapScreen::Create(tiles);
}
开发者ID:Shin-NiL,项目名称:Player,代码行数:29,代码来源:tilemap_layer.cpp

示例2: Sprite

void Scene_Battle_Rpg2k3::DrawFloatText(int x, int y, int color, const std::string& text, int _duration) {
	Rect rect = Font::Default()->GetSize(text);

	BitmapRef graphic = Bitmap::Create(rect.width, rect.height);
	graphic->Clear();
	graphic->TextDraw(-rect.x, -rect.y, color, text);

	Sprite* floating_text = new Sprite();
	floating_text->SetBitmap(graphic);
	floating_text->SetOx(rect.width / 2);
	floating_text->SetOy(rect.height + 5);
	floating_text->SetX(x);
	floating_text->SetY(y);
	floating_text->SetZ(500 + y);

	FloatText float_text = FloatText(EASYRPG_SHARED_PTR<Sprite>(floating_text), _duration);

	floating_texts.push_back(float_text);
}
开发者ID:t3573393,项目名称:Player,代码行数:19,代码来源:scene_battle_rpg2k3.cpp

示例3: Draw

void Text::Draw(Bitmap& dest, int x, int y, int color, std::string const& text, Text::Alignment align) {
    if (text.length() == 0) return;

    FontRef font = dest.GetFont();
    Rect dst_rect = Font::Default()->GetSize(text);

    switch (align) {
    case Text::AlignCenter:
        dst_rect.x = x - dst_rect.width / 2;
        break;
    case Text::AlignRight:
        dst_rect.x = x - dst_rect.width;
        break;
    case Text::AlignLeft:
        dst_rect.x = x;
        break;
    default:
        assert(false);
    }

    dst_rect.y = y;
    dst_rect.width += 1;
    dst_rect.height += 1; // Need place for shadow
    if (dst_rect.IsOutOfBounds(dest.GetWidth(), dest.GetHeight())) return;

    BitmapRef text_surface; // Complete text will be on this surface
    text_surface = Bitmap::Create(dst_rect.width, dst_rect.height, true);
    text_surface->SetTransparentColor(dest.GetTransparentColor());
    text_surface->Clear();

    // Load the system file for the shadow and text color
    BitmapRef system = Cache::System(Data::system.system_name);
    // Load the exfont-file
    BitmapRef exfont = Cache::Exfont();

    // Get the Shadow color
    Color shadow_color(Cache::system_info.sh_color);
    // If shadow is pure black, increase blue channel
    // so it doesn't become transparent
    if ((shadow_color.red == 0) &&
            (shadow_color.green == 0) &&
            (shadow_color.blue == 0) ) {

        if (text_surface->bytes() >= 3) {
            shadow_color.blue++;
        } else {
            shadow_color.blue += 8;
        }
    }

    // Where to draw the next glyph (x pos)
    int next_glyph_pos = 0;

    // The current char is an exfont
    bool is_exfont = false;

    // This loops always renders a single char, color blends it and then puts
    // it onto the text_surface (including the drop shadow)
    for (boost::u8_to_u32_iterator<std::string::const_iterator>
            c(text.begin(), text.begin(), text.end()),
            end(text.end(), text.begin(), text.end()); c != end; ++c) {
        Rect next_glyph_rect(next_glyph_pos, 0, 0, 0);

        boost::u8_to_u32_iterator<std::string::const_iterator> next_c_it = boost::next(c);
        uint32_t const next_c = std::distance(c, end) > 1? *next_c_it : 0;

        // ExFont-Detection: Check for A-Z or a-z behind the $
        if (*c == '$' && std::isalpha(next_c)) {
            int exfont_value = -1;
            // Calculate which exfont shall be rendered
            if (islower(next_c)) {
                exfont_value = 26 + next_c - 'a';
            } else if (isupper(next_c)) {
                exfont_value = next_c - 'A';
            } else {
                assert(false);
            }
            is_exfont = true;

            BitmapRef mask = Bitmap::Create(12, 12, true);

            // Get exfont from graphic
            Rect const rect_exfont((exfont_value % 13) * 12, (exfont_value / 13) * 12, 12, 12);

            // Create a mask
            mask->Clear();
            mask->Blit(0, 0, *exfont, rect_exfont, 255);

            // Get color region from system graphic
            Rect clip_system(8+16*(color%10), 4+48+16*(color/10), 6, 12);

            BitmapRef char_surface = Bitmap::Create(mask->GetWidth(), mask->GetHeight(), true);
            char_surface->SetTransparentColor(dest.GetTransparentColor());
            char_surface->Clear();

            // Blit gradient color background (twice because of full glyph)
            char_surface->Blit(0, 0, *system, clip_system, 255);
            char_surface->Blit(6, 0, *system, clip_system, 255);

            // Blit mask onto background
//.........这里部分代码省略.........
开发者ID:Bonstra,项目名称:EasyRPG-Player,代码行数:101,代码来源:text.cpp


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