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


C++ drawGrid函数代码示例

本文整理汇总了C++中drawGrid函数的典型用法代码示例。如果您正苦于以下问题:C++ drawGrid函数的具体用法?C++ drawGrid怎么用?C++ drawGrid使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: boundingRect

void GfxBlockItem::paint(QPainter *p,
			 const QStyleOptionGraphicsItem *,
			 QWidget *) {
  // paint background grid; items draw themselves  
  QRectF bb = boundingRect();
  QColor c(style().color("canvas-grid-color"));
  c.setAlphaF(style().real("canvas-grid-alpha"));
  p->setPen(QPen(c,
		 style().real("canvas-grid-line-width"),
		 Qt::SolidLine,
		 Qt::FlatCap));
  double dx = style().real("canvas-grid-spacing");
  drawGrid(p, bb, dx);

  c = style().color("canvas-grid-major-color");
  c.setAlphaF(style().real("canvas-grid-major-alpha"));

  p->setPen(QPen(c,
		 style().real("canvas-grid-major-line-width"),
		 Qt::SolidLine,
		 Qt::FlatCap));
  dx *= style().integer("canvas-grid-major-interval");
  if (dx)
    drawGrid(p, bb, dx);
}
开发者ID:wagenadl,项目名称:eln,代码行数:25,代码来源:GfxBlockItem.cpp

示例2: main

int main(int argc, char const *argv[])
{
	int coordinates1[MAXCOORDINATES];
	int coordinates2[MAXCOORDINATES];

	
	if (argc < 2)
	{
		printf("Wrong number of files\n");	
		return 0;
	}

	do{
		getLifeFile(argv[1], coordinates1);
		getLifeFile(argv[2], coordinates2);
		randomiseCoordinates(coordinates1);
		randomiseCoordinates(coordinates2);
		wrapAdjustmentCoordinates(coordinates1);
		wrapAdjustmentCoordinates(coordinates2);
	} while(checkCoordsOverlap(coordinates1, coordinates2));
	
	drawGrid(coordinates1, coordinates2);
	evolveGame(coordinates1, coordinates2);
	drawGrid(coordinates1, coordinates2);

	printf("1: %d\n\n", count(coordinates1));
	printf("2: %d\n\n", count(coordinates2));


	return 0;
}
开发者ID:haroonhassan,项目名称:GOL,代码行数:31,代码来源:lw.c

示例3: move

void PHScrollerView::draw()
{    
    if (inertial && (inscroll.x || inscroll.y))
    {
        move(inscroll);
        PHLowPassFilter(inscroll.x, 0, 1/60.0f, 4.0f);
        PHLowPassFilter(inscroll.y, 0, 1/60.0f, 4.0f);
        if (fabs(inscroll.x)<0.001)
            inscroll.x=0;
        if (fabs(inscroll.y)<0.001)
            inscroll.y=0;
    }
    drawGrid(1.0,0.05,PHColor(0,1,0,0.6));
    drawGrid(0.5,0.025,PHColor(0,1,0,0.3));
    drawGrid(0.1,0.015,PHColor(0,1,0,0.2));
    
    if (content)
    {
        PHPoint p = content->position();
        GLfloat vertices[] = {
            p.x, p.y+0.15,
            p.x-0.15, p.y,
            p.x+0.15, p.y,
            p.x, p.y-0.15
        };
        
        gm->setGLStates(PHGLBlending | PHGLVertexArray);
        gm->setColor(PHColor(1,0,0,1));
        gm->vertexPointer(2, GL_FLOAT, 0, vertices);
        gm->applyShader(gm->solidColorShader());
        glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
    }
}
开发者ID:dapetcu21,项目名称:Porkholt,代码行数:33,代码来源:PHScrollerView.cpp

示例4: glViewport

void OpenGLTransformation::drawSub1()
{
  glViewport(0, 0, windowWidth / 2, windowHeight);
  glScissor(0, 0, windowWidth / 2, windowHeight);

  glClearColor(0.1f, 0.1f, 0.1f, 1);
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);

  MatStack.matrixMode(tgt::MatrixStack::PROJECTION);
  MatStack.pushMatrix();
  MatStack.loadMatrix(camera->getProjectionMatrix(glm::ivec2(windowWidth * 0.5f, windowHeight)));
  MatStack.matrixMode(tgt::MatrixStack::MODELVIEW);
  MatStack.pushMatrix();
  MatStack.loadMatrix(camera->getViewMatrix());

  // always draw the grid at the origin (before any modeling transform)
  drawGrid(10, 1);
  drawAxis(4);

  glm::mat4 cubeModel = glm::translate(glm::vec3(-0.5f));
  MatStack.pushMatrix();
  MatStack.loadMatrix(camera->getViewMatrix() * cubeModel);
  drawCube();
  MatStack.popMatrix();

  MatStack.matrixMode(tgt::MatrixStack::PROJECTION);
  MatStack.popMatrix();
  MatStack.matrixMode(tgt::MatrixStack::MODELVIEW);
  MatStack.popMatrix();
}
开发者ID:alvin-me,项目名称:MIVT,代码行数:30,代码来源:opengltransformation.cpp

示例5: glColor3f

void Snake::draw()
{
	node* ptr= tail;

	
	for(;ptr!=NULL; ptr=ptr->next)
	{
		glColor3f(0.0, 1.0, 0.0);
		drawGrid(ptr->xVal, ptr->yVal);
	}

	glColor3f(1.0, 0.0, 0.0);
	drawGrid(seed[0], seed[1]);

	if(counter==5)
	{
		glColor3f(0.0, 0.0, 1.0);
		drawGrid(special[0], special[1]);
		glColor3f(1.0, 1.0, 1.0);
		drawFourDigiNumber(countDown, edge+1, 20.0, 1.2);
	}

	glColor3f(1.0,1.0, 0.0);
	glBegin(GL_QUADS);
	   glVertex2f(edge-0.5, -0.5);
	   glVertex2f(edge, -0.5);
	   glVertex2f(edge, edge-0.5);
	   glVertex2f(edge-0.5, edge-0.5);
	glEnd();

	glColor3f(1.0, 1.0, 1.0);
	drawFourDigiNumber(score, edge+1.0, 40.0, 1.2);
}
开发者ID:crg91,项目名称:Snake,代码行数:33,代码来源:Snake.cpp

示例6: drawGameMatrix

/** Dessine la surface de jeu sur screen
 * screen : Surface où dessiner
 * sim : Surface à dessiner
 * grid : Dessine la grille si vrai
 **/
void drawGameMatrix(SDL_Surface *screen, Simulation *sim, int grid)
{
	int x = 0, y = 0, i, j;
	int xCoin = sim->dispX - 0.5*sim->largeurCase*sim->nbCasesX;
	int yCoin = sim->dispY - 0.5*sim->largeurCase*sim->nbCasesY;
	
	for(i = 0; i < sim->nbCasesX; i++)
	{
		for(j = 0; j < sim->nbCasesY; j++)
		{
			if(sim->buffers[sim->actualBuffer][i][j])
			{
				x = xCoin + i*sim->largeurCase;
				y = yCoin + j*sim->largeurCase;
				
				drawSquareAbsolute(screen, sim->largeurCase, x, y);
			}
		}
	}
	
	if(grid)
	{
		drawGrid(screen, sim->largeurCase, xCoin, yCoin, sim->nbCasesX, sim->nbCasesY);
		drawGrid(screen, sim->nbCasesX*sim->largeurCase/sqrt(sim->nbThread), xCoin, yCoin, sqrt(sim->nbThread), sqrt(sim->nbCasesY));
	}
}
开发者ID:WhiteMoll,项目名称:game_of_life,代码行数:31,代码来源:affichage_sdl.c

示例7: run

/**
 * run
 * Run is the main control body of the program. It first prints the header which
 * contains directions on how to use the program then enters the paused state
 * in which the user may edit the population using a cursor controlled by the 
 * arrow keys. If the user presses Enter, the simulation is started and will
 * continue until the user again presses Enter to pause or Esc to exit.
 **/
void run(int model[][ROWS]) {
    printHeader(); //prints directions
	drawBorder(GRIDCOLOR); //draws a border
	swapBuff();
    int i = COLUMNS/2; //initializes position of cursor to middle of screen
    int j = ROWS/2;
    raw_key = 0x1C; //sets raw_key = ENTER
    while (raw_key != 0x01) { //loops until user hits Esc
	if (raw_key==0x1C) { //checks for enter pressed
            raw_key=0;
	    waitVRetrace();
	    drawGrid(GRIDCOLOR); //draws grid on screen for edit mode
	    drawSquare(i,j,SELCOLOR); //draws cursor at position on screen
	    while (raw_key!=0x1C && raw_key!=0x01) { //loops until Esc or Enter
		waitVRetrace();
		if (raw_key==0x48) { //up arrow has been pressed
		    raw_key = 0;
		    updateSquare(model,i,j); //erases cursor
		    if (j>0) {j--;} //updates cursor position
		    drawSquare(i,j,SELCOLOR); //draws cursor at new position
		}
		if (raw_key==0x50) { //down arrow has been pressed
		    raw_key = 0;
		    updateSquare(model,i,j);
		    if (j<ROWS-1) {j++;}
		    drawSquare(i,j,SELCOLOR);
		}
		if (raw_key==0x4B) { //left arrow has been pressed
		    raw_key = 0;
		    updateSquare(model,i,j);
		    if (i>0) {i--;}
		    drawSquare(i,j,SELCOLOR);
		}
		if (raw_key==0x4D) { //right arrow has been pressed
		    raw_key = 0;
		    updateSquare(model,i,j);
		    if (i<COLUMNS-1) {i++;}
		    drawSquare(i,j,SELCOLOR);
		}
		if (raw_key==0x39) { //spacebar has been pressed
		    raw_key = 0;
		    //flips the life state of current square
		    if (model[i][j]==1) {model[i][j]=0;}
		    else {model[i][j]=1;}
		}
		swapBuff();
	    }
			//clears raw key if enter was pressed
            if (raw_key==0x1C) {raw_key=0;} 
	    updateSquare(model,i,j); //erases cursor
	    drawGrid(BGCOLOR); //erases grid for simulation mode
	    while(raw_key!=0x01 && raw_key!=0x1C) { //loops until Esc or Enter
		updateModel(model); //simulates game of life and redraws squares
		waitVRetrace();
		swapBuff();
	    }
	}
    }
}
开发者ID:ahelwer,项目名称:UofC,代码行数:67,代码来源:MAIN.C

示例8: String

int TetrisGrid::removeLines()
{
	int removed = 0;
	for(int i = 0; i < GRID_HEIGHT; i++)
	{
		bool removeThisRow = true;
		for(int j = 0; j < GRID_WIDTH; j++)
		{
			if(((*(grid[i]))[j]) == ' ')
			{
				removeThisRow = false;
				break;
			}
		}
		if(removeThisRow)
		{
			grid.remove(i);
			String* emptyLine = new String(T("          "));
			grid.insert(0, emptyLine);
			removed++;
			if(removed == 4)
			{
				break;
			}
		}
	}
	drawGrid();
	return removed;
}
开发者ID:sbimbra,项目名称:tetris,代码行数:29,代码来源:TetrisGrid.cpp

示例9: drawGrid

void BuzzWord::newGame()
{
	gameOver = false;
	delete grid;
	drawGrid();
	setCentralWidget(grid);
}
开发者ID:opieproject,项目名称:opie,代码行数:7,代码来源:buzzword.cpp

示例10: main

int main()
{

    char playerOne[10];
    char playerTwo[10];
    char mesgOne[50] = "Enter player one's name: ";
    char mesgTwo[50] = "Enter player two's name: ";

    initscr();
    mvprintw(13, 1,"%s",mesgOne);
    getstr(playerOne);
    mvprintw(14, 1,"%s",mesgTwo);
    getstr(playerTwo);

    cbreak();
    noecho();
    drawGrid();

    move(1,2);
    refresh();
    //when you first start the game, the cursor is first space (1,2)

    gamePlay(playerOne, playerTwo);

    refresh();
    getch();
    endwin();
    return 0;
}
开发者ID:Kushal-Pandya,项目名称:CIS2500,代码行数:29,代码来源:a1.c

示例11: autoMoveDown

void autoMoveDown() {
    backupGrid();
    cleanShape(g_CUR_CUBE);
    g_CUR_CUBE->moveDown();
    if(isValidShapePos(g_CUR_CUBE) == false) {
        // move back && setShape
        g_CUR_CUBE->moveUp();
        setShape(g_CUR_CUBE);

        // get next cube && draw it
        g_CUR_CUBE = g_NEXT_CUBE;
        if(isValidShapePos(g_CUR_CUBE) == false) {
            gameOver();
        }
        Shape *s = createShape();
        COORD ref_coord = {4, 2};
        g_NEXT_CUBE = new Cube(ref_coord, s->shape, s->types);
        cleanNEXT(g_CUR_CUBE);
        drawNEXT(g_NEXT_CUBE);
        checkGrid();
    }
    else {
        ; // do nothing
    }
    setShape(g_CUR_CUBE);
    drawGrid();
}
开发者ID:zhanglintc,项目名称:tetris,代码行数:27,代码来源:tetris.cpp

示例12: Display

void Display() {
  glClear (GL_COLOR_BUFFER_BIT);
  glColor3f (1.0, 0.0, 0.0);  

  pthread_mutex_lock(&command_mutex);

  cell_bin[0][0] = cell_bin[0][1] = cell_bin[1][0] = cell_bin[1][1] = 0;
  avg_fitness[0] = avg_fitness[1] = 0.0;
  coherence[0] = coherence[1] = 0.0;
  
  if (stop == false) {
    automata->coherenceModel(payoff_matrix,sim_info.pmut,cell_bin,avg_fitness,coherence);
    timer++;
  }

  //data_file << timer << " " << automata->gtFitness() << endl;
  
  
  glViewport(0,0,400,400);
  glColor3f(0,0,1);
  drawBorder();
  drawGrid();

  glViewport(400,0,400,400);
  glColor3f(0,0,1);
  drawBorder();
  drawMonitor();


  pthread_mutex_unlock(&command_mutex);

  glutSwapBuffers ();
  glutPostRedisplay();
}
开发者ID:dirkzwager,项目名称:CP,代码行数:34,代码来源:main.cpp

示例13: computeTscale

void
ClipObject::draw(QGLViewer *viewer,
		 bool backToFront, float widgetSize)
{
  m_size = widgetSize;
  computeTscale();

  if (!m_show)
    return;

  if (m_imagePresent ||
      m_captionPresent ||
      (m_gridX > 0 && m_gridY > 0) )
    {
      if (m_gridX > 0 && m_gridY > 0)
	drawGrid();

      if (m_imagePresent || m_captionPresent)
	drawCaptionImage();

      if (m_active) drawLines(viewer, backToFront);
    }
  else
    drawLines(viewer, backToFront);
}
开发者ID:Elavina6,项目名称:drishti,代码行数:25,代码来源:clipobject.cpp

示例14: OnRedisplay

//////////////////////////////////////////////////
// This is called on a glutPostRedisplay
//////////////////////////////////////////////////
static void OnRedisplay()
{ 
   glClearColor( 0.0f, 0.0f, 0.0f, 1.0f );
   glClear( GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT );
   glEnable( GL_DEPTH_TEST );
   glEnable( GL_BLEND );
   glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); 
   
   
   // set up the projection matrix
   glMatrixMode( GL_PROJECTION );
      glLoadIdentity();                     
      gluPerspective( 80.0f, AppWindow::width / AppWindow::height, 0.01f, 1000.0f );
                           
   // initialize your matrix stack used for transforming your models
    glMatrixMode( GL_MODELVIEW );
      glLoadIdentity();      

   // !!!TODO!!!: replace the following with your own opengl commands!
   glTranslatef( 0, -10, 0 );
   drawGrid();
   // !!!TODO!!!: ////////////////////////////////////////
   
   // swaps the front and back frame buffers.
   // hint: you've been drawing on the back, offscreen, buffer.  
   // This command then brings that framebuffer onscreen.
   glutSwapBuffers();
}
开发者ID:Michael-Lfx,项目名称:vrjuggler,代码行数:31,代码来源:main.cpp

示例15: drawBackGround

/*!

 */
void
FieldPainter::draw( QPainter & painter )
{
    if ( Options::instance().minimumMode() )
    {
        painter.fillRect( painter.window(),
                          Qt::black );
        return;
    }

    if ( Options::instance().antiAliasing() )
    {
        painter.setRenderHint( QPainter::Antialiasing, false );
    }

    drawBackGround( painter );
    drawLines( painter );
    drawPenaltyAreaLines( painter );
    drawGoalAreaLines( painter );
    drawGoals( painter );
    if ( Options::instance().showFlag() )
    {
        drawFlags( painter );
    }
    if ( Options::instance().gridStep() > 0.0 )
    {
        drawGrid( painter );
    }

    if ( Options::instance().antiAliasing() )
    {
        painter.setRenderHint( QPainter::Antialiasing );
    }
}
开发者ID:edymanoloiu,项目名称:FotbalRobotic,代码行数:37,代码来源:field_painter.cpp


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