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


C++ drawRectangle函数代码示例

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


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

示例1: glEnable

void SimpleBallGameWidget::paintGL()
{
	glEnable(GL_TEXTURE_2D);

	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glLoadIdentity();
	glColor3f(1, 1, 1);

	// Draw background
	glPushMatrix();
	const float BOX_WIDTH = 130.0f;
	const float BOX_HEIGHT = 84.0f;
	glTranslatef(-BOX_WIDTH / 2, -BOX_HEIGHT / 2, -100.0);
	glBindTexture(GL_TEXTURE_2D, m_backgroundTexture);
	drawRectangle(0.0, 0.0, BOX_WIDTH, BOX_HEIGHT);
	glPopMatrix();

	// Draw ball
	glPushMatrix();
	const float RADIUS = 11.0f;

	// Ball point is in logical units, let's convert it to OpenGL units.
	const float yPixel = ((m_ballPoint.ry()/MAX_LOGICAL) * MAX_BALL_Y_PX) + MIN_BALL_Y_PX;
	glTranslatef(0, -35.0 + yPixel, -90.0);
	glBindTexture(GL_TEXTURE_2D, m_ballTexture);
	drawRectangle(-RADIUS, -RADIUS, RADIUS, RADIUS);
	glPopMatrix();

	glFlush();

	glDisable(GL_TEXTURE_2D);
}
开发者ID:CBRUhelsinki,项目名称:CENTplatform,代码行数:32,代码来源:SimpleBallGameWidget.cpp

示例2: movePaddle

int movePaddle(int padDir, float* topY, float MOVE_DISTANCE, int PAD_HEIGHT, bool** ledArray, float LEFT_X, int PAD_WIDTH, float TOP_MARGIN, float BOT_END) {
    if(padDir != 1 && padDir != 5) {
        padDir = 0;
        return padDir;
    }
    else if(padDir == 1 && (int) (*topY + 0.5) - MOVE_DISTANCE < TOP_MARGIN) {
        padDir = 0;
        return padDir;
    }
    else if(padDir == 5 && (int) (*topY + 0.5) + PAD_HEIGHT - 1 + MOVE_DISTANCE > BOT_END) {
        padDir = 0;
        return padDir;
    }
    if(padDir == 1 && (int) (*topY) != (int) (*topY - MOVE_DISTANCE)) {
        drawRectangle(ledArray, false, *topY + 0.5, LEFT_X, PAD_HEIGHT, PAD_WIDTH);
        *topY -= MOVE_DISTANCE;
        drawRectangle(ledArray, true, *topY + 0.5, LEFT_X, PAD_HEIGHT, PAD_WIDTH);
    }
    else if(padDir == 5 && (int) (*topY) != (int) (*topY + MOVE_DISTANCE)) {
        drawRectangle(ledArray, false, *topY + 0.5, LEFT_X, PAD_HEIGHT, PAD_WIDTH);
        *topY += MOVE_DISTANCE;
        drawRectangle(ledArray, true, *topY + 0.5, LEFT_X, PAD_HEIGHT, PAD_WIDTH);
    }
    return padDir;
}
开发者ID:ECE1T6,项目名称:game-o-matic,代码行数:25,代码来源:pong.c

示例3: drawTopRotor

void drawTopRotor(float r, float angle){
	glPushMatrix();
	glRotatef(angle,0.0f,1.0f,0.0f);
	drawRectangle(r,r/10.0f,r/20.0f);
	glRotatef(180.0f,0.0f,1.0f,0.0f);
	drawRectangle(r,r/10.0f,r/20.0f);
	glPopMatrix();
}
开发者ID:ProZsolt,项目名称:Grafika,代码行数:8,代码来源:hf4.cpp

示例4: drawRectangle

void SpaceShip::draw() const {
	drawRectangle(body, COLOR);
	drawRectangle(cannon, COLOR);
	for (int i = 0; i < bullets.size(); ++i) {
		if (bullets[i].isAlive()) {
			bullets[i].draw();
		}
	}
}
开发者ID:boconnell,项目名称:space-invaders,代码行数:9,代码来源:spaceship.cpp

