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

C++ drawRectangle函数代码示例

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

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



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


示例16: glLoadIdentity

void OpenGLInterface::printHistogram(Histogram &histogram, FigureRectangle rectangle) {
	/* Put coursor back to (0, 0, 0) */
    glLoadIdentity();
	int numberOfBins = histogram.getNumberOfArguments();
	int numberOfCharts = histogram.getNumberOfCharts();
	double binWidth = 1 / double(numberOfBins);

	drawArgumentLabels(histogram.getMinArgument(), histogram.getMaxArgument(), 4, rectangle);
	drawValueLabels(histogram.getMinValue(), histogram.getMaxValue(), 4, rectangle);
	rectangle.resize(0.93, 0.93);

	glEnable(GL_ALPHA_TEST);
	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_DST_ALPHA);
	double leftDownX = rectangle.getMiddleX() - rectangle.getSizeX() / 2;
	double leftDownY = rectangle.getMiddleY() - rectangle.getSizeY() / 2;
	double sizeX = rectangle.getSizeX();
	double sizeY = rectangle.getSizeY();
	double sideGap = configurator->getSideGap();

	for(int j = 0; j < numberOfCharts; j++) {
		FigureRectangle histogramColumn;
		Color color = histogram.getColor(j);
		histogramColumn.setColor(color);

		for(int i = 0; i < numberOfBins; i++) {
			histogramColumn.setFigure(leftDownX + i * binWidth * sizeX, leftDownY, leftDownX + ((i + 1) * binWidth - binWidth * sideGap) * sizeX, leftDownY + histogram.getValue(j, i) / histogram.getMaxValue() * sizeY);
			drawRectangle(histogramColumn);
		}
	}
	glDisable(GL_BLEND);
	glDisable(GL_ALPHA_TEST);
}
开发者ID:a-einstein1879,项目名称:MarketProject,代码行数:33,代码来源:outputGraphics.cpp


示例17: glRotatef

void Orbiter::render(){
	if(orbit!=NULL){
	orbit->fill=fill;
	orbit->render();
	glRotatef(angle,0,0,1);
	glTranslatef(orbitrad,0,0);
	glGetFloatv(GL_MODELVIEW_MATRIX, buffer);
	x=buffer[12];
	y=buffer[13];
	if(staticOb)
		glRotatef(-angle,0,0,1);
	if(fill)
	glBegin(GL_POLYGON);
	else
	glBegin(GL_LINE_LOOP);
		glColor4f(0,1,1,1);
		glVertex2f(-radius/2,-radius/2);
		glVertex2f(-radius/2,radius/2);
		glColor4f(1,0,0,1);
		glVertex2f(radius/2,radius/2);
		glVertex2f(radius/2,-radius/2);
	glEnd();
	if(!staticOb)
	glRotatef(-angle,0,0,1);
	
	}
	else{
	glLoadIdentity();
	glTranslatef(x,y,0);
	glRotatef(angle,0,0,1);
	glColor3f(1,0,1);
	drawRectangle(radius,radius,fill);
	}
}
开发者ID:smrutled,项目名称:CSE-Opengl-Projects,代码行数:34,代码来源:Orbiter.cpp


示例18: QThread

void Mwars::on_pbRectangle_clicked()
{
    if(rectangleIsRunning) {
        QMessageBox::critical(this, "Error", "Rectangle is already running");
        return;
    }

    workerThread = new QThread();            // instantiates ScannerDraw class and the QThread
    scannerDraw = new ScannerDraw(this, 33, 44);   // on heap

    scannerDraw->moveToThread(workerThread);
    connect(workerThread, SIGNAL(started()), scannerDraw, SLOT(drawRectangle()));

    connect(scannerDraw, SIGNAL(finished()), workerThread, SLOT(quit()), Qt::DirectConnection);
    connect(scannerDraw, SIGNAL(finished()), scannerDraw, SLOT(deleteLater()));
    connect(scannerDraw, SIGNAL(finished()), workerThread, SLOT(deleteLater()));

    connect(workerThread, SIGNAL(finished()), this, SLOT(rectangleFinished()));

    connect(ui->pbStopRectangle, SIGNAL(clicked()), this, SLOT(stopRectangle()));

    // need these signals cause can't call sockets across threads
    connect(scannerDraw, SIGNAL(sendScannerMssg (ushort, ushort, ushort)), this, SLOT(sendScannerMssg(ushort, ushort, ushort)));
    connect(scannerDraw, SIGNAL (laserOn()), this, SLOT(laserOn()));
    connect(scannerDraw, SIGNAL (laserOff()), this, SLOT(laserOff()));
    connect(scannerDraw, SIGNAL (scannerOn()), this, SLOT(scannerOn()));
    connect(scannerDraw, SIGNAL (scannerOff()), this, SLOT(scannerOff()));

    workerThread->start();

    rectangleIsRunning = true;
    ui->pbStopRectangle->setEnabled(true);
}
开发者ID:OliverBJ01,项目名称:scannerConsole,代码行数:33,代码来源:console.cpp


示例19: advanceGame

void advanceGame(void* gameMemory, OOGameInput* input, OOGameOutput* output) {
	cbgame * game = (cbgame*) gameMemory;

	game->input = input;
	game->output = output;

	if( !game->initialised ) {
		initGame(game);
	}

	game->moveDelta = game->p1.x;
	updateGame(game);
	game->moveDelta -= game->p1.x;

	clearScreen(game);
	
	drawPlayer(game, &game->p2);
	drawPlayer(game, &game->p1);

	// draw a rectangle at the mouse position
	drawRectangle(game, (ooint)input->mouse.x, (ooint)input->mouse.y, 25, 25, 0xffff0000);

	outputSine(game);

	game->time += game->input->dt;
}
开发者ID:ali-motisi,项目名称:CerealBox,代码行数:26,代码来源:cbsamplegame.c


示例20: getvals

struct IplImage *framescompare(struct IplImage *curr, struct IplImage *prev)
{
	int x, y, h, w;
	struct IplImage *res;
	unsigned char *pvdata, *cvdata;
	struct rct rectangle;

	h = curr->height;
	w = curr->width;
	
	cvdata = getvals(curr);

	pvdata = getvals(prev);
	
	res = ipl_cloneimg(prev);
	
	for(y = 0; y < h; y++) {
		for(x = 0; x < w; x++) {
			if(abs(cvdata[y * w + x] - pvdata[y * w + x]) > 20) {
				rectangle.x1 = x;
				rectangle.y1 = y;
				rectangle.x2 = x;
				rectangle.y2 = y;
				getobj(cvdata, pvdata, x, y, w, h, &rectangle);
			}
			if((rectangle.x2 - rectangle.x1) * (rectangle.y2 - rectangle.y1) > 50) {
			drawRectangle(res, rectangle.x1, rectangle.y1, rectangle.x2, rectangle.y2);
			}
		}
	}
	
	free(pvdata);
	free(cvdata);
	return res;
}
开发者ID:muller95,项目名称:LampCV,代码行数:35,代码来源:justcomp.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ drawScene函数代码示例发布时间:2022-05-30
下一篇:
C++ drawRect函数代码示例发布时间: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