本文整理汇总了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 );
}
}
示例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 );
}
}