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


C++ Surface::Draw方法代码示例

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


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

示例1: testFunction

void Test_Surface::testFunction(Surface &f) {
  qsrand(1);
  ParameterMap parameters = f.getParameters();
//  cerr << f.getFunctionName().toStdString() << " parameters ("<< parameters.size() << "): " << parameters.toString() << endl;
  f(0.,0.);
  VecMath::Rotation<4> r(random_number<double>(), random_number<double>(), random_number<double>(), random_number<double>(), random_number<double>(), random_number<double>());
  VecMath::Vector<4> t(random_number<double>(), random_number<double>(), random_number<double>(), random_number<double>());
  f.Transform(r, t);
  f.Project(2., 4., false);
  f.Draw(view_);
  f.ReInit(1., 1., 1., -2., 2., 0.2, -2., 2., 0.2);
}
开发者ID:lene,项目名称:HyperspaceExplorer,代码行数:12,代码来源:Test_Surface.cpp

示例2: DrawBackground

void Map::DrawBackground(Window screen, Graphics* assets){
	Point2D dim = GetMapDimension();
	Surface* surface =& (assets->forest[0]);
	Surface* parallax = & (assets->forestParallax);
	int forestStart = (int)dim.Y;//The bottom of the map

	int Xstart = 0;
	int Xcount = 0;
	int parallaxStartX =0;
	//(Bottom of map - (the current camera position + the height of the screen)) divided by the height of the background surface -1
	//== (bottom of map - the bottom of the screen)/height of background -1
	//==how many backgrounds are already beneath this position?
	int Ycount = (int)((forestStart - (_mapPosition.Y+screen.GetHeight())) / surface->GetHeight()) - 1;
	//the starting point for the background to draw
	int Ystart = (int)dim.Y - surface->GetHeight()*Ycount;
	while(Ystart>_mapPosition.Y){
		//The vertical height determines the kind of background
		surface->SetTransparency(255);
		if(Ycount == 0)
		{surface = &(assets->forest[0]); parallax=&(assets->forestParallax);}
		else if(Ycount == 1)
		{surface =&( assets->air[0]);parallax=0;}
		else if(Ycount == 2)
		{surface = &(assets->space1);parallax=0;}
		else if(Ycount < 0)
		{surface->SetTransparency(0);parallax=0;}
		else {surface = &(assets->space2);parallax=0;}
		//This one is handled, go the next one
		Ystart -= surface->GetHeight();
		//The starting position of the next background to render
		Xstart = (int)(_mapPosition.X - ((Uint32)_mapPosition.X % (Uint32)surface->GetWidth()));
		//How many backgrounds are already left of this?
		Xcount = (int)(_mapPosition.X/surface->GetWidth());
		if (parallax!=0 && parallax->IsInit())
		{
			int parallaxStartX=(int)(_mapPosition.X/2 - ((Uint32)(_mapPosition.X/2) % (Uint32)parallax->GetWidth()));
			while(parallaxStartX < _mapPosition.X + screen.GetWidth()){		
				parallax->Draw(screen,(Uint32)(parallaxStartX-_mapPosition.X/2), (Uint32)(Ystart-_mapPosition.Y)+400);
				parallax->Draw(screen,(Uint32)(parallaxStartX-_mapPosition.X/2), (Uint32)(Ystart-_mapPosition.Y)+400);
				parallaxStartX += parallax->GetWidth();
			}
		}
		while(Xstart < _mapPosition.X + screen.GetWidth()){
			//Handle the current image for the looping backgrounds
			if(Ycount == 1){
				if(Xcount>2)Xcount = Xcount%3;
				surface = &(assets->air[Xcount]);
				Xcount++;
			}
			else if(Ycount == 0){
				if(Xcount>3) Xcount = Xcount%4;
				surface = &(assets->forest[Xcount]);
				Xcount++;
			}
			surface->Draw(screen, (Uint32)(Xstart-_mapPosition.X), (Uint32)(Ystart-_mapPosition.Y));	
			Xstart += surface->GetWidth();
		}
		Ycount++;
	}
			
}
开发者ID:ZealousV,项目名称:ART,代码行数:61,代码来源:Map.cpp

示例3: BuildFrame

/** @brief Open the frame file and construct the image of the frame
  */
bool WindowBox::BuildFrame()
{
  // only bother if we have a frame template
  if (!FrameVisible) {
    return false;
  }
  FrameSurface.Init(Size.W, Size.H);

  Surface spritePage;
  if (!spritePage.LoadImage(FRAMES_DIR + SLASH + FrameName + ".png")) {
    LOG(FrameName + " - frame image missing");
    FrameVisible = false;
    return false;
  } else if (spritePage.W != GRID * 4) {
    const real scale = (real)GRID * (real)4 / (real)spritePage.W;
    spritePage.Zoom(scale, scale);
    LOG("frame image size incorrect, scaling to fit");
  }

  // sprite image layout
  // 00C 01M 02E 03C   corner middle edge corner
  // 04M 05M 06I 07M   middle middle icon middle
  // 08E 09D 10U 11E   edge    down   up   edge
  // 12C 13M 14E 15C   corner middle edge corner

  Rect src(GRID, GRID);
  Rect dst(GRID, GRID);

  // create the base frame
  for (szt i = 0, colS = Size.W / GRID; i < colS; ++i) {
    for (szt j = 0, rowS = Size.H / GRID; j < rowS; ++j) {
      szt index;
      if (j == 0) {
        if (i == 0) {
          index = 0;
        } else if (i == colS / 2 && colS > 8) {
          index = 1;
        } else if (i < colS - 1) {
          index = 2;
        } else {
          index = 3;
        }
      } else if (j < rowS - 1) {
        if (i == 0) {
          if (j == rowS / 2 && rowS > 8) {
            index = 4;
          } else {
            index = 8;
          }
        } else if (i < colS - 1) {
          index = 5;
        } else {
          if (j == rowS / 2 && rowS > 8) {
            index = 7;
          } else {
            index = 11;
          }
        }
      } else {
        if (i == 0) {
          index = 12;
        } else if (i == colS / 2 && colS > 8) {
          index = 13;
        } else if (i < colS - 1) {
          index = 14;
        } else {
          index = 15;
        }
      }
      src.X = GRID * (index % 4);
      src.Y = GRID * (index / 4);
      dst.X = GRID * i;
      dst.Y = GRID * j;
      spritePage.SetClip(src);
      spritePage.Draw(FrameSurface, dst);
    }
  }

  // create icons
  FrameUp.Init(GRID, GRID);
  FrameIcon.Init(GRID, GRID);
  FrameDown.Init(GRID, GRID);
  src.X = GRID * 2;
  src.Y = GRID * 2;
  spritePage.SetClip(src);
  spritePage.Draw(FrameUp);
  src.X = GRID * 2;
  src.Y = GRID * 1;
  spritePage.SetClip(src);
  spritePage.Draw(FrameIcon);
  src.X = GRID * 1;
  src.Y = GRID * 2;
  spritePage.SetClip(src);
  spritePage.Draw(FrameDown);

  // set up icon locations
  UpDst.W = UpDst.H = GRID;
  UpDst.X = Size.X + Size.W - 2 * GRID;
//.........这里部分代码省略.........
开发者ID:paul-szczepanek,项目名称:lethe,代码行数:101,代码来源:windowbox.cpp


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