• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ drawGrid函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了drawGrid函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: 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


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


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


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


示例8: drawGrid

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


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


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


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


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


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


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


示例15: drawPreview

static void drawPreview(struct colorDialog *c, ID2D1RenderTarget *rt)
{
	D2D1_SIZE_F size;
	D2D1_RECT_F rect;
	double r, g, b;
	D2D1_COLOR_F color;
	D2D1_BRUSH_PROPERTIES bprop;
	ID2D1SolidColorBrush *brush;
	HRESULT hr;

	size = realGetSize(rt);
	rect.left = 0;
	rect.top = 0;
	rect.right = size.width;
	rect.bottom = size.height;

	drawGrid(rt, &rect);

	hsv2RGB(c->h, c->s, c->v, &r, &g, &b);
	color.r = r;
	color.g = g;
	color.b = b;
	color.a = c->a;
	ZeroMemory(&bprop, sizeof (D2D1_BRUSH_PROPERTIES));
	bprop.opacity = 1.0;
	bprop.transform._11 = 1;
	bprop.transform._22 = 1;
	hr = rt->CreateSolidColorBrush(&color, &bprop, &brush);
	if (hr != S_OK)
		logHRESULT(L"error creating brush for preview", hr);
	rt->FillRectangle(&rect, brush);
	brush->Release();
}
开发者ID:StapleButter,项目名称:melonDS,代码行数:33,代码来源:colordialog.cpp


示例16: QPixmap

void gyro_widget::refreshPixmap()
{
  pixmap = QPixmap(size());
  pixmap.fill(this, 0, 0);
 
  
  if(abs(gyro_x) < 2)
    gyro_x = 0;
  else
    gyro_x = multiplier_x * gyro_x;
  if(abs(gyro_y) < 2)
    gyro_y = 0;
  else 
    gyro_y = multiplier_y * gyro_y;
  
  pos_x = (pos_x - gyro_x < 5) ? 5 : (pos_x - gyro_x);
  if(pos_x > width() - 5 )
    pos_x = width() - 5;
  pos_y = (pos_y - gyro_y < 5) ? 5 : (pos_y - gyro_y);
  if(pos_y > height() - 5 ) 
    pos_y = height() - 5;

  QPainter painter(&pixmap);
  painter.initFrom(this);
  drawGrid(&painter);
  drawSquare(&painter);
  update();
}
开发者ID:willpan,项目名称:WinlabEEG,代码行数:28,代码来源:gyro_widget.cpp


示例17: display

void display (void) {
	glClearDepth (1);
    glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glLoadIdentity();  
	gluLookAt(120.0, 20.0, 140.0,		
              0.0, 0.0, 0.0,		
              0.0, 5.0, 0.0);		
	float pos[]={10.0,90.0,-110.0,1.0};        //set the position
	glLightfv(GL_LIGHT0,GL_POSITION,pos);
	glEnable(GL_COLOR_MATERIAL);
	
	camera();
	glPushMatrix();
	
	glTranslatef(0, -30, 0);
	//glScalef(10,10,10);
	//glCallList(cube);
	glPopMatrix();
	drawGrid();
	//createHabitat();
	drawWalls();
	drawHabitat();
	drawFood();
	drawObject();
	drawPredator();

	//saveToDisk();
    glutSwapBuffers();
}
开发者ID:avasay,项目名称:Flocking,代码行数:29,代码来源:flock1.cpp


示例18: drawGrid

void CSceneWidget::drawForeground(QPainter *painter, const QRectF &rect)
{
    if (m_gridEnabled && m_cellWidth > 0) {
        drawGrid(painter);
    }
    QGraphicsView::drawForeground(painter, rect);
}
开发者ID:slima4,项目名称:zgui-qt,代码行数:7,代码来源:scenewidget.cpp


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


示例20: glClear

        void Render::draw(Camera *camera, Container& container)
        {
            glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
            glUseProgram(shader->getProgramID());

            glEnableVertexAttribArray(0);
            glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer);
            glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, (void*)0);

            //glEnableVertexAttribArray(1);
            //glBindBuffer(GL_ARRAY_BUFFER, colorbuffer);
            //glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, (void*)0);

            glEnableVertexAttribArray(2);
            glBindBuffer(GL_ARRAY_BUFFER, normalbuffer);
            glVertexAttribPointer(2, 3, GL_FLOAT, GL_FALSE, 0, (void*)0);

            glUniformMatrix4fv(camera->get_projection_location(), 1, GL_FALSE, camera->get_projection_matrix());
            glUniformMatrix4fv(camera->get_view_location(), 1, GL_FALSE, camera->get_view_matrix());
            glUniformMatrix4fv(camera->get_model_location(), 1, GL_FALSE, camera->get_model_matrix());

            drawGrid();
            drawContainer(container, camera);
            drawLayers(container.getLayers(), camera);

            glDisableVertexAttribArray(0);
            glDisableVertexAttribArray(1);
            glDisableVertexAttribArray(2);
        }
开发者ID:krabex,项目名称:ContainerLoadingProblem-AI_UWr,代码行数:29,代码来源:Render.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ drawImage函数代码示例发布时间:2022-05-30
下一篇:
C++ drawFrame函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap