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


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

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


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

示例1: 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

示例2: rng

void G2DTestSystemDriver::DrawLinePerf ()
{
  SetFont (fontItalic);
  WriteCentered (0,-16*4, white, -1, "LINE SLOPE AND PERFORMANCE TEST");

  int w2 = myG2D->GetWidth () / 2;
  int colors [4] = { red, green, blue, yellow };
  int a;
  for (a = 0; a < 360; a += 5)
  {
    float angle = (a * TWO_PI) / 360.0;
    float x = w2 + 80 * cos (angle);
    float y = 100 + 80 * sin (angle);
    myG2D->DrawLine (w2, 100, x, y, colors [a & 3]);
  }

  // Compute the size for the random lines box
  int sx = 0;
  int sw = myG2D->GetWidth ();
  int sy = myG2D->GetHeight () / 2;
  int sh = sy;
  myG2D->DrawBox (sx, sy + 16, sw, sh - 16, dsteel);

  SetFont (fontLarge);
  WriteCentered (0,-16*2, gray,  -1, "Above this text you should see a uniformly hashed circle,");
  WriteCentered (0,-16*1, gray,  -1, "while below you should see some random lines, and the");
  WriteCentered (0, 16*0, gray,  -1, "measured line drawing performance in pixels per second.");

  // Test line drawing performance for 1/4 seconds
  sx += 20; sw -= 40;
  sy += 30; sh -= 40;
  csRandomGen rng (csGetTicks ());
  csTicks start_time = csGetTicks (), delta_time;
  float pix_count = 0;
  do
  {
    for (a = 0; a < 5000; a++)
    {
      float x1 = sx + rng.Get () * sw;
      float y1 = sy + rng.Get () * sh;
      float x2 = sx + rng.Get () * sw;
      float y2 = sy + rng.Get () * sh;
      myG2D->DrawLine (x1, y1, x2, y2, colors [rng.Get (4)]);
      x2 = csQint (x2 - x1); y2 = csQint (y2 - y1);
      pix_count += csQsqrt (x2 * x2 + y2 * y2);
    }
    myG2D->PerformExtension ("flush");
    delta_time = csGetTicks () - start_time;
  } while (delta_time < 500);
  pix_count = pix_count * (1000.0 / delta_time);
  WriteCentered (0, 16*1, green, black, " Performance: %20.1f pixels/second ", pix_count);
}
开发者ID:crystalspace,项目名称:CS,代码行数:52,代码来源:g2dtest.cpp

示例3: switch

void G2DTestSystemDriver::WriteCentered (int mode, int dy, int fg, int bg,
  const char *format, ...)
{
  if (!font) return;

  csString text;
  va_list arg;

  va_start (arg, format);
  text.FormatV (format, arg);
  va_end (arg);

  int fw, fh;
  font->GetDimensions (text, fw, fh);

  int x = (myG2D->GetWidth () - fw) / 2;
  int y = 0;

  switch (mode)
  {
    case 0: // centered by Y
      y = dy + myG2D->GetHeight () / 2;
      break;
    case 1: // from top
      y = dy;
      break;
    case 2: // from bottom
      y = dy + (myG2D->GetHeight () - 1 - fh);
      break;
  }

  myG2D->Write (font, x, y + fh - font->GetDescent(), fg, bg, text, 
    CS_WRITE_BASELINE);
}
开发者ID:crystalspace,项目名称:CS,代码行数:34,代码来源:g2dtest.cpp

示例4: DrawWindowResizeScreen

void G2DTestSystemDriver::ResizeContext ()
{
  if (!myG2D->BeginDraw ())
    return;

  myG2D->Clear (black);
  DrawWindowResizeScreen ();

  csString text;
  text.Format ("Canvas [%d x %d]", myG2D->GetWidth (), myG2D->GetHeight ());
  SetFont (fontLarge);
  int fw, fh;
  font->GetDimensions (text, fw, fh);
  int x = myG2D->GetWidth () - fw;
  myG2D->Write (font, x, 0, red, -1, text);

  myG2D->FinishDraw ();
  myG2D->Print (0);
}
开发者ID:crystalspace,项目名称:CS,代码行数:19,代码来源:g2dtest.cpp

示例5: 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

示例6: LayerSampler

 LayerSampler (int basemap_w, int basemap_h, MaterialLayer* layer)
  : textureScale (layer->texture_scale)
 {
   float layer_needed_x = float (basemap_w) / textureScale.x;
   float layer_needed_y = float (basemap_h) / textureScale.y;
   iImage* layerImage = layer->GetImage();
   int mip_x = csFindNearestPowerOf2 (
     int (ceil (layerImage->GetWidth() / layer_needed_x)));
   int mip_y = csFindNearestPowerOf2 (
     int (ceil (layerImage->GetHeight() / layer_needed_y)));
   int mip = csMax (
     csClamp (csLog2 (mip_x), csLog2 (layerImage->GetWidth()), 0),
     csClamp (csLog2 (mip_y), csLog2 (layerImage->GetHeight()), 0));
   img = GetImageMip (layerImage, mip);
   img_w = img->GetWidth();
   img_h = img->GetHeight();
 }
开发者ID:garinh,项目名称:cs,代码行数:17,代码来源:basemapgen.cpp


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