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


C++ Image::DrawTiled方法代码示例

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


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

示例1: Draw

/**\brief Draws the StatusBar
 * \param x x-coordinate
 * \param y y-coordinate
 *
 * \bug This can segfault with an empty title.
 */
void StatusBar::Draw(int x, int y) {
	int widthRemaining = this->width;
	Image *BorderLeft = Image::Get( "Resources/Graphics/hud_bar_left.png" );
	Image *BorderMiddle = Image::Get( "Resources/Graphics/hud_bar_middle.png" );
	Image *BorderRight= Image::Get( "Resources/Graphics/hud_bar_right.png" );

	if(pos==UPPER_RIGHT||pos==LOWER_RIGHT){
		x = Video::GetWidth() - BorderLeft->GetWidth() - width - BorderRight->GetWidth();
	}

	// Draw the Border
	BorderLeft->Draw(x,y);
	x += BorderLeft->GetWidth();
	BorderMiddle->DrawTiled(x,y,width, BorderMiddle->GetHeight());
	BorderRight->Draw(x+width,y);

	BitType->SetColor(1.f,1.f,1.f,1.f);

	// Draw the Title
	int wTitle = BitType->RenderTight( x, y+BorderMiddle->GetHalfHeight(), title,Font::LEFT,Font::MIDDLE );
	widthRemaining -= wTitle;
	x += wTitle + 5;

	// Draw Name
	if( !name.empty() ) {
		int wName = BitType->RenderTight( x, y+BorderMiddle->GetHalfHeight(), GetName() ,Font::LEFT,Font::MIDDLE );
		widthRemaining -= wName;
		x += wName;
	}

	// Draw the Bar
	if ( (int)(ratio*widthRemaining) > 0 ) {
		Image *BarLeft = Image::Get( "Resources/Graphics/hud_hullstr_leftbar.png" );
		Image *BarMiddle = Image::Get( "Resources/Graphics/hud_hullstr_bar.png" );
		Image *BarRight = Image::Get( "Resources/Graphics/hud_hullstr_rightbar.png" );

		int bar_y = y + BorderLeft->GetHalfHeight() - BarLeft->GetHalfHeight();
		BarLeft->Draw( x, bar_y );
		x += BarLeft->GetWidth();
		int bar_w = widthRemaining - BarLeft->GetWidth() - BarRight->GetWidth();
		BarMiddle->DrawTiled( x, bar_y,static_cast<int>(bar_w*ratio), BarMiddle->GetHeight() );
		BarRight->Draw( x + static_cast<int>(bar_w*ratio), bar_y );
	}
}
开发者ID:akollias,项目名称:Epiar,代码行数:50,代码来源:hud.cpp

示例2: Draw

/**\brief Draws the StatusBar
 * \param x x-coordinate
 * \param y y-coordinate
 *
 * \bug This can segfault with an empty title.
 */
void StatusBar::Draw(int x, int y) {
	int widthRemaining = this->width;

	Image *BackgroundLeft = Image::Get( "data/skin/hud_bar_left.png" );
	Image *BackgroundMiddle = Image::Get( "data/skin/hud_bar_middle.png" );
	Image *BackgroundRight= Image::Get( "data/skin/hud_bar_right.png" );

	if(pos == UPPER_RIGHT || pos == LOWER_RIGHT) {
		x = Video::GetWidth() - BackgroundLeft->GetWidth() - width - BackgroundRight->GetWidth();
	}

	// Draw the Border
	BackgroundLeft->Draw(x,y);
	x += BackgroundLeft->GetWidth();
	BackgroundMiddle->DrawTiled(x, y, width, BackgroundMiddle->GetHeight());
	BackgroundRight->Draw(x + width, y);


	// Draw the Title
	int wTitle = font->RenderTight( x, y + BackgroundMiddle->GetHalfHeight(), title, Font::LEFT, Font::MIDDLE );
	widthRemaining -= wTitle;
	x += wTitle + 5;

	// Draw Name
	int wName = font->RenderTight( x, y + BackgroundMiddle->GetHalfHeight(), name, Font::LEFT, Font::MIDDLE );
	widthRemaining -= wName;
	x += wName;

	// Draw the Bar
	if ( (int)(ratio*widthRemaining) > 0 ) {
		Image *BarLeft = Image::Get( "data/skin/hud_hullstr_leftbar.png" );
		Image *BarMiddle = Image::Get( "data/skin/hud_hullstr_bar.png" );
		Image *BarRight = Image::Get( "data/skin/hud_hullstr_rightbar.png" );

		int bar_y = y + BackgroundLeft->GetHalfHeight() - BarLeft->GetHalfHeight();
		BarLeft->Draw( x, bar_y );
		x += BarLeft->GetWidth();
		int bar_w = widthRemaining - BarLeft->GetWidth() - BarRight->GetWidth();
		BarMiddle->DrawTiled( x, bar_y,static_cast<int>(bar_w*ratio), BarMiddle->GetHeight() );
		BarRight->Draw( x + static_cast<int>(bar_w*ratio), bar_y );
	}
}
开发者ID:cthielen,项目名称:epiar,代码行数:48,代码来源:hud.cpp


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