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


C++ rectangle函数代码示例

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


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

示例1: InitPrintCut

static void InitPrintCut(void)
{
   HWND Window,Mid;
   int xw,yw,i,j;
   char p[40];
   int SaveColor;
   struct viewporttype SaveViewPort;


   BEGINOK;
   //WaitMessageEmpty();

   MouseHidden();
   getviewsettings(&SaveViewPort);
   SaveColor=getcolor();

   SetPrinter(-CurrentPrinter);
   Window=PrintCutWin[wDISPWIN];
   Mid=WindowGetFather(Window);
   ScreenDispWidth=WindowGetWidth(Window)-10;
   ScreenDispHeight=WindowGetHeight(Window)-10;
   WinX=ScreenX=WindowGetLeft(Window)+WindowGetLeft(Mid);
   WinY=ScreenY=WindowGetTop(Window)+WindowGetTop(Mid);

   setviewport(WinX,WinY,WinX+ScreenDispWidth+9,WinY+ScreenDispHeight+9,1);
   setwritemode(COPY_PUT);
   setcolor(EGA_WHITE);
   //setcolor(11);
   bar(0,0,ScreenDispWidth+9,ScreenDispHeight+9);

   PaperW=(float)(printer->xpixel)*25.4/PrinterDPI;
   PaperH=(float)(printer->ypixel)*25.4/PrinterDPI;

   SCRscaleX=PaperW/ScreenDispWidth;
   SCRscaleY=PaperH/ScreenDispHeight;
   if (SCRscaleX>SCRscaleY)
        SCRscaleY=SCRscaleX;
   else
        SCRscaleX=SCRscaleY;

   xw=mXw=PaperW/SCRscaleX;
   yw=mYw=PaperH/SCRscaleY;

   ScreenX=ScreenX+5+(ScreenDispWidth-mXw)/2;
   ScreenY=ScreenY+5+(ScreenDispHeight-mYw)/2;

   //setwritemode(COPY_PUT);
   setcolor(EGA_DARKGRAY);       //gray
   setviewport(0,0,getmaxx(),getmaxy(),1);
   rectangle(ScreenX-1,ScreenY-1,ScreenX+xw,ScreenY+yw);
   //setviewport(ScreenX-1,ScreenY-1,ScreenX+xw,ScreenY+yw,1);
   //rectangle(ScreenX-1,ScreenY-1,ScreenX+xw,ScreenY+yw);
   //setviewport(ScreenX,ScreenY,ScreenX+mXw-1,ScreenY+mYw-1,1);

   GetUserFrame(0,&xw,&yw);
   PageWI=xw;
   PageHI=yw;
   PageW=xw*25.4/1000;
   PageH=yw*25.4/1000;

   sprintf(p,"%4d",(int)(PaperW+.5));
   GetXY(3,&i,&j);
   DispXY(i-10,j,p,COLORP);

   sprintf(p,"%4d",(int)(PaperH+.5));
   GetXY(4,&i,&j);
   DispXY(i-10,j,p,COLORP);

   setwritemode(COPY_PUT);
   setcolor(SaveColor);
   setviewport(SaveViewPort.left,SaveViewPort.top,SaveViewPort.right,
              SaveViewPort.bottom,SaveViewPort.clip);
   MouseShow();

}
开发者ID:Inzaghi2012,项目名称:EZP,代码行数:75,代码来源:PRINTPRO.C

示例2: while

bool SpatialAverageSpotter::train(string dirPath)
{
    
    int count=0;
    vector<vector<tuple<int,Point2f> > > features;
    featureAverages.resize(codebook->size());
    for (int i =0; i<codebook->size(); i++)
        featureAverages[i]=Mat(BASE_SIZE,BASE_SIZE,CV_32F,Scalar(0));
    
    DIR *dir;
    struct dirent *ent;
    if ((dir = opendir (dirPath.c_str())) != NULL) {
      /* print all the files and directories within directory */
//      Mat img;
      while ((ent = readdir (dir)) != NULL) {
          
          string fileName(ent->d_name);
//          cout << "examining " << fileName << endl;
          if (fileName[0] == '.' || fileName[fileName.size()-1]!='G')
              continue;
          
          Mat img = imread(dirPath+fileName, CV_LOAD_IMAGE_GRAYSCALE);
//          resize(img,img,Size(0,0),2,2);
          threshold(img,img,120.0,255,THRESH_BINARY);
//          windowWidth += img.cols;
//          windowHeight += img.rows;
//          int avg=0;
//          for (int x=0; x<img.cols; x++)
//              for (int  y=0; y<img.rows; y++)
//                  avg += (int)img.at<unsigned char>(y,x);
////          cout << "avg="<<avg<<"/"<<img.cols*img.rows<<" = "<<avg/(img.cols*img.rows)<<endl;
//          avg /= img.cols*img.rows;
          
          resize(img,img,Size(PRE_BASE_SIZE,PRE_BASE_SIZE*((0.0+img.rows)/img.cols)));
          
          
          copyMakeBorder( img, img, BORDER_SIZE, BORDER_SIZE, BORDER_SIZE, BORDER_SIZE, BORDER_CONSTANT, 255 );
          assert(img.cols > 1 && img.rows > 1);
          adjustedTrainingImages.push_back(img.clone());
          
          Point2f centerOfMass = findCenterOfMass(img);
          int offsetx=(img.cols/2)-centerOfMass.x;
          int offsety=(img.rows/2)-centerOfMass.y;
          translateImg(img,offsetx,offsety);
          
        
          vector<KeyPoint> keypoints;
          Mat desc;
          detectKeypoints( img,keypoints, desc);
          Mat out;
          cvtColor(img,out,CV_GRAY2RGB);
          circle(out,centerOfMass,1,Scalar(0,0,255));
          
          features.resize(count+1);
          //double scaling = BASE_SIZE/img
          for (int r=0; r<desc.rows; r++)
          {
              int f = codebook->quantize(desc.row(r));
              Point2f offsetPoint(keypoints[r].pt.x - centerOfMass.x, keypoints[r].pt.y - centerOfMass.y);
              features[count].push_back(make_tuple(f,offsetPoint));//we're ignoring the keypoint scale.. 
              
              
//              circle(out,keypoints[r].pt,keypoints[r].size,Scalar(colorTable[f]));
              Rect rec(keypoints[r].pt.x-(keypoints[r].size/2),keypoints[r].pt.y-(keypoints[r].size/2),keypoints[r].size,keypoints[r].size);
              rectangle(out,rec,Scalar(colorTable[f]));
              
          }
          guassColorIn(features[count]);
          
          
          imshow("learning keypoints",out);
          cout << "image "<<count<<endl;
          waitKey(5);
          
          count++;
//          img.release();
      }
      closedir (dir);
    } else {
      /* could not open directory */
      perror ("");
      return false;
    }
    
    //We now step through adjusting the scales of the various images so the guass coloring is maximized
    //But we may still want to look at tfidf to see which ones should be weighted more, etc.
    maximizeAlignment(features);
    
    float max=0;
    float min =99999;
    float avg_max=0;
    
    int firstx=9999;
    int lastx=0;
    int firsty=9999;
    int lasty=0;
    
    for (int f=0; f<codebook->size(); f++)
    {
        float local_max=0;
//.........这里部分代码省略.........
开发者ID:herobd,项目名称:intel_index,代码行数:101,代码来源:spatialaveragespotter.cpp

示例3: switch

void population::draw(QPainter *painter, float GLscale, float viewX, float viewY, int width, int height, QImage image, drawStyle style)
{
    float scale = GLscale/200.0;

    this->setupTrans(GLscale, viewX, viewY, width, height);

    if (this->isSpikeSource) {
        style = spikeSourceDrawStyle;
    }

    switch (style) {
    case microcircuitDrawStyle:
    {
        // draw circle
        QPen oldPen = painter->pen();
        QPen pen = painter->pen();
        pen.setWidthF((pen.widthF()+1.0)*2*scale);
        painter->setPen(pen);
        painter->drawEllipse(transformPoint(QPointF(this->x, this->y)),0.5*GLscale/2.0,0.5*GLscale/2.0);
        painter->setPen(oldPen);
        QFont oldFont = painter->font();
        QFont font = painter->font();
        font.setPointSizeF(GLscale/10.0);
        painter->setFont(font);
        // print label
        QStringList text = this->name.split(" ");
        if (text.size()>0) {
            QString title = text.at(0);
            if (title.size() > 5)
                title.resize(5);
            painter->drawText(QRectF(transformPoint(QPointF(this->x-0.5, this->y-0.2)),transformPoint(QPointF(this->x+0.5, this->y+0.2))), Qt::AlignCenter, title);
            painter->setFont(oldFont);
        }
        return;
    }
    case layersDrawStyle:
    {
        return;
    }
    case spikeSourceDrawStyle:
    {
        // draw circle
        QPen oldPen = painter->pen();
        QPen pen = painter->pen();
        pen.setWidthF((pen.widthF()+1.0));//*GLscale/100.0
        pen.setColor(QColor(200,200,200,0));
        painter->setPen(pen);
        QBrush brush;
        brush.setStyle(Qt::SolidPattern);
        QColor col(this->colour);
        col.setAlpha(100);
        brush.setColor(col);
        QBrush oldBrush = painter->brush();
        painter->setBrush(brush);
        painter->drawEllipse(transformPoint(QPointF(this->x, this->y)),0.5*GLscale/2.0,0.5*GLscale/2.0);
        QFont oldFont = painter->font();
        QFont font = painter->font();
        font.setPointSizeF(GLscale/10.0);
        painter->setFont(font);
        // print label
        pen.setColor(QColor(0,0,0,255));
        painter->setPen(pen);
        //painter->drawText(QRectF(transformPoint(QPointF(this->x-0.5, this->y-0.2)),transformPoint(QPointF(this->x+0.5, this->y+0.2))), Qt::AlignCenter, "SS");
        painter->setFont(oldFont);
        painter->setBrush(oldBrush);
        painter->setPen(oldPen);
        QImage ssimage(":/images/ssBig.png");
        QRectF imRect(transformPoint(QPointF(this->x, this->y))-QPointF(0.4*GLscale/2.0,0.4*GLscale/2.0),QSizeF(0.4*GLscale,0.4*GLscale));
        painter->drawImage(imRect, ssimage);
        return;
        break;
    }
    case standardDrawStyle:
    case standardDrawStyleExcitatory:
    case saveNetworkImageDrawStyle:
    default:
        // do nothing here, break out into the code below.
        break;
    }

    // transform the co-ordinates manually (using the qt transformation leads to blurry fonts!)
    float left = ((this->left+viewX)*GLscale+float(width))/2;
    float right = ((this->right+viewX)*GLscale+float(width))/2;
    float top = ((-this->top+viewY)*GLscale+float(height))/2;
    float bottom = ((-this->bottom+viewY)*GLscale+float(height))/2;

    QRectF rectangle(left, top, right-left, bottom-top);

    QRectF rectangleInner(left+2*scale, top+2*scale, right-left-8*scale, bottom-top-4*scale);

    QColor col(this->colour);
    col.setAlpha(100);
    QPainterPath path;
    path.addRoundedRect(rectangle,0.05*GLscale,0.05*GLscale);

    painter->fillPath(path, col);

    painter->drawImage(rectangle, image);

    // Draw a dark grey border around the population
//.........这里部分代码省略.........
开发者ID:ABRG-Models,项目名称:SpineCreator,代码行数:101,代码来源:population.cpp

示例4: main

main()
{
	int mode=VGAHI,driver=VGA;
	char ch;
 	unsigned int l;
 	int i,gi,gj,j,flag=1;/*i,j是循环变量,flag是标记变量,-1:向x负半轴移动,+1:向x正半轴移动*/
 	double qx,qy,k,b=0.0,speech=0.4,x,y;
 	double r=2.0,bx=60.0,byy=270.0;
 	double pianx=100.0,piany=100.0,tx=20.0,ty=10.0,jx=2.0,jy=2.0;
 	int mx=0,my=0,mb,sum;/*sum纪录砖块的数目*/
 	FILE * p;
  	if((p = fopen("record.dat", "r")) == NULL)
    	{
    		p=fopen("record.dat","w");
    		fprintf(p,"0 0 0 0 0\n");
    		rewind(p);
     	}
     	fclose(p);

	initgraph(&driver,&mode,"C:\\tc");
	setbkcolor(BLUE);
 	Msinit();
 	Setmouse((int)(pianx+1+bx/2),(int)((tx+jx)*8+pianx-1-bx/2),(int)byy+piany,(int)byy+piany);

star:	cleardevice();/*程序重载的介入点*/
	setcolor(RED);
	outtextxy(30,20,"^_^ Welcome to Play Hitting Brick Game! ^_^");

	sum=0;
 	qx=100.0+pianx-10;qy=180.0+pianx-10;k=0.33;
 	setcolor(7);
 	rectangle((int)(pianx-2),(int)(piany-2),(int)((tx+jx)*8+2+pianx),302+piany);
 	setcolor(1);
 	rectangle((int)(pianx-1),(int)(piany-1),(int)((tx+jx)*8+1+pianx),301+piany);
 	/*读取盘面情况*/
 	p=fopen("record.dat", "r");
 	for(i=0;i<5;i++)
 		fscanf(p,"%x ",&zhuan[i]);
 	fclose(p);
 	/*画砖块*/
 	for(i=0;i<5;i++)
 	{
 		l=1;
  		for(j=0;j<16;j++)
  		{
  			if((zhuan[i]&l)==0)
   			{
   				Draw((int)((jx+tx)*((16*i+j)%8)+pianx+jx),(int)((jy+ty)*((int)((16*i+j)/8))+piany+jy),(int)tx,(int)ty);
    				sum+=1;
   			}
   			l=l*2;
  		}
 	}
	gotoxy(5,4);
	printf("Press any key to start game...Q key to quit...");
	ch=getch();
	if(ch=='q'||ch=='Q')
		quitgame();
	else
	{
		gotoxy(5,4);
		printf("                                              ");
	}

 	for(;;)
	{
		setfillstyle(1, 0);
  		bar(mx-bx/2,my,mx+bx/2,my+5);
  		Msread(&mx, &my, &mb);

  		Draw(mx-bx/2,my,bx,5);
  		setcolor(0);
		mycircle(qx,qy,r,0);
  		/*判断求是否反弹*/
  		if(qx-r<=pianx+1 || qx+r>=(tx+jx)*8+pianx-1)
  		{
  			flag=-flag;
  			k=-k;
  		}
  		if(qy-r<=piany+1)
  			k=-k;

  		for(gi=0;gi<5;gi++)
  		{
  			l=1;
  			for(gj=0;gj<16;gj++)
  			{
  				if((zhuan[gi]&l)==0)
    				{
    					j=(16*gi+gj)/8;
     					i=(16*gi+gj)%8;
     					x=(jx+tx)*i+jx+tx/2+pianx;
     					y=(jy+ty)*j+jy+ty/2+piany;
     					/*边判断1*/
     					if(qy>=y-ty/2 && qy<=y+ty/2 &&(pow(qx+r-x+tx/2,2)<1 || pow(qx-r-x-tx/2,2)<1))
      					{
      						flag=-flag;
      						k=-k;
       						zhuan[gi]=zhuan[gi]|l;
       						sum-=1;
//.........这里部分代码省略.........
开发者ID:13436120,项目名称:Cgames,代码行数:101,代码来源:213.C

示例5: rectangle

void Camera::draw_box( Mat* img, Rect rect ){
    rectangle(*img, Point(roi.x, roi.y), Point(roi.x+roi.width,roi.y+roi.height), Scalar(255,0,0), 2, 8, 0  );
}
开发者ID:rondell,项目名称:Cognitive-Robotics-Project,代码行数:3,代码来源:Camera.cpp

示例6: main

int main()
{
int gd=DETECT,gm,i=0,x,y,area;
initgraph(&gd,&gm,"tc:\bgi");//put your directory contains egavga.bgi
rectangle(0,0,getmaxx(),getmaxy());//to find max x and y coordinate in the screen
arc(240,120,40,140,70);//arc(x,y,stangle,endangle,radius);
ellipse(165,80,10,280,20,20);//ellipse (x,y,stangle,endangle,xrad,yrad) ,ears
ellipse(315,80,-100,170,20,20);//ears
arc(235,120,163,215,70);
arc(245,120,-35,17,70);
ellipse(193,178,85,280,40,20);
ellipse(283,178,-100,95,40,20);
ellipse(238,199,180,0,39,50);
ellipse(213,123,44,240,33,40);
ellipse(262,123,-60,135,33,40);
ellipse(210,123,0,360,13,20);//left eye
ellipse(265,123,0,360,13,20);//right eye
ellipse(210,133,0,360,10,10);//left eye ball
ellipse(265,133,0,360,10,10);//right eye ball
ellipse(210,133,0,360,3,3);//left eye ball
ellipse(265,133,0,360,3,3);//right eye ball
ellipse(238,160,0,360,10,13);//nose
arc(240,125,228,312,68);//mouth
arc(240,120,230,310,72);//mouth
setfillstyle(1,4);
floodfill(238,100,15);//floodfill(238,160,15);//nose
setfillstyle(1,15);
floodfill(210,113,15);
floodfill(265,113,15);
setfillstyle(1,9);
floodfill(210,100,15);
setfillstyle(1,1);
floodfill(315,80,15);
moveto(203,220);
lineto(203,260);
lineto(183,260);
lineto(183,350);
lineto(293,350);
lineto(293,260);
lineto(273,260);
lineto(273,220);
moveto(183,350);
lineto(173,460);
lineto(213,460);
lineto(238,400); 
lineto(263,460);
lineto(303,460);
lineto(293,350);
moveto(173,460);
lineto(143,478);
lineto(213,478);
lineto(213,460);
moveto(263,460);
lineto(263,478);
lineto(333,478);
lineto(303,460);
line(238,400,238,350);
//right hand
moveto(183,260);
lineto(113,310);
lineto(183,375);
moveto(183,280);
lineto(137,310);
lineto(181,353);
setfillstyle(2,13);
floodfill(190,300,15);
setfillstyle(1,5);
floodfill(223,400,15);
setfillstyle(1,5);
floodfill(253,400,15);
setfillstyle(1,6);
floodfill(173,470,15);
floodfill(303,470,15);
//fingers
secondleft();
ellipse(413.5,228,0,180,3.5,3.5);
line(420,240,433,240);
line(423,247,440,247);
line(413,240,410,228);
line(417,228,420,240);
ellipse(433,243.5,-90,90,3.5,3.5);
line(423,254,440,254);
ellipse(440,250.5,-90,90,3.5,3.5);
ellipse(430,257,-90,90,3,3);
line(413,260,430,260);

area=imagesize(409,224,444,261);
buf=malloc(area);
getimage(409,224,444,261,buf);
while(!kbhit())
{
if(i==0)
{
setfillstyle(1,15);
setcolor(15);
ellipse(210,133,0,360,10,10);//left eye ball
ellipse(265,133,0,360,10,10);//right eye ball
setcolor(0);
ellipse(210,133,0,360,3,3);//left eye ball
ellipse(265,133,0,360,3,3);//right eye ball
//.........这里部分代码省略.........
开发者ID:saurabhchavan,项目名称:LoadingBar,代码行数:101,代码来源:cgproj.cpp

示例7: filemenu

void filemenu(int mode)
{
	getstats(mode);
	if (button(100,100,170,120,"OPTIMIZE",9,13,base2,false,mode)==DDgui_LeftClick && mode!=DD_AfterCheck) { optimizeproject(); waitleftbutton=true; }
	if (button(100,121,170,141,"TextureO",9,13,base2,false,mode)==DDgui_LeftClick && mode!=DD_AfterCheck) { savetextureusefile(); waitleftbutton=true; }
	if (mode==DD_Draw)
	{
		glColor4f(buttontextlit);
		rectangle(661,120,775,264);
	}	  
	if (mode==DD_Check)
		if (leftclickinwindow(661,121,774,263) && mouseinwindow(661,121,774,260)) fscnselected=min(fscnbarpos+(my-121) / 10,filenum(prjlist)-1);
	if ((mode ==DD_Check) && mouseinwindow(661,121,774,263)) fscnbarpos-=wheel*4;
	scroller(775,120,790,264,15,15,filenum(prjlist),14,fscnbarpos,mode);
	if (mode==DD_Draw)
	{
		pf = prjlist;
		for (x=1;x<=fscnbarpos;x++) pf=pf->next;
		for (x=0;x<=13;x++)
		{
			if (pf!=NULL)
			{
				if (fscnbarpos+x==fscnselected) glColor4f(col4); else glColor4f(buttontextlit);
				glRasterPos2i(665,130+x*10);
				strcpy(st,pf->filedata.cFileName);
				glPrint(st,base2,18);
				pf=pf->next;
			}
		}

		glColor4f(buttontextlit);
		sprintf(s,"%d PROJECTS.",filenum(prjlist));
		glRasterPos2i(683,277);
		glPrint(s,base2);

	}
	glColor4f(1,1,1,1);
	if ((button(686,283,771,299,texbutton1,0,96.0/256.0,85.0/256.0,112.0/256.0,false,mode) == DDgui_LeftClick) && (mode!=DD_AfterCheck))
	{
		pf = prjlist;
		for (x=1;x<=fscnselected;x++) pf=pf->next;
		//sprintf(s,"%s%s",scenedir,pf->filedata.cFileName);
		memset(lastfilename,0,256);
		memcpy(lastfilename,pf->filedata.cFileName,strlen(pf->filedata.cFileName)-4);
		sprintf(s,"%s%s",projectdir,pf->filedata.cFileName);
		//loadaDDictscene(*actualscene,NULL,s,true,true,true,true,true);				
		LoadProject(s);
		modellviews[3].cam=actualscene->editview;
		modellviews[3].cam2=actualscene->editview;
		tTexture *tex=texturelist;
		while ((tex!=NULL) && (tex->number!=selectedtexture)) tex=tex->next;
		memcpy(generatedtexture.commands,tex->commands,sizeof(generatedtexture.commands));
		memcpy(generatedtexture.texts,tex->texts,sizeof(generatedtexture.texts));
		generatedtexture.commandnum=tex->commandnum;
		//memcpy(generatedtexture.layers,tex->layers,sizeof(generatedtexture.layers));
		for (y=0;y<=3;y++)
		{
			glBindTexture(GL_TEXTURE_2D, texlayers[y]);
			glTexImage2D(GL_TEXTURE_2D,0,3,256,256,0,GL_RGBA,GL_UNSIGNED_BYTE,generatedtexture.layers[y]);
		}				
		
		if (materiallist!=NULL)
		{
			matselected=0;
			material *mat=materiallist;
			for (x=1;x<=matselected;x++) mat=mat->next;
			mattexture=mat->handle;
		}				

		waitleftbutton=true;
	}

	if (button(685,300,770,316,texbutton1,0,144.0/256.0,85.0/256.0,160.0/256.0,false,mode) == DDgui_LeftClick) 
	{
		char *ss=readline("Enter Filename (.scn not needed)",210,0,base2,lastfilename);
		if (ss!="")
		{
			//sprintf(s,"%s%s.scn",scenedir,ss);
			//saveaDDictscene(*actualscene,NULL,s,scntexturesave, scncamerasave, scnselectionsave, scnlightsave, scnobjectsave);
			memset(lastfilename,0,256);
			memcpy(lastfilename,ss,strlen(ss));
			sprintf(s,"%s%s.64k",projectdir,ss);
			SaveProject(s);
		}
	}
	if (button(685,317,770,333,texbutton1,0,160.0/256.0,85.0/256.0,176.0/256.0,false,mode) == DDgui_LeftClick) 
	{
		char *ss=readline("Enter Filename (.scn not needed)",210,0,base2,"");
		if (ss!="")
		{
			sprintf(s,"%s%s.m64",minimaldir,ss);
			//SaveMinimalScene(*actualscene,NULL,s);
			saveminimalproject(s,2);
		}
	}
	/*RadioButton(681,341,scntexturesave,"TEXTURES",mode);
	RadioButton(681,355,scncamerasave,"CAMERAS",mode);
	RadioButton(681,369,scnselectionsave,"SELECTIONS",mode);
	RadioButton(681,383,scnlightsave,"LIGHTS",mode);
	RadioButton(681,397,scnobjectsave,"OBJECTS",mode);*/
//.........这里部分代码省略.........
开发者ID:ConspiracyHu,项目名称:2012SourcePack,代码行数:101,代码来源:filemenu.cpp

示例8: main


//.........这里部分代码省略.........
   setcolor(4);
   fillellipse(9,6,1,1);
   fillellipse(15,6,1,1);
   size = imagesize(7,2,18,12);
   head3 = malloc(size);
   getimage(7,2,18,12,head3);


   //head4-down
   //eyes
   fillellipse(9,17,1,1);
   fillellipse(15,17,1,1);
   size = imagesize(7,12,18,22);
   head4 = malloc(size);
   getimage(7,12,18,22,head4);
   cleardevice();


   //food
   setcolor(15);
   setfillstyle(1,15);
   fillellipse(10,10,3,5);
   size = imagesize(5,3,15,17);
   food = malloc(size);
   getimage(5,3,15,17,food);
   cleardevice();

    /* repeat until a key is pressed */

   maxx=getmaxx();
   maxy=getmaxy();
   setlinestyle(0,1,3);
   setcolor(9);
   rectangle(0,0,maxx,maxy);
   setlinestyle(0,1,2);
   line(maxx-150,0,maxx-150,maxy);
   setcolor(8);
   setfillstyle(1,8);
   bar(maxx-147,3,maxx-3,63);
   setcolor(12);
   int maze=1;
   if(maze==1)
   {
   setfillstyle(1,6);
   bar(4,4,maxx-154,14);
   bar(4,4,14,maxy-4);
   bar(4,maxy-4,maxx-154,maxy-14);
   bar(maxx-154-10,4,maxx-154,maxy-4);
   }


   settextstyle(0,0,1);
   delay(300);
   outtextxy(maxx-125,30,"RATTLE SNAKE");
   delay(300);
   setcolor(11);
   setlinestyle(0,1,2);
   rectangle(maxx-145,65,maxx-5,205);
   outtextxy(maxx-128,70,"INSTRUCTIONS");
   delay(200);
   setcolor(6);
   outtextxy(maxx-140,90,"Commands     Key");
   delay(300);
   setcolor(8);
   outtextxy(maxx-140,110," Move Up      8");
   delay(50);
开发者ID:Sir2B,项目名称:Uni,代码行数:67,代码来源:SNAKE.CPP

示例9: main

void main()
{
int total_seats = 84 , total_seats_to_be_booked , display_time , total_seats_booked = 0;
//int gd = DETECT , gm;
//initgraph(&gd,&gm,"c:\\turboc3\\bgi");
clrscr();
welcome_screen();
closegraph();
clrscr();
int gd = DETECT , gm;
initgraph(&gd,&gm,"c:\\turboc3\\bgi");
setbkcolor(GREEN);
for(A=0;A<=79;A++)
cout<<g;
cout << "\n\t\t\tTotal number of seats available is " << total_seats << endl;
for(A=0;A<=79;A++)
cout<<g;
cout<<endl;
cout << "\nEnter number of seats you want to book " << endl;
cin>>total_seats_to_be_booked;
exit_program(total_seats_to_be_booked);
//cout << "\nEnter total number of display time " << endl;
//cin >> display_time;
total_seats_booked += total_seats_to_be_booked;
//display_time = display_time * 1000;
//cin >> total_seats_to_be_booked;
//delay(3000);

getch();
closegraph();
clrscr();
int graphics_driver = DETECT , graphics_mode;
initgraph(&graphics_driver,&graphics_mode,"c:\\turboc3\\bgi");
setcolor(BLUE);
setbkcolor(RED);
setfillstyle(SOLID_FILL,BLUE);
/*Draw seats of a theatre as square boxes */
	char buff[1];
	double c = 0;
for(int j = 10 ; j < getmaxy()-50 ; j+=60)
{
	for(int i = 10 ; i < getmaxx()-50 ; i+=50)
	{
	  c++;
	  gcvt(c ,3 , buff);
	//  memset(buff , c , 0);
	  setfillstyle(SOLID_FILL, BLUE);
	  //textbackground(RED);
	  bar(i , j , i + 35 , j + 35);
	  rectangle(i , j , i + 35 , j + 35);
	  setcolor(15);
	  moveto( i+16 , j+16 );
	 // cout << c;
	  outtext(buff);
	// print_seat_number(c , i , j);
	}
}
//delay(display_time);
getch();
closegraph();
clrscr();
int seat_number;
int seats[84];
memset(seats , 0 , 85);
//gd = DETECT , gm;
initgraph(&gd,&gm,"c:\\turboc3\\bgi");
setbkcolor(BLUE);
cout << "Enter seat numbers you want to book " << endl;
for(int i = 0 ; i < total_seats_to_be_booked ; i++)
{
	cout << "Seat number " << i + 1 << endl;
	cin >> seat_number;
	seats[seat_number] = 1;
}
getch();
clrscr();
gd = DETECT;
initgraph(&gd , &gm , "c:\\turboc3\\bgi");
int k = 0;
setcolor(BLUE);
setbkcolor(RED);
for(int p = 10 ; p <= getmaxy()-50 ; p+=60)
{
	for(int i = 10 ; i <= getmaxx()-50 ; i+=50)
	{
	  k++;
	  gcvt(k ,3 , buff);
	  if(seats[k] == 1)
	  {
		setfillstyle(SOLID_FILL,GREEN);
	  }
	  else
	  {
		setfillstyle(SOLID_FILL, BLUE);
	  }
	  bar(i , p , i + 35 , p + 35);
	  rectangle(i , p , i + 35 , p + 35);
	  setcolor(15);
	  moveto( i+16 , p+16 );
	  outtext(buff);
//.........这里部分代码省略.........
开发者ID:anil1996,项目名称:mini_project,代码行数:101,代码来源:main.cpp

示例10: centre


//.........这里部分代码省略.........

			if (it == hierachedContours.begin() && it->second.size() < _aspectedContours)
				continue;

			for (int k = 0; k < it->second.size(); k++)
			{
				if (it->second[k].size() < _minContourPoints)
				{
					if (k == 0) // padre
						break;
					else        // figlio
						continue;
				}

				convexHull(it->second[k], hull, false);

				double epsilon = it->second[k].size() * 0.003;
				approxPolyDP(it->second[k], approx, epsilon, true);

#ifdef DEBUG_MODE			
				tempI = Scalar(0);
				vector<vector<Point>> temp;
				temp.push_back(approx);
				drawContours(tempI, temp, -1, cv::Scalar(255), 1, CV_AA);
#endif

				// REMOVE TOO EXTERNAL SHAPES -------------

				if (imageTooBig)
				{
					Rect bounding = boundingRect(it->second[k]);

#ifdef DEBUG_MODE
					rectangle(tempI, _deleteRect, Scalar(255));
					rectangle(tempI, bounding, Scalar(255));
#endif

					bool isInternal = bounding.x > _deleteRect.x &&
						bounding.y > _deleteRect.y &&
						bounding.x + bounding.width < _deleteRect.x + _deleteRect.width &&
						bounding.y + bounding.height < _deleteRect.y + _deleteRect.height;


					if (!isInternal)
					{
						if (k == 0)
							break;
					}
				}

				// --------------------------------------------------

				if (!findBaseShape)
				{
					if (hull.size() < minPoint || hull.size() > maxPoint)
					{
						if (k == 0) // padre
							break;
						else        // figlio
							continue;
					}

				}


				if (k == 0)
开发者ID:dariopasquali,项目名称:Tesi,代码行数:67,代码来源:MultiContourObjectDetector.cpp

示例11: money_transfer

void money_transfer()
{

char num,number[20],type[5];int n=0,t=0,coff=1;
setcolor(15);settextstyle(2,0,5);
setfillstyle(0,0);
bar(20,120,100,180);bar(300,10,500,50);
cleardevice();setbkcolor(0);
outtextxy(30,314,"Enter the 10-digit Pin number:");
rectangle(260,314,600,334);
num=0;
while(num!=13)
{
setcolor(15);settextstyle(2,0,4);
if(kbhit())
{
num=getch();
if(isdigit(num) && num!=8 && n<100){
sprintf(number,"%c",num);outtextxy(265+n,314,"*");n+=10;}

if(num==8 && n>0 && n<=100)
{setfillstyle(0,1); bar(265+n,314,265+n-10,328);n-=10;
}

}}

captcha();

num=0;n=0;w=0;

while(num!=13)
{
settextstyle(2,0,4);
if(kbhit())
{
num=getch();
if(num!=8 && n<60){
sprintf(number,"%c",num);
outtextxy(20+n,272,number);n+=10;}

if(num==8 && n>0 && n<=60)
{setfillstyle(1,15); bar(20+n,272,20+n-10,283);n-=10;}

}}

setfillstyle(0,0);
bar(30,305,400,330);

cleardevice();setbkcolor(0);num=0;bk();
setcolor(15);settextstyle(2,0,5);
outtextxy(40,150,"accept the whole fare to transfer from your account?");
outtextxy(70,200,"yes(y)");outtextxy(130,200,"no(n)");
num=getch();

sprintf(number,"%c",num);
outtextxy(40,230,number);

if(num=='y')
{cleardevice();setcolor(0);setcolor(3);settextstyle(2,0,5);bk();
outtextxy(50,240,"transaction is complete.successfully transmitted from your account.");
}
else
{
cleardevice();setcolor(3);settextstyle(2,0,5);
outtextxy(50,240,"interupt caused.transaction stopped.");
}
}
开发者ID:rsabishek,项目名称:Airline-Manager,代码行数:67,代码来源:BKF.C

示例12: secure

void secure()
{
char cha,daff[30];int s=0;
setcolor(15);settextstyle(2,0,5);
cleardevice();setbkcolor(0);
bk();setcolor(15);rectangle(0,0,getmaxx(),getmaxy());
//outtextxy(250,14,"username");rectangle(320,13,600,28);
outtextxy(250,40,"password");rectangle(320,40,600,55);

settextstyle(2,0,4);cha=0;
while(cha!=13)
{
if(kbhit())
{
cha=getch();
if(cha!=8 && s<=200)
{sprintf(daff,"%c",cha);outtextxy(330+s,14,daff);
s+=10;}

if(cha==8 && s>0 && s<=210)
{setfillstyle(0,1); bar(330+s,14,330+s-10,24);s-=10;}

}}

cha=0;
s=0;

while(cha!=13)
{
if(kbhit())
{
cha=getch();
if(cha!=8 && s<200)
{sprintf(daff,"%c",cha);outtextxy(330+s,40,"*");s+=10;}

if(cha==8 && s>0 && s<=210)
{setfillstyle(0,1); bar(330+s,42,330+s-10,50);s-=10;}
}}
cha=0;

cleardevice();setbkcolor(0);
setcolor(3);settextstyle(2,0,5);
outtextxy(40,100,"Payment mode");
setcolor(4);
outtextxy(40,130,"credit");
setcolor(15);
outtextxy(40,140,"debit");
outtextxy(40,150,"net banking.");

pay=0;cha=0;
while(cha!=27)
{
if(kbhit())
{ cha=getch();
if(cha==80 && pay<2)
{pay++;select_pay(pay);}
if(cha==72 && pay>0)
{pay--;select_pay(pay);}
if(cha==13)
break;
}}

}
开发者ID:rsabishek,项目名称:Airline-Manager,代码行数:63,代码来源:BKF.C

示例13: InitSubPage

void InitSubPage(HWND Window,int pt_w,int pt_h,int pg_w,int pg_h)
{
   HWND Mid;
   int xw,yw,i,j;
   char p[40];
   int SaveColor;
   struct viewporttype SaveViewPort;


   WaitMessageEmpty();

   MouseHidden();
   getviewsettings(&SaveViewPort);
   SaveColor=getcolor();

   Mid=WindowGetFather(Window);
   ScreenDispWidth=WindowGetWidth(Window)-10;
   ScreenDispHeight=WindowGetHeight(Window)-10;
   WinX=ScreenX=WindowGetLeft(Window)+WindowGetLeft(Mid);
   WinY=ScreenY=WindowGetTop(Window)+WindowGetTop(Mid);

   setviewport(WinX,WinY,WinX+ScreenDispWidth+9,WinY+ScreenDispHeight+9,1);
   setwritemode(COPY_PUT);
   setcolor(EGA_WHITE);
   bar(0,0,ScreenDispWidth+9,ScreenDispHeight+9);

   SCRscaleX=SubP->TotalX/ScreenDispWidth*1.05;
   SCRscaleY=SubP->TotalY/ScreenDispHeight*1.05;

   if (SCRscaleX>SCRscaleY)
        SCRscaleY=SCRscaleX;
   else
        SCRscaleX=SCRscaleY;

   xw=mXw=pg_w/SCRscaleX;
   yw=mYw=pg_h/SCRscaleY;

   ScreenX=ScreenX+5+(ScreenDispWidth-mXw)/2;
   ScreenY=ScreenY+5+(ScreenDispHeight-mYw)/2;

   //setcolor(EGA_DARKGRAY);       //gray
   setcolor(12);
   setviewport(0,0,getmaxx(),getmaxy(),1);
   rectangle(ScreenX,ScreenY,ScreenX+xw,ScreenY+yw);

   setviewport(WinX,WinY,WinX+ScreenDispWidth+9,WinY+ScreenDispHeight+9,1);

   for (i=0;i<PG.Blocks;i++)
   {
      int x0,x1,y0,y1;
      mXw=ScreenX-WinX;
      mYw=ScreenY-WinY;
      x0=-PG.PageBlock[i].Xoffset*1000/25.4/SCRscaleX+mXw;
      y0=-PG.PageBlock[i].Yoffset*1000/25.4/SCRscaleY+mYw;
      x1=x0+pt_w/SCRscaleX;
      y1=y0+pt_h/SCRscaleY;
      if (PG.PageBlock[i].Reveser&1)
        setcolor(14);
      else
        setcolor(11);
      rectangle(x0,y0,x1,y1);
   }

   setwritemode(COPY_PUT);
   setcolor(SaveColor);
   setviewport(SaveViewPort.left,SaveViewPort.top,SaveViewPort.right,
              SaveViewPort.bottom,SaveViewPort.clip);
   MouseShow();

}
开发者ID:Inzaghi2012,项目名称:EZP,代码行数:70,代码来源:PRINTPRO.C

示例14: while

void *image_show( void *)        /*analiza imagem*/
{
    Mat frameCopy;
    Mat frameAnalize;
    Mat result;
    mouseInfo.event=-1;
    while(1)
    {
        pthread_mutex_lock(&in_frame);
        frameCopy=frame;
        pthread_mutex_unlock(&in_frame);

        pthread_mutex_lock(&in_mouseInfo);
        if(mouseInfo.x > 100 && mouseInfo.y >100 && mouseInfo.event==EVENT_LBUTTONDOWN)
        {
            Cerro;
            printf("Change! \n");
            Rect myDim(mouseInfo.x-25,mouseInfo.y-25, 50, 50);
            frameAnalize = frameCopy(myDim).clone();     
            frameAnalize.copyTo(frameAnalize);
        }
        else if(mouseInfo.event == -1)
        {
            Rect myDim(100,100, 50, 50);
            frameAnalize = frameCopy(myDim);     
            frameAnalize.copyTo(frameAnalize);
            mouseInfo.event=-2;
        }
        pthread_mutex_unlock(&in_mouseInfo);

        /// Create the result matrix
        int result_cols =  frameCopy.cols - frameAnalize.cols + 1;
        int result_rows = frameCopy.rows - frameAnalize.rows + 1;
        result.create( result_cols, result_rows, CV_32FC1 );

        /// Do the Matching and Normalize
        int match_method=1; //1-5
        matchTemplate( frameCopy, frameAnalize, result, match_method );
        normalize( result, result, 0, 1, NORM_MINMAX, -1, Mat() );

        /// Localizing the best match with minMaxLoc
        double minVal; double maxVal; Point minLoc; Point maxLoc;
        Point matchLoc;
        minMaxLoc( result, &minVal, &maxVal, &minLoc, &maxLoc, Mat() );

        /// For SQDIFF and SQDIFF_NORMED, the best matches are lower values. For all the other methods, the higher the better
        if( match_method  == CV_TM_SQDIFF || match_method == CV_TM_SQDIFF_NORMED )
            { matchLoc = minLoc; }
        else
            { matchLoc = maxLoc; }
        
        /// Show me what you got
        rectangle( frameCopy, matchLoc, Point( matchLoc.x + frameAnalize.cols , matchLoc.y + frameAnalize.rows ), Scalar::all(0), 2, 8, 0 );
        rectangle( result, matchLoc, Point( matchLoc.x + frameAnalize.cols , matchLoc.y + frameAnalize.rows ), Scalar::all(0), 2, 8, 0 );

        /// make a dif with the original and the matched
        Rect myDim2(matchLoc.x,matchLoc.y,50 , 50);
        Mat frameAnalizado = frameCopy(myDim2).clone(); 
        Mat subt = frameAnalize - frameAnalizado;

        /// Make a simple text to debug
        char str[256];
        sprintf(str, "x:%d/y:%d", matchLoc.x, matchLoc.y);
        putText(frameCopy, str, cvPoint(30,30), FONT_HERSHEY_COMPLEX_SMALL, 0.8, cvScalar(200,200,250), 1, CV_AA);

        sprintf(str, "maxVal:%.8f/minVal:%.8f", maxVal, minVal);
        putText(frameCopy, str, cvPoint(30,60), FONT_HERSHEY_COMPLEX_SMALL, 0.6, cvScalar(200,200,250), 1, CV_AA);

        /// Show de imgs
        imshow("image_show",frameCopy);
        namedWindow("image_show", CV_WINDOW_NORMAL); waitKey(30);
        imshow("analize",frameAnalize);
        namedWindow("analize", CV_WINDOW_NORMAL); waitKey(30);
        imshow("result",result);
        namedWindow("result", CV_WINDOW_NORMAL); waitKey(30);
        imshow("analizado",frameAnalizado);
        namedWindow("analizado", CV_WINDOW_NORMAL); waitKey(30);
        imshow("sub",subt);
        namedWindow("sub", CV_WINDOW_NORMAL); waitKey(30);

        usleep(10);
        
    }
    Cerro; printf("Image_show Down !\n");
    return NULL;
}
开发者ID:patrickelectric,项目名称:predator,代码行数:86,代码来源:main.cpp

示例15: Play

void Play(void)/*游戏实现过程*/
{
   srand((unsigned long)time(0));
   food.flag=1;/*1表示需出现新食物,0表示食物已存在*/
   snake.life=0;/*标志贪吃蛇活着*/
   snake.dir=1;/*方向向右*/
   snake.x[0]=300;snake.y[0]=240;/*定位蛇头初始位置*/
   snake.x[1]=300;snake.y[1]=240;
   snake.node=2;/*贪食蛇节数*/
   do
   {
      while(!kbhit())/*在没有按键的情况下,蛇自己移动身体*/
      {
	 if(food.flag==1)/*需要出现新食物*/
	 do
	 {
	     food.x=rand()%520+60;
	     food.y=rand()%370+60;
		food.flag=0;/*标志已有食物*/
	 }while(food.x%10!=0||food.y%10!=0);
	 if(food.flag==0)/*画出食物*/
	 {
              setcolor(GREEN);
	      setlinestyle(3,0,3);
              rectangle(food.x,food.y,food.x+10,food.y+10);
	 }
         for(i=snake.node-1;i>0;i--)/*实现蛇向前移动*/
         {
            snake.x[i]=snake.x[i-1];
	    snake.y[i]=snake.y[i-1];
	 }
      
	 switch(snake.dir)
	 {
	    case 1:snake.x[0]+=10;break;/*向右移*/
	    case 2: snake.x[0]-=10;break;/*向左移*/
	    case 3: snake.y[0]-=10;break;/*向上移*/
	    case 4: snake.y[0]+=10;break;/*向下移*/
	 }
	 for(i=3;i<snake.node;i++)
	 {
	    if(snake.x[i]==snake.x[0]&&snake.y[i]==snake.y[0])/*判断蛇是否吃到自己*/
	    {
               GameOver();/*游戏结束*/
               snake.life=1;/*蛇死*/
               break;
	    }
        }
	if(snake.x[0]<60||snake.x[0]>590||snake.y[0]<50||
	   snake.y[0]>440)/*蛇是否撞到墙壁*/
	{
	    GameOver();/*游戏结束*/
	    snake.life=1; /*蛇死*/
	    break;
	}
	if(snake.x[0]==food.x&&snake.y[0]==food.y)/*判断是否吃到食物*/
	{
           setcolor(0);/*用背景色遮盖调食物*/
           rectangle(food.x,food.y,food.x+10,food.y+10);
	   snake.node++;/*蛇的身体长一节*/
	   food.flag=1;/*需要出现新的食物*/
	}
	setcolor(4);/*画蛇*/
	for(i=0;i<snake.node;i++)
	 {     setlinestyle(0,0,1);
	   rectangle(snake.x[i],snake.y[i],snake.x[i]+10,
	       snake.y[i]+10);
	       }
	delay(speed);
	setcolor(0);/*用背景色遮盖蛇的的最后一节*/
	rectangle(snake.x[snake.node-1],snake.y[snake.node-1],
	snake.x[snake.node-1]+10,snake.y[snake.node-1]+10);
     }  /*endwhile(!kbhit)*/
    if(snake.life==1)/*如果蛇死就跳出循环*/
        break;
    key=bioskey(0);/*接收按键*/
       if(key==UP&&snake.dir!=4)/*判断是否往相反的方向移动*/
	  snake.dir=3;
       else
	 if(key==DOWN&&snake.dir!=3)/*判断是否往相反的方向移动*/
		   snake.dir=4;
	  else
	      if(key==RIGHT&&snake.dir!=2)/*判断是否往相反的方向移动*/
	     snake.dir=1;
	     else
	if(key==LEFT&&snake.dir!=1)/*判断是否往相反的方向移动*/
		snake.dir=2;
   }while(key!=ESC);/*ESC键退出游戏*/
}
开发者ID:1040003585,项目名称:LearnedCandCPP,代码行数:89,代码来源:she.C


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