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


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

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


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

示例1: rng

void G2DTestSystemDriver::PixelClipTest ()
{
  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*-12, white, -1, "PIXEL CLIP TEST");

  SetFont (fontLarge);
  WriteCentered (0,16*-10,  black, dsteel, "This will test if pixel clipping is being done properly");
  
  WriteCentered (0,16*-8,   black, dsteel, "For each of the following clip tests we will be drawing");
  WriteCentered (0,16*-7,   black, dsteel, "a 1 pixel wide green rectangle with a 1 pixel wide red rectangle");
  WriteCentered (0,16*-6,   black, dsteel, "inside of it.");

  WriteCentered (0,16*-4,   black, dsteel, "The clipping rectangle has been set so the red rectangle is");
  WriteCentered (0,16*-3,   black, dsteel, "inside the clipping region. If any of the lines of the red rectangle");
  WriteCentered (0,16*-2,   black, dsteel, "are solid (not drawn over) then the clipping region is cutting off too much");
  
  WriteCentered (0,16*0,   black, dsteel, "The green rectangle is outside the clipping region. If any of the lines");
  WriteCentered (0,16*1,   black, dsteel, "of the green rectangle are being drawn over then the clipping region is");
  WriteCentered (0,16*2,   black, dsteel, "not clipping enough.");
  

  SetFont (fontCourier);

  DrawClipRect(sx, sy, sw, sh);

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

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


  // widen the range where we try to draw pixels
  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);
      myG2D->DrawPixel(x,y,black);
    }
    delta_time = csGetTicks () - start_time;
  } while (delta_time < 100);
}
开发者ID:crystalspace,项目名称:CS,代码行数:59,代码来源:g2dtest.cpp

示例2: SetFont

void G2DTestSystemDriver::BlitTest ()
{
  int w = myG2D->GetWidth ();
  int h = myG2D->GetHeight ();
  myG2D->SetClipRect(0,0,w,h);
  myG2D->DrawBox(0,0,w,h, dsteel);
  
  SetFont (fontItalic);
  WriteCentered (0,-16*8, white, -1, "BLIT() TEST");

  SetFont (fontLarge);
  WriteCentered (0,-16*7, black, dsteel, "This will test whether iGraphics2D->Blit() works correctly");
  WriteCentered (0,-16*6, black, dsteel, "on this canvas.");

  WriteCentered (0,-16*4, black, dsteel, "You should see an image of an arrow and the word %s.",
		 CS::Quote::Double ("up"));
  WriteCentered (0,-16*3, black, dsteel, "It is surrounded by a green rectangle, and the image");
  WriteCentered (0,-16*2, black, dsteel, "itself has a black border. No red should be visible");
  WriteCentered (0,-16*1, black, dsteel, "and the border has to be complete, too.");

  if (blitTestImage.IsValid ())
  {
    const int imW = blitTestImage->GetWidth ();
    const int imH = blitTestImage->GetHeight ();
    const int bx = (w - imW) / 2;
    const int by = h / 2;
    DrawClipRect (bx, by, imW + 1, imH + 1);
    myG2D->Blit (bx + 1, by + 1, imW, imH, 
      (unsigned char*)blitTestImage->GetImageData ());
  }
}
开发者ID:crystalspace,项目名称:CS,代码行数:31,代码来源:g2dtest.cpp

示例3: switch


//.........这里部分代码省略.........
          EnterState (stTestLineDraw);
          EnterState (stWaitKey);
          break;
        case stTestLineDraw:
          DrawLineTest ();
          EnterState (stTestLinePerf);
          EnterState (stWaitKey);
          break;
        case stTestLinePerf:
          DrawLinePerf ();
          if (lastkey2)
            EnterState (stTestTextDraw);
          else
            EnterState (stTestLinePerf);
          break;
        case stTestTextDraw:
          DrawTextTest ();
          if (lastkey3)
            EnterState (stTestTextDraw2);
          else
            EnterState (stTestTextDraw);
          break;
        case stTestTextDraw2:
          DrawTextTest2 ();
          if (lastkey4)
            EnterState (stPixelClipTest);
          else
            EnterState (stTestTextDraw2);
          break;
        case stPixelClipTest:
          PixelClipTest ();
          if (lastkey5)
          {
            myG2D->SetClipRect(0,0,myG2D->GetWidth(), myG2D->GetHeight());
            EnterState (stLineClipTest);
          }
          else
            EnterState (stPixelClipTest);
          break;
        case stLineClipTest:
          LineClipTest ();
          if (lastkey6)
          {
            myG2D->SetClipRect(0,0,myG2D->GetWidth(), myG2D->GetHeight());
            EnterState (stBoxClipTest);
          }
          else
            EnterState (stLineClipTest);
          break;
        case stBoxClipTest:
          BoxClipTest ();
          if (lastkey7)
          {
            myG2D->SetClipRect(0,0,myG2D->GetWidth(), myG2D->GetHeight());
	    EnterState (stFontClipTest);
          }
          else
            EnterState (stBoxClipTest);
          break;
        case stFontClipTest:
          FontClipTest ();
          if (lastkey8)
	    EnterState (stBlitTest);
          else
            EnterState (stFontClipTest);
          break;
开发者ID:crystalspace,项目名称:CS,代码行数:67,代码来源:g2dtest.cpp


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