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


C++ Graphics::DrawRect方法代码示例

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


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

示例1: Paint

///////////////////////////////////////////////////////////////////////////////
// Paint: Draw the credits.
///////////////////////////////////////////////////////////////////////////////
void ScrollingTextComponent::Paint(Graphics &g)
{
	Component::Paint(g);

	// Draw the background.
	g.SetFont(GetDefaultFont());
	g.SetColor(0xFFFFFF);
	g.FillRect(2,2,Width()-4,Height()-4);

	// Draw the frame.
	g.ApplyColorSchemeColor(StandardColor_3DHilight);
	g.DrawRect(0,0,Width(),Height());
	g.DrawRect(1,1,Width()-1,Height()-1);
	g.ApplyColorSchemeColor(StandardColor_3DShadow);
	g.DrawRect(0, 0,Width()-1,Height()-1);

	// Draw the text.
	int nTop = mScrollTop;
	CreditsList::iterator Itr = mLines.begin();

	while (Itr != mLines.end())
	{
		CreditLineInfo& LineInfo = *Itr;
		int nStrHt = g.GetFont()->GetHeight();

		if (nTop < Height() / 3)
			g.SetColor(DimColor(LineInfo.GetColor(), nTop * 100 / (Height() / 3)));
		else if (Height() - nTop <= nStrHt)
			g.SetColor(0xFFFFFF);
		else if (nTop > (Height() * 2 / 3) - nStrHt)
			g.SetColor(DimColor(LineInfo.GetColor(), ((Height() - (nTop + nStrHt)) * 100 / (Height() / 3))));
		else
			g.SetColor(LineInfo.GetColor());

		if (g.GetColor() != 0xFFFFFF && nTop > 2 && nTop < Height() - nStrHt - 2)
		{
			int nStrWd = g.GetFont()->GetStringWidth(LineInfo.GetLine());
			g.DrawString(LineInfo.GetLine(), (Width() - nStrWd) / 2, nTop);
		}
		nTop += nStrHt;
		++Itr;
	}
	mTotalTextHeight = nTop - mScrollTop;
}
开发者ID:SOLARIC,项目名称:world-opponent-network,代码行数:47,代码来源:CreditsDialog.cpp

示例2: render

void cGameStateChart::render(Graphics &con){
 
  //Clear buffer and draw graphics
  con.ClearBuffer(0, 0, 0, 0);
  con.BeginDrawing();
  GRAPHIC_IMAGE gi;

  CGameData *pData = CGameData::Instance();

  //draw chart stuff
  gi = g_Sprite.GetSpriteData(48);//white square for chart background
  gi.scale = 5.05;
  con.RenderGraphicModulate(262 + pData->m_shockX, 134 + pData->m_shockX, gi, m_red, m_green, m_blue);

  //chart highlights and reference lines
  con.DrawRect(262, 134, 762, 634,255, 0, 0);
  con.DrawLine(512, 134, 512, 634, 0, 0, 120);
  con.DrawLine(262, 384, 762, 384, 0, 0, 120);
  
  //draw user interface on right side of chart
  con.DrawLine(780, 134, 800, 134, 0, 255, 0);//horizontal tick marks
  con.DrawLine(780, 249, 800, 249, 0, 255, 0);
  con.DrawLine(780, 269, 800, 269, 0, 255, 0);
  con.DrawLine(780, 384, 800, 384, 0, 255, 0);
  con.DrawLine(790, 134, 790, 249, 0, 255, 0);//vertical lines
  con.DrawLine(790, 269, 790, 384, 0, 255, 0);

  //draw range
  con.Draw2DTextValue("SCALE", (float)m_chartScale[m_chartScaleIndex], F_V20, 780, 249, 0, 255, 0);

  //zoom in and zoom out
  if(g_Global.g_mouse.x > 806 && g_Global.g_mouse.x < 1006 
    && ::GetActiveWindow() == g_hWnd){
    if(g_Global.g_mouse.y > 134 && g_Global.g_mouse.y < 249 && m_chartScaleIndex < 4){//zoom in
      gi = g_Sprite.GetSpriteData(30);
      con.RenderGraphicModulate(811,139,gi,m_red, m_green, m_blue);
    }
    else if(g_Global.g_mouse.y > 269 && g_Global.g_mouse.y < 384 && m_chartScaleIndex > 0){//zoom out
      gi = g_Sprite.GetSpriteData(29);
      con.RenderGraphicModulate(811,274,gi,m_red, m_green, m_blue);
    }
  }

  //display ship and sub data
//  CGameData *pData = CGameData::Instance();
  float posX = 0, posY = 0;
  float range = (float)m_chartScale[m_chartScaleIndex];

  //ships
  for(int i = 0; i < pData->m_targets.size(); ++i){
    posX = (pData->m_targets[i].m_posX - pData->m_Player.m_posX) * 250/range;
    posY = (pData->m_targets[i].m_posY - pData->m_Player.m_posY) * 250/range;

    if(pData->m_targets[i].m_bAlive == true &&  posX >= -250 && posX <= 250 && posY >= -250 && posY <= 250)//{
      con.DrawCircle(512 + posX,384 - posY, 255,0,0,(pData->m_targets[i].m_length/500) * (20000/(range * 2) ));
  }

  //torpedo
  for(int i = 0; i < pData->m_torpedos.size(); ++i){
    posX = (pData->m_torpedos[i].GetPositionX()- pData->m_Player.m_posX) * 250/range;
    posY = (pData->m_torpedos[i].GetPositionY() - pData->m_Player.m_posY) * 250/range;

    if(pData->m_torpedos[i].IsRunning() == true &&  posX >= -250 && posX <= 250 && posY >= -250 && posY <= 250)//{
      con.DrawCircle(512 + posX,384 - posY, 0, 0, 0,2 * (20000/(range * 8)));
  }

  //draw scope bearing line to indicate which target is being viewed
  float s = 0, t = 0;
  s = 512 + 250 * cos(pData->ConvertDegreesToRadians( pData->m_Player.m_heading + pData->m_scopeRotateAngle/5.689));
  t = 384 - 250 * sin(pData->ConvertDegreesToRadians( pData->m_Player.m_heading + pData->m_scopeRotateAngle/ 5.689));
  con.DrawLine(512,384,s,t, 0, 255,0);

  //draw sub in center of chart
  gi = g_Sprite.GetSpriteData(57);
  gi.rotationAngle =  pData->m_Player.m_heading * 3.141592654/180;
  gi.scale = 1;// (1000/range);
  con.RenderGraphicModulate(512 - (gi.width/2)* gi.scale, 384 - (gi.height/2) * gi.scale, gi, m_red, m_green, m_blue);

  //display short cuts
  gi = g_Sprite.GetSpriteData(36);//sonar
  con.RenderGraphicModulate(10,10,gi,m_red, m_green, m_blue);
  gi = g_Sprite.GetSpriteData(37);//radar
  con.RenderGraphicModulate(120,10,gi,m_red, m_green, m_blue);
  gi = g_Sprite.GetSpriteData(38);//conn selected
  con.RenderGraphicModulate(230,10,gi,m_red, m_green, m_blue);
  gi = g_Sprite.GetSpriteData(39);//fire control
  con.RenderGraphicModulate(694,10,gi,m_red, m_green, m_blue);
  gi = g_Sprite.GetSpriteData(40);//damage control
  con.RenderGraphicModulate(804,10,gi,m_red, m_green, m_blue);
  gi = g_Sprite.GetSpriteData(47);//chart
  con.RenderGraphicModulate(914,10,gi,m_red, m_green, m_blue);

  //draw tool tips for short cuts
  if(g_Global.g_mouse.y > 10 && g_Global.g_mouse.y < 130){
    //if(g_Global.g_mouse.x > 10 & g_Global.g_mouse.x < 104)
    //  con.Draw2DText("Sonar", F_V20, 20, 10, 0,255,255);
    //else if(g_Global.g_mouse.x > 120 & g_Global.g_mouse.x < 207)
    //  con.Draw2DText("Radar", F_V20, 130, 10, 0,255,255);
    if(g_Global.g_mouse.x > 230 & g_Global.g_mouse.x < 310)
      con.Draw2DText("Conn", F_V20, 240, 10, 0,255,255);
//.........这里部分代码省略.........
开发者ID:ChuckBolin,项目名称:Sinking,代码行数:101,代码来源:cGameStateChart.cpp

示例3: OnDraw

//[-------------------------------------------------------]
//[ Public virtual PLGui::Widget functions                ]
//[-------------------------------------------------------]
void FocusWidget::OnDraw(Graphics &cGraphics)
{
	cGraphics.DrawRect(Color4::Black, Vector2i::Zero, GetSize() - Vector2i(1, 1), 0, 0, 1);
}
开发者ID:ByeDream,项目名称:pixellight,代码行数:7,代码来源:FocusWidget.cpp


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