示例5: glLineWidth

void DrawingContext::drawRectangleFilledWithBorder(GLfloat x, GLfloat y, GLfloat width, GLfloat height) {
  glLineWidth(0);
  glColor3f(fillR, fillG, fillB);
  drawRectangle(GL_QUADS, x, y, width, height);

  glLineWidth(lineWidth);
  glColor3f(lineR, lineG, lineB);
  drawRectangle(GL_LINE_LOOP, x, y, width, height);
}
开发者ID:dasaro77,项目名称:OGLText,代码行数:9,代码来源:DrawingContext.cpp

示例6: createImage

void createImage(){
	int background = 0x1e5096;
	
	printf("P3\n");
	printf("%i %i\n", WIDTH, HEIGHT);
	printf("255\n");
	
	fillBackground(background);
	drawRectangle(0x1e8699, 10, 50, 100, 500, 400);
	drawRectangle(0x6EED1F, 20, 120, 120, 400, 500);
	drawImage();
	
}
开发者ID:domeej,项目名称:Python,代码行数:13,代码来源:zeichne.c

示例7: drawCube

void drawCube(float x1,float y1,float z1,float x2,float y2,float z2){
  float z=z2-z1;
  float d=30,x3,y3,x4,y4;
  drawRectangle(x1,y1,x2,y2);
  x3=pres(x1,z,d);
  y3=pres(y1,z,d);
  x4=pres(x2,z,d);
  y4=pres(y2,z,d);
  drawRectangle(x3,y3,x4,y4);
  line(x1,y1,x3,y3);
  line(x2,y2,x4,y4);
  line(x1,y2,x3,y4);
  line(x2,y1,x4,y3);
}
开发者ID:abhijeetchauhan,项目名称:Algorithms,代码行数:14,代码来源:3drot.c

示例8: drawRectangle

void drawSpectrum::draw(int result[9]){
	for (int i = 0; i < 9; i++) {
		if (result[i] < previousFlow[i]) {

			int debutEffacement = (previousFlow[i]>8) ? 8 : previousFlow[i];
			int x = 9 - debutEffacement;
			drawRectangle(i, debutEffacement, x, 1, 12);
			previousFlow[i] --;
		}
		else {
			drawRectangle(i, 0, result[i], 1, 60);
			previousFlow[i] = result[i];
		}
	}
}
开发者ID:metaheavens,项目名称:LaunchControl,代码行数:15,代码来源:drawSpectrum.cpp

示例9: while

void Draw::renderRect()
{
std::stack <int> tempPoints;
std::stack <char *> tempColor;

tempPoints=pointlist;
tempColor=colorlist;

if (pointlist.size()/4!=(colorlist.size()))
std::cout<<"Error,mismatch between number of colors and points in the rectangle"<<std::endl;

    while(!tempPoints.empty())
{
int x = tempPoints.top();
tempPoints.pop();
int y = tempPoints.top();
tempPoints.pop();
int width = tempPoints.top();
tempPoints.pop();
int height = tempPoints.top();
tempPoints.pop();



drawRectangle(x,y,width,height,tempColor.top());

tempColor.pop();

}


}
开发者ID:gregf,项目名称:Maze-background,代码行数:32,代码来源:maze.cpp

示例10: calculateTextSize

void Button::draw ( int _x, int _y )
{
	std::pair< int, int > dimensions = calculateTextSize();

	drawRectangle( _x, _y, dimensions.first + 2 * PADDING, dimensions.second + 2 * PADDING );
	drawText( _x + PADDING, _y + PADDING );
}
开发者ID:zaychenko-sergei,项目名称:oop-samples,代码行数:7,代码来源:button.cpp

示例11: drawRectangle

	void DrawingSurface::drawFilledRectangle(const Color::RGBA<float>& frontColor,
		const Color::RGBA<float>& backColor, float x, float y, float width, float height, float lineWidth)
	{
		if (backColor.alpha > 0)
		{
			// Draw the back as a quad with the proper color
			pImpl->baseShader->bindUniform("Color", backColor);
			const float vertices[] =
				{
					x, y + height,
					x, y,
					x + width, y,
					x, y + height,
					x + width, y,
					x + width, y + height
				};
			::glEnableVertexAttribArray(Gfx3D::Vertex<>::vaPosition);
			::glVertexAttribPointer(Gfx3D::Vertex<>::vaPosition, 2, GL_FLOAT, false, 0, vertices);
			// Draw
			::glDrawArrays(GL_TRIANGLES, 0, 6);
			::glDisableVertexAttribArray(Gfx3D::Vertex<>::vaPosition);
		}

		if (frontColor != backColor && lineWidth > 0)
			drawRectangle(frontColor, backColor, x, y, width, height, lineWidth);
	}
开发者ID:MAPJe71,项目名称:libyuni,代码行数:26,代码来源:drawingsurface.cpp

示例12: mouse

/* draw figure what was chosen from the buttons */
void mouse(int button, int state, int x, int y)
{
  int new_y = mapState.window_height - y;
  int a;
  Point* new_point ;
  a = (x > PANEL_BORD_PADDING);

  initFlag(x, new_y);

  if (mapState.drawing_state == DRAWING_RECT && a) {
    drawRectangle(x, new_y);

  } else if (mapState.drawing_state == DRAWING_CIRCLE && a) {
    drawCircle(x, new_y, CIRCLE_DIAMETER);

  } else if (mapState.drawing_state == DRAWING_LINE && a) {

    if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN) {
      mapState.DrawingLine = START;
      mapState.new_point = createPoint(x, new_y, mapState.points_storage, mapState.marked_point);
      createEdge(mapState.edges_storage, mapState.new_point, mapState.marked_point, mapState.previous_point);
      mapState.previous_point = mapState.new_point;
    }  
    draw();
  }
}
开发者ID:valcat,项目名称:Paint-Map,代码行数:27,代码来源:paint-map.c

示例13: MessageBox

	//处理图片的事件处理函数
	void CRecognitionTextView::OnDeal()
	{
		// TODO: 在此添加命令处理程序代码
		if(src == NULL)
		{
			if(filePath !="")
			{
				src = tools.deal(filePath,src,&outlineSs,&lines,outline,isCutted);
				if(src == NULL)
				{
					MessageBox(TEXT("加载失败!"));
				}
				else
				{
					Invalidate();
					drawRectangle(0, m_nVScrollPos);
					OnPaint();
				}
			}
			else
			{
				MessageBox(TEXT("未加载图片!"));
			}
		}
		else
		{
			MessageBox(TEXT("不能处理图片!"));
		}
	}
开发者ID:GigaLove,项目名称:WordRecognition,代码行数:30,代码来源:RecognitionTextView.cpp

示例14: main

void main(void)
{
	unsigned char tmp;	
	unsigned char x = 0;
	
	P1_4 = 1;

	//P1_4 = 0;
	fb_init();
	keyboard_init();
	EA = 1;	 // enable global interrupts

	clearDisplay();
	drawRectangle(0,0,13,19);

	
	while(1) {
		/*	
		tmp = readBuf();

		if(tmp == 0x34) 
		{ 
			if(x == 0){
				setPx(2,2);
				x = 1;	
			}
			else {
				clearPx(2,2);
				x = 0;
			}
		}
		*/
	}	
}
开发者ID:schuere,项目名称:hnseBoard,代码行数:34,代码来源:main.c

示例15: glLineWidth

void Frame::drawBorder() {
  glLineWidth(1.0f);
  glColor3f(0.3f, 0.3f, 0.3f);
  drawRectangle(
    posLeft, posTop,
    outerWidth, outerHeight);
}
开发者ID:gaborpapp,项目名称:sonotopy,代码行数:7,代码来源:Frame.cpp


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