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


C++ csRef::DrawBox方法代码示例

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


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

示例1: rng

void G2DTestSystemDriver::BoxClipTest()
{
  int w = myG2D->GetWidth ();
  int h = myG2D->GetHeight ();
  int sx = w/4, sy = h / 2 + 60, sw = w/2, sh = h / 4 - 60;
  myG2D->SetClipRect(0,0,w,h);
  myG2D->DrawBox(0,0,w,h, dsteel);
  
  SetFont (fontItalic);
  WriteCentered (0,-16*4, white, -1, "BOX CLIP TEST");

  SetFont (fontLarge);
  WriteCentered (0,-16*3,  black, dsteel, "This will test if box clipping is being done properly");
  WriteCentered (0,-16*2,  black, dsteel, "You should see a thin green rectangle below");

  WriteCentered (0,16*0,   black, dsteel, "Again all the black should be contained inside the green");
  WriteCentered (0,16*1,   black, dsteel, "rectangle. The red rectangle should not be visible.");
  

  SetFont (fontCourier);

  DrawClipRect(sx, sy, sw, sh);

  myG2D->SetClipRect(sx + 1, sy + 1, sx + sw, sy + sh);
  

  // Test random box drawing
  csRandomGen rng (csGetTicks ());
  csTicks start_time = csGetTicks (), delta_time;


  // widen the range where we try to draw
  sx -= 10;
  sy -= 10;
  sw += 20;
  sh += 20;

  do
  {
	int i;
    for (i = 0; i < 1000; i++)
    {
      int x = int(sx + rng.Get () * sw);
      int y = int(sy + rng.Get () * sh);
      int width = int(rng.Get () * sw);
      int height = int(rng.Get () * sh);
      myG2D->DrawBox(x,y,width,height,black);
    }
    delta_time = csGetTicks () - start_time;
  } while (delta_time < 100);

}
开发者ID:crystalspace,项目名称:CS,代码行数:52,代码来源:g2dtest.cpp

示例2: SetFont

void G2DTestSystemDriver::DrawAlphaTestScreen ()
{
  int w = myG2D->GetWidth ();
  int h = myG2D->GetHeight ();
  myG2D->SetClipRect(0,0,w,h);
  myG2D->DrawBox(0,0,w,h, dsteel);

  SetFont (fontItalic);
  WriteCentered (1, 1, white, -1, "ALPHA COLOR TEST");

  SetFont (fontLarge);
  WriteCentered (1, 16*2, black, -1, "If your current canvas is in 32-bit mode, you should");
  WriteCentered (1, 16*3, black, -1, "see various text and geometry at various transparencies.");

  myG2D->DrawBox (190, 80, 50, 100, black);
  myG2D->DrawBox (20, 100, 150, 75, myG2D->FindRGB (205, 0, 125, 200));
  myG2D->DrawBox (120, 100, 100, 50, myG2D->FindRGB (120, 50, 50, 100));
  myG2D->DrawLine (30, 110, 120, 60, myG2D->FindRGB (255, 128, 128, 128));
  myG2D->DrawLine (120, 60, 70, 120, myG2D->FindRGB (128, 255, 128, 128));
  myG2D->DrawLine (70, 120, 30, 110, myG2D->FindRGB (128, 128, 255, 128));

  if (alphaBlitImage.IsValid ())
  {
    myG2D->Blit (20, 160, alphaBlitImage->GetWidth (), alphaBlitImage->GetHeight (), 
      (unsigned char*)alphaBlitImage->GetImageData ());
  }

  myG2D->Write (font, 50, 140, myG2D->FindRGB (255, 255, 255, 100), -1,
    L"Here is some partially transparent text");
  myG2D->Write (font, 50, 150, myG2D->FindRGB (0, 0, 255, 150), -1,
    L"overlaying partially transparent boxes.");

  csString str;
  int i;
  int y = 140;
  int tw, th;
  font->GetMaxSize (tw, th);
  for (i = 0; i < 6; i++)
  {
    const uint8 alpha = (i * 51);
    str.Format ("FG has alpha %" PRIu8 , alpha);
    myG2D->Write (font, 320, y, MakeColor (255, 255, 255, alpha), 
      black, str);
    y += th;
    str.Format ("BG has alpha %" PRIu8, alpha);
    myG2D->Write (font, 320, y, white, MakeColor (0, 0, 0, alpha), 
      str);
    y += th;
  }
}
开发者ID:crystalspace,项目名称:CS,代码行数:50,代码来源:g2dtest.cpp

示例3: DrawWindowScreen

void G2DTestSystemDriver::DrawWindowResizeScreen ()
{
  DrawWindowScreen ();

  myG2D->AllowResize (true);
  myG2D->DrawBox (0, myG2D->GetHeight () / 2 + 16, myG2D->GetWidth (), 16 * 4, blue);
  SetFont (fontLarge);

  WriteCentered (0, 16*1, white, -1, "Now resizing should be enabled. Try to resize the");
  WriteCentered (0, 16*2, white, -1, "window: you should be either unable to do it (if");
  WriteCentered (0, 16*3, white, -1, "canvas driver does not support resize) or see");
  WriteCentered (0, 16*4, white, -1, "the current window size in top-right corner.");

  SetFont (fontCourier);
  WriteCentered (2, 0, green, -1, "press any key to continue");
}
开发者ID:crystalspace,项目名称:CS,代码行数:16,代码来源:g2dtest.cpp


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