int main() { int gd=DETECT,gm,i,j,k,l,x1,x2,y1,y2,x3,y3,angle,b[8]; printf("Enter the coordinates of triangle\n"); scanf("%d%d%d%d%d%d",&x1,&y1,&x2,&y2,&x3,&y3); int a[]={x1,y1,x2,y2,x3,y3,x1,y1}; printf("Enter the angle\n"); scanf("%d",&angle); initgraph(&gd,&gm,NULL); setcolor(WHITE); drawpoly(4,a); b[0] = (int)((float)(x1*cos(angle))-(float)(y1*sin(angle))); b[1] = (int)((float)(x1*sin(angle))+(float)(y1*cos(angle))); b[2] = (int)((float)(x2*cos(angle))-(float)(y2*sin(angle))); b[3] = (int)((float)(x2*sin(angle))+(float)(y2*cos(angle))); b[4] = (int)((float)(x3*cos(angle))-(float)(y3*sin(angle))); b[5] = (int)((float)(x3*sin(angle))+(float)(y3*cos(angle))); b[6]=b[0]; b[7]=b[1]; drawpoly(4,b); for(i=0;i<8;i++) { printf("%d ",b[i]); } delay(5000); }
void main() { int gm,gd; printf("Enter line co ordinates x1 y1 x2 y2"); scanf("%d %d %d %d",&x1,&y1,&x2,&y2); printf("Enter window co ordinates xw1,yw1,xw2,yw2"); scanf("%d %d %d %d",&w[0],&w[1],&w[4],&w[5]); detectgraph(&gd,&gm); initgraph(&gd,&gm,"C:\\TURBOC3\\bgi"); w[2]=w[4]; w[3]=w[1]; w[6]=w[0]; w[7]=w[5]; w[8]=w[0]; w[9]=w[1]; line(x1,y1,x2,y2); drawpoly(5,w); cohen(); getch(); closegraph(); detectgraph(&gd,&gm); initgraph(&gd,&gm,"C:\\TURBOC3\\bgi"); line(x1,y1,x2,y2); drawpoly(5,w); getch(); }
void drawhouse(int x, int y) { int house[] = {x,y,x+100,y,x+100,y+100,x,y+100,x,y}; int door[] = {x+25,y+100,x+75,y+100,x+75,y+50,x+25,y+50,x+25,y+100}; int roof[] = {x,y,x+100,y,x+50,y-50,x,y}; int window[] = {x+10,y+10,x+30,y+10,x+30,y+30,x+10,y+30,x+10,y+10}; drawpoly(5,house); drawpoly(5,door); drawpoly(4,roof); drawpoly(5,window); }
void newdrawhouse(int x, int y, int x1w, int y1w, int x2w, int y2w, int x1v, int y1v, int x2v, int y2v) { float sx = (float)(x2v-x1v)/(x2w-x1w); float sy = (float)(y2v-y1v)/(y2w-y1w); int house[] = {x1v+sx*x,y1v+sy*y,x1v+sx*(x+100),y1v+sy*y,x1v+sx*(x+100),y1v+sy*(y+100),x1v+sx*x,y1v+sy*(y+100),x1v+sx*x,y1v+sy*y}; int roof[] = {x1v+sx*x,y1v+sy*y,x1v+sx*(x+100),y1v+sy*y,x1v+sx*(x+50),y1v+sy*(y-50),x1v+sx*x,y1v+sy*y}; int door[] = {x1v+sx*(x+25),y1v+sy*(y+100),x1v+sx*(x+75),y1v+sy*(y+100),x1v+sx*(x+75),y1v+sy*(y+50),x1v+sx*(x+25),y1v+sy*(y+50),x1v+sx*(x+25),y1v+sy*(y+100)}; int window[] = {x1v+sx*(x+10),y1v+sy*(y+10),x1v+sx*(x+30),y1v+sy*(y+10),x1v+sx*(x+30),y1v+sy*(y+30),x1v+sx*(x+10),y1v+sy*(y+30),x1v+sx*(x+10),y1v+sy*(y+10)}; drawpoly(5,house); drawpoly(5,door); drawpoly(4,roof); drawpoly(5,window); }
void club(int *note) { //club effect: colorful lines!!! int pointxy[4]; int color_f=15; srand(time(NULL)); for(int k=0; k<71; k++) { Beep(note[k], note[71+k]); if(k%2) { // same as in play function pointxy[k%2-1]=60+9*(k-1); pointxy[k%2]=750-0.5*note[k-1]; pointxy[k%2+1]=60+9*k; pointxy[k%2+2]=750-0.5*note[k]; } else { pointxy[k%2]=60+9*(k-1); pointxy[k%2+1]=750-0.5*note[k-1]; pointxy[k%2+2]=60+9*k; pointxy[k%2+3]=750-0.5*note[k]; } // select line color color_f=rand()%16; setcolor(color_f); drawpoly(2, &pointxy[0]); delay(10); } system("cls"); setcolor(WHITE);//reset line color }
void POLY::borrarpoly() { int t; t = getcolor(); setcolor (getbkcolor() ); drawpoly (n, puntos); setcolor(t); }
void main() { clrscr(); int poly[20],n,x,y,fill,tp; cout<<"Enter no of vertices of the polygon\n"; cin>>n; for(int i=0;i<n;i++) { cout<<"Enter x and y co-ordinates of point "<<(i+1)<<"\n"; cin>>x>>y; poly[2*i]=320+x; poly[2*i+1]=240-y; } poly[2*n]=poly[0]; poly[2*n+1]=poly[1]; cout<<"Enter co-ordinates of any point inside the polygon\n"; cin>>x>>y; cout<<"Enter fill color\n"; cin>>fill; init(); line(320,0,320,480); line(0,240,640,240); setcolor(14); drawpoly(n+1,poly); floodstk(320+x,240-y,0,fill); getch(); }
void main(){ int n=0,gm,gd=DETECT; initgraph(&gd,&gm,"D:\\TCPP3\\BGI"); clrscr(); cout<<"Enter no. of vertices: "; cin>>n; int coordinates[1000]; cout<<"Enter coordinates:"<<endl; for(int i=0;i<2*n;i+=2){ cout<<"x"<<(i/2)<<": "; cin>>coordinates[i]; cout<<"y"<<(i/2)<<": "; cin>>coordinates[i+1]; } coordinates[2*n]=coordinates[0]; coordinates[2*n+1]=coordinates[1]; clrscr(); cleardevice(); //setbkcolor(9); //setcolor(EGA_WHITE); drawpoly(n+1,coordinates); floodfill(coordinates[0]+1,coordinates[1]+1,BLUE,BLACK); getch(); closegraph(); }
void tree(int x,int ymax) { int poly[]={0,35,35,35,20,0,0,35}; setfillstyle(2,GREEN); drawpoly(4,poly); line(5,5,10,10); }
void line(int x0, int y0, int x1, int y1) { POINT line[2]; line[0].x = x0; line[0].y = y0; line[1].x = x1; line[1].y = y1; drawpoly(2, (int*)&line); }
void rectangle(int left, int top, int right, int bottom) { POINT rect[5]; rect[0].x = left, rect[0].y = top; rect[1].x = right, rect[1].y = top; rect[2].x = right, rect[2].y = bottom; rect[3].x = left, rect[3].y = bottom; rect[4].x = left, rect[4].y = top; drawpoly(5, (int*)&rect); }
void DrawList(List thelist) { // traverse the list from last to first.. drawing each object NodeLink currnode; int color; thelist->cursor = thelist->last; scare_mouse(); while (thelist->cursor != NULL) { currnode = thelist->cursor; if (currnode->Object == LINE) { linebres(currnode->obj_data.line.p1.x, currnode->obj_data.line.p1.y, currnode->obj_data.line.p2.x, currnode->obj_data.line.p2.y, currnode->obj_data.line.color); } else { if (currnode->Object == CIRCLE) { circlebres(screen, currnode->obj_data.circle.p1.x, currnode->obj_data.circle.p1.y, currnode->obj_data.circle.radius, currnode->obj_data.circle.color); } else { if (currnode->Object == POLYGON) { color = currnode->obj_data.polygon.color; drawpoly(currnode,color); } else { if (currnode->Object == TEXT) { textout(screen,font,currnode->obj_data.text.data, currnode->obj_data.text.p1.x, currnode->obj_data.text.p1.y, currnode->obj_data.text.color); } } } } thelist->cursor = thelist->cursor->prev; //mode cursor back a node } unscare_mouse(); }
void Draw() {if(count==0) return; int arr[60]; for(int i=0;i<count;i++) {arr[2*i]=pts[i].x,arr[2*i+1]=pts[i].y;} if(!fill) {drawpoly(count,arr); line(pts[0].x,pts[0].y,pts[count-1].x,pts[count-1].y); } else fillpoly(count,arr); }
void DRAWANGLE(int X1,int Y1,int X2,int Y2,int X3,int Y3,int COLOR) { int DATAARRAY[8]; DATAARRAY[0]=X1; DATAARRAY[1]=Y1; DATAARRAY[2]=X2; DATAARRAY[3]=Y2; DATAARRAY[4]=X3; DATAARRAY[5]=Y3; DATAARRAY[6]=X1; DATAARRAY[7]=Y1; setcolor(COLOR); drawpoly(4,DATAARRAY); }
void tools_icons() { int poly[12]={323,3,337,3,330,10,337,17,323,17,323,3}; int x, y, mx, my, mb,i,j,c=0; int pix[16][16]; int startX=19,startY=0,BUTTON_WIDTH=20,GAP=0; FILE* fp = NULL; if((fp = fopen("Icons.icl","rb")) !=NULL) { x = startX+4, y = startY+2; while( fread(&pix, sizeof(pix), 1, fp) != NULL) { for(i=0; i<16; i++) { for(j=0; j<16; j++) { if(pix[i][j] != 16) putpixel(x+j, y+i, pix[i][j]); } } x+=BUTTON_WIDTH+GAP; c++; if(c==14) break; } fclose(fp); } else { closegraph(); printf("\n Error: Icons.icl file not found....."); getch(); } setcolor(BLUE); setlinestyle(1,0xffff,1); rectangle(303,3,317,17); setlinestyle(0,0xffff,1); drawpoly(6,poly); circle(350,10,7); setfillstyle(1,9); bar(368,3,373,17); setfillstyle(1,4); bar(373,3,378,17); }
main() { int shape[10] = { 50, 50, 100, 150, 200, 150, 350, 90, 50, 50 }; int driver, mode; driver = DETECT; initgraph(&driver, &mode, ""), setbkcolor(CYAN); setcolor(RED); drawpoly(5, shape); getch(); restorecrtmode(); }
void style_icon() { int poly[12]={43,3,57,3,50,10,57,17,43,17,43,3}; switch(cur_tool) { case 10: setlinestyle(1,0xffff,1); setcolor(BLUE); line(63,17,77,3); setlinestyle(0,0xffff,1); setlinestyle(1,0xffff,3); setcolor(BLUE); line(83,17,97,3); setlinestyle(0,0xffff,1); setlinestyle(0,0xffff,1); setcolor(BLUE); line(23,17,37,3); setlinestyle(0,0xffff,3); setcolor(BLUE); line(43,17,57,3); setlinestyle(0,0xffff,1); break; case 17: setcolor(BLUE); circle(30,10,7); arc(50,10,0,180,7); arc(70,10,90,270,7); arc(90,10,180,0,7); arc(110,10,270,90,7); break; case 15: setcolor(BLUE); line(23,17,37,3); drawpoly(6,poly); setlinestyle(1,0xffff,1); rectangle(63,3,77,17); setlinestyle(0,0xffff,1); break; } }
void handle(event me[2]) {if(is1(flag,0)) {if(is1(flag,1)) {if(me[1].x>=x+w1-2&&me[1].y>y&&me[1].x<x+w1+charheight+2&&me[1].y<y+charheight+8) {setfillstyle(SOLID_FILL,ACOL);bar(x+w1-2,y,x+w1+charheight+2,y+charheight+8); if((me[1].b&1)==1){set1(flag,3);set0(flag,1);set1(flag,2);} } } if(is1(flag,2)) {if(me[1].x>x+w/2+w2+1&&me[1].y>y&&me[1].x<x+w/2+w2+charheight+9&&me[1].y<y+charheight+8) {setfillstyle(SOLID_FILL,ACOL);bar(x+w/2+w2+1,y,x+w/2+w2+charheight+9,y+charheight+8); if((me[1].b&1)==1){set1(flag,4);set0(flag,2);set1(flag,1);} } } } if(is1(flag,1)&&is1(flag,0))setcolor(1);else setcolor(8); outtextxy(x+1,y+4," PLAY : "); setcolor(0); setfillstyle(SOLID_FILL,1); int pol[8]; pol[0]=x+w1+2;pol[1]=y+1; pol[2]=x+w1+2;pol[3]=y+charheight+7; pol[4]=x+w1+(charheight+6)/sqrt(2);pol[5]=y+(charheight+6)/2+1; pol[6]=x+w1+2;pol[7]=y+1; fillpoly(4,pol); setcolor(9); drawpoly(4,pol); if(is1(flag,2)&&is1(flag,0))setcolor(2);else setcolor(8); outtextxy(x+1+w/2,y+4," PAUSE : "); setcolor(0); setfillstyle(SOLID_FILL,2); bar(x+w/2+w2+3,y+2,x+w/2+w2+charheight+7,y+charheight+6); setcolor(11); rectangle(x+w/2+w2+3,y+2,x+w/2+w2+charheight+7,y+charheight+6); line(x+w/2+7+w2,y+5,x+w/2+7+w2,y+charheight+3); line(x+w/2+11+w2,y+5,x+w/2+11+w2,y+charheight+3); }
int main() { double x1, y1, x2, y2; int n, poly[14], i; printf("Number of vertices: "); scanf("%d", &n); printf("Enter vertices:\n"); for (i = 0; i < 2 * n; i++) scanf("%d", &poly[i]); poly[2 * n] = poly[0]; poly[2 * n + 1] = poly[1]; printf("Window coordinates (min, max): "); scanf("%f%f%f%f", &xmin, &ymin, &xmax, &ymax); initwindow(640, 480); drawpoly(n + 1, poly); rectangle(xmin, ymin, xmax, ymax); while( !kbhit() ); cleardevice(); for (i = 0; i < n; i++) clip(poly[2 * i], poly[(2 * i) + 1], poly[(2 * i) + 2], poly[(2 * i) + 3]); while( !kbhit() ); return EXIT_SUCCESS; }
void polyfill::getdata() { cout<<"Enter number of vertices : "; cin>>n; int index; index = 2*n; poly = new int[index+2]; for(int i=0;i<index;i++) { cout<<"Enter x co-ordinate : "; cin>>poly[i]; i++; cout<<"Enter y co-ordinate : "; cin>>poly[i]; } poly[index] = poly[0]; poly[index+1] = poly[1]; drawpoly(index+1,poly); }
void main() { int gd,gm,v,i; float thetha,x[10],y[10]; int x1[30]; clrscr(); printf("Enter the no. of vertices\n"); scanf("%d",&v); printf("Enter the co ordinates"); for(i=0;i<v;i++) scanf("%f %f",&x[i],&y[i]); printf("Enter the angle of rotation\n"); scanf("%f",&thetha); thetha=(thetha*3.142/180); for(i=0;i<2*v;i=i+2) { x1[i]=x[i]*cos(thetha)-y[i]*sin(thetha); x1[i+1]=x[i]*sin(thetha)+y[i]*cos(thetha); printf("%d %d ",x[i],x[i+1]); //x[i+1]*cos(thetha)-y[i+1]*sin(thetha); //x[i+1]*sin(thetha)+y[i+1]*cos(thetha); } x1[2*v]=x1[0]; x1[2*v+1]=x1[1]; detectgraph(&gd,&gm); initgraph(&gd,&gm,"C://TURBOC3//BGI"); for(i=0;i<v-1;i++) { line(x[i],y[i],x[i+1],y[i+1]); } line(x[0],y[0],x[v-1],y[v-1]); getch(); drawpoly(v,x1); //line(); getch(); // closegraph(); }
/* * Using polygons, hatching, and filling. */ main() { short val; winopen("poly"); unqdevice(INPUTCHANGE); qdevice(KEYBD); /* enable keyboard */ /* * Wait for REDRAW event ... */ while (qread(&val) != REDRAW) ; color(BLACK); /* clear to black */ clear(); /* * world coordinates are now in the range -10 to 10 * in x, y, and z. Note that positive z is towards us. */ ortho(-10.0, 10.0, -10.0, 10.0, 10.0, -10.0); color(YELLOW); /* * write out the string "Polygon from poly()" in the * starting at (-8.0, -4.0) and scaled to be 4.0 units long, * 0.5 units high. */ hfont("futura.m"); hboxtext(-8.0, -4.0, 4.0, 0.5, "Polygon from poly()/ polf()"); color(GREEN); /* * write out a scaled string starting at (0.0, 6.0) */ hboxtext(0.0, 6.0, 4.5, 0.5, "Polygon from bgnpoly()/ endpoly()"); hboxtext(0.0, 5.0, 4.5, 0.5, " pmv()/ pdr()/ pclos()"); color(MAGENTA); /* * write out a scaled string starting at (0.0, 6.0) */ hboxtext(3.5, -3.5, 1.9, 0.5, "Arc/ Arcf"); /* * draw some wire frame polygons */ drawpoly(); /* * rotate so the next polygons will appear in a different place. */ rot(20.0, 'x'); rot(30.0, 'y'); /* * draw some filled polygons. */ drawpolyf(); gexit(); }
void POLY::dibujarpoly() { drawpoly (n,puntos); }
void generateprojectlists() { for (scene *s=scenelist;s;s=s->next) { for (int i=0;i<s->objectnum;i++) { GLuint lasthandle=256; bool textureon=false; s->objects[i].solidlist=glGenLists(1); s->objects[i].translist=glGenLists(1); s->objects[i].envlist=glGenLists(1); object o=s->objects[i]; glPushAttrib(GL_ALL_ATTRIB_BITS); glNewList(s->objects[i].solidlist,GL_COMPILE); glBegin(GL_TRIANGLES); int y; for (y=0; y<o.polygonnum; y++) if (o.polygons[y].color.w==1.0) { if (o.data.textured && o.polygons[y].texturehandle!=lasthandle) { textureon=true; lasthandle=o.polygons[y].texturehandle; glEnd(); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D,lasthandle); glBegin(GL_TRIANGLES); } if (textureon && !o.polygons[y].texturehandle) { glEnd(); textureon=false; glDisable(GL_TEXTURE_2D); glBegin(GL_TRIANGLES); } drawpoly(&o,y); } glEnd(); glEndList(); glPopAttrib(); glPushAttrib(GL_ALL_ATTRIB_BITS); glNewList(s->objects[i].translist,GL_COMPILE); lasthandle=256; textureon=false; glBegin(GL_TRIANGLES); for (y=0; y<o.polygonnum; y++) if (o.polygons[y].color.w!=1.0) { if (o.data.textured && o.polygons[y].texturehandle!=lasthandle) { textureon=true; lasthandle=o.polygons[y].texturehandle; glEnd(); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D,lasthandle); glBegin(GL_TRIANGLES); } if (textureon && !o.polygons[y].texturehandle) { glEnd(); textureon=false; glDisable(GL_TEXTURE_2D); glBegin(GL_TRIANGLES); } drawpoly(&o,y); } glEnd(); glEndList(); glPopAttrib(); glPushAttrib(GL_ALL_ATTRIB_BITS); glNewList(s->objects[i].envlist,GL_COMPILE); lasthandle=256; textureon=false; glBegin(GL_TRIANGLES); if (o.data.material2set) { for (y=0; y<o.polygonnum; y++) { if (o.data.material2set && o.polygons[y].envmaphandle!=lasthandle) { lasthandle=o.polygons[y].envmaphandle; glEnd(); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D,lasthandle); glBegin(GL_TRIANGLES); } drawpoly(&o,y); } } glEnd(); glEndList(); glPopAttrib(); } } }
main() { int driver = DETECT, mode; char c; int k1[] = { 0, 0, 20, 0, 20, 60, 30, 60, 30, 100, 0, 100, 0, 0 }; int k2[] = { 40, 0, 50, 0, 50, 60, 60, 60, 60, 100, 30, 100, 30, 60, 40, 60, 40, 0 }; int k3[] = { 70, 0, 90, 0, 90, 100, 60, 100, 60, 60, 70, 60, 70, 0 }; int k4[] = { 90, 0, 110, 0, 110, 60, 120, 60, 120, 100, 90, 100, 90, 0 }; int k5[] = { 130, 0, 140, 0, 140, 60, 150, 60, 150, 100, 120, 100, 120, 60, 130, 60, 130, 0 }; int k6[] = { 160, 0, 170, 0, 170, 60, 180, 60, 180, 100, 150, 100, 150, 60, 160, 60, 160, 0 }; int k7[] = { 190, 0, 210, 0, 210, 100, 180, 100, 180, 60, 190, 60, 190, 0 }; int k8[] = { 210, 0, 230, 0, 230, 60, 240, 60, 240, 100, 210, 100, 210, 0 }; int k9[] = { 250, 0, 260, 0, 260, 60, 270, 60, 270, 100, 240, 100, 240, 60, 250, 60, 250, 0 }; int k10[] = { 280, 0, 300, 0, 300, 100, 270, 100, 270, 60, 280, 60, 280, 0 }; int k11[] = { 300, 0, 330, 0, 330, 100, 300, 100, 300, 0 }; int k12[] = { 330, 0, 360, 0, 360, 100, 330, 100, 330, 0 }; initgraph(&driver, &mode, ""); int maxx = getmaxx(); int maxy = getmaxy(); for (long j = 0; j <= 300; j++) { putpixel(random(maxx), random(maxy), 4); delay(1); } setfillstyle(SOLID_FILL, BLACK); bar(89, 39, 571, 261); setlinestyle(SOLID_LINE, 3, 3); line(90, 50, 90, 250); //outline line(100, 40, 540, 40); line(100, 260, 540, 260); line(550, 250, 550, 50); arc(100, 50, 90, 180, 10); arc(100, 250, 180, 270, 10); arc(540, 250, 270, 360, 10); arc(540, 50, 0, 90, 10); circle(200, 90, 35); setfillstyle(SOLID_FILL, 9); floodfill(200, 90, WHITE); circle(482, 95, 42); setfillstyle(SOLID_FILL, 3); floodfill(482, 95, WHITE); setlinestyle(SOLID_LINE, 1, 1); rectangle(270, 60, 370, 130); setfillstyle(SOLID_FILL, 14); floodfill(290, 80, WHITE); rectangle(270, 130, 295, 140); setfillstyle(SOLID_FILL, 5); floodfill(280, 135, WHITE); rectangle(295, 130, 320, 140); setfillstyle(SOLID_FILL, 5); floodfill(300, 135, WHITE); rectangle(320, 130, 345, 140); setfillstyle(SOLID_FILL, 5); floodfill(330, 135, WHITE); rectangle(345, 130, 370, 140); setfillstyle(SOLID_FILL, 5); floodfill(350, 135, WHITE); rectangle(120, 60, 145, 70); setfillstyle(SOLID_FILL, 1); floodfill(130, 65, WHITE); rectangle(120, 90, 145, 100); setfillstyle(SOLID_FILL, 1); floodfill(130, 95, WHITE); ellipse(132, 125, 0, 360, 11, 8); setfillstyle(SOLID_FILL, RED); floodfill(132, 125, WHITE); circle(230, 130, 5); setfillstyle(SOLID_FILL, RED); floodfill(230, 130, WHITE); rectangle(387, 60, 427, 75); setfillstyle(SOLID_FILL, 10); floodfill(395, 70, WHITE); rectangle(385, 90, 403, 110); setfillstyle(SOLID_FILL, 6); floodfill(390, 100, WHITE); rectangle(411, 90, 430, 110); setfillstyle(SOLID_FILL, 6); floodfill(420, 100, WHITE); rectangle(387, 120, 427, 135); setfillstyle(SOLID_FILL, 10); floodfill(395, 130, WHITE); rectangle(150, 260, 510, 250); setfillstyle(SOLID_FILL, 8); floodfill(180, 255, WHITE); circle(500, 120, 6); setfillstyle(SOLID_FILL, 8); floodfill(500, 120, WHITE); setviewport(225, 300, 530, 410, 1); int poly1[] = { 0, 2, 12, 60, 22, 54, 18, 28, 35, 2, 0, 2 }; int poly2[] = { 10, 10, 23, 10, 14, 20, 10, 10 }; int poly3[] = { 50, 0, 60, 2, 60, 45, 50, 42, 50, 0 }; int poly4[] = { 71, 70, 83, 13, 105, 74, 87, 53, 71, 70 }; int poly5[] = { 85, 30, 90, 45, 83, 43, 85, 30 }; int poly6[] = { 110, 53, 120, 2, 130, 57, 148, 0, 135, 84, 132, 84, 118, 29, 110, 53 }; int poly7[] = { 177, 2, 200, 35, 180, 85, 160, 33, 177, 2 }; int poly8[] = { 178, 20, 190, 35, 179, 70, 166, 34, 178, 20 }; drawpoly(6, poly1); setfillstyle(SOLID_FILL, RED); fillpoly(6, poly1); drawpoly(4, poly2); setfillstyle(SOLID_FILL, BLACK); fillpoly(4, poly2); drawpoly(5, poly3); setfillstyle(SOLID_FILL, RED); fillpoly(5, poly3); drawpoly(5, poly4); setfillstyle(SOLID_FILL, RED); fillpoly(5, poly4); drawpoly(4, poly5); setfillstyle(SOLID_FILL, BLACK); fillpoly(4, poly5); drawpoly(8, poly6); setfillstyle(SOLID_FILL, RED); fillpoly(8, poly6); drawpoly(5, poly7); setfillstyle(SOLID_FILL, RED); fillpoly(5, poly7); drawpoly(5, poly8); setfillstyle(SOLID_FILL, BLACK); fillpoly(5, poly8); setviewport(150, 150, 510, 250, 1); pnobody(); c = getch(); do { switch (c) { case 'q': { setfillstyle(SOLID_FILL, GREEN); fillpoly(7, k1); pno(261); setfillstyle(SOLID_FILL, BLUE); fillpoly(7, k1); break; } case 'w': { setfillstyle(SOLID_FILL, RED); fillpoly(9, k2); pno(293); setfillstyle(SOLID_FILL, BLUE); fillpoly(9, k2); pnobody(); break; } case 'e': { setfillstyle(SOLID_FILL, GREEN); fillpoly(7, k3); pno(329); setfillstyle(SOLID_FILL, BLUE); fillpoly(7, k3); pnobody(); break; } case 'r': { setfillstyle(SOLID_FILL, RED); fillpoly(7, k4); pno(350); setfillstyle(SOLID_FILL, BLUE); fillpoly(7, k4); pnobody(); break; } case 't': { setfillstyle(SOLID_FILL, GREEN); fillpoly(9, k5); pno(392); setfillstyle(SOLID_FILL, BLUE); fillpoly(9, k5); pnobody(); break; } case 'y': { setfillstyle(SOLID_FILL, RED); fillpoly(9, k6); pno(440); setfillstyle(SOLID_FILL, BLUE); fillpoly(9, k6); pnobody(); break; } case 'u': { setfillstyle(SOLID_FILL, GREEN); fillpoly(7, k7); pno(493); setfillstyle(SOLID_FILL, BLUE); fillpoly(7, k7); pnobody(); break; } case 'i': { setfillstyle(SOLID_FILL, RED); fillpoly(7, k8); pno(523); setfillstyle(SOLID_FILL, BLUE); fillpoly(7, k8); pnobody(); break; } case 'o': { setfillstyle(SOLID_FILL, GREEN); fillpoly(9, k9); pno(587); setfillstyle(SOLID_FILL, BLUE); fillpoly(9, k9); pnobody(); break; } case 'p': { setfillstyle(SOLID_FILL, RED); fillpoly(7, k10); pno(659); setfillstyle(SOLID_FILL, BLUE); fillpoly(7, k10); pnobody(); break; } case '[': { setfillstyle(SOLID_FILL, GREEN); fillpoly(5, k11); pno(698); setfillstyle(SOLID_FILL, BLUE); fillpoly(5, k11); pnobody(); break; } case ']': { setfillstyle(SOLID_FILL, RED); fillpoly(5, k12); pno(784); setfillstyle(SOLID_FILL, BLUE); fillpoly(5, k12); pnobody(); break; } case '1': { setfillstyle(SOLID_FILL, YELLOW); bar(20, 0, 40, 60); pno(311); setfillstyle(SOLID_FILL, BLACK); bar(20, 0, 40, 60); pnobody(); break; } case '2': { setfillstyle(SOLID_FILL, WHITE); bar(50, 0, 70, 60); pno(370); setfillstyle(SOLID_FILL, BLACK); bar(50, 0, 70, 60); pnobody(); break; } case '4': { setfillstyle(SOLID_FILL, YELLOW); bar(110, 0, 130, 60); pno(415); setfillstyle(SOLID_FILL, BLACK); bar(110, 0, 130, 60); pnobody(); break; } case '5': { setfillstyle(SOLID_FILL, WHITE); bar(140, 0, 160, 60); pno(466); setfillstyle(SOLID_FILL, BLACK); bar(140, 0, 160, 60); pnobody(); break; } case '6': { setfillstyle(SOLID_FILL, YELLOW); bar(170, 0, 190, 60); pno(554); setfillstyle(SOLID_FILL, BLACK); bar(170, 0, 190, 60); pnobody(); break; } case '8': { setfillstyle(SOLID_FILL, WHITE); bar(230, 0, 250, 60); pno(662); setfillstyle(SOLID_FILL, BLACK); bar(230, 0, 250, 60); pnobody(); break; } case '9': { setfillstyle(SOLID_FILL, YELLOW); bar(260, 0, 280, 60); pno(740); setfillstyle(SOLID_FILL, BLACK); bar(260, 0, 280, 60); pnobody(); break; } case 'Q': { setfillstyle(SOLID_FILL, GREEN); fillpoly(7, k1); pno(261); setfillstyle(SOLID_FILL, BLUE); fillpoly(7, k1); break; } case 'W': { setfillstyle(SOLID_FILL, RED); fillpoly(9, k2); pno(293); setfillstyle(SOLID_FILL, BLUE); fillpoly(9, k2); pnobody(); break; } case 'E': { setfillstyle(SOLID_FILL, GREEN); fillpoly(7, k3); pno(329); setfillstyle(SOLID_FILL, BLUE); fillpoly(7, k3); pnobody(); break; } case 'R': { setfillstyle(SOLID_FILL, RED); fillpoly(7, k4); pno(350); setfillstyle(SOLID_FILL, BLUE); fillpoly(7, k4); pnobody(); break; } case 'T': { setfillstyle(SOLID_FILL, GREEN); fillpoly(9, k5); pno(392); setfillstyle(SOLID_FILL, BLUE); fillpoly(9, k5); pnobody(); break; } case 'Y': { setfillstyle(SOLID_FILL, RED); fillpoly(9, k6); pno(440); setfillstyle(SOLID_FILL, BLUE); fillpoly(9, k6); pnobody(); break; } case 'U': { setfillstyle(SOLID_FILL, GREEN); fillpoly(7, k7); pno(493); setfillstyle(SOLID_FILL, BLUE); fillpoly(7, k7); pnobody(); break; } case 'I': { setfillstyle(SOLID_FILL, RED); fillpoly(7, k8); pno(523); setfillstyle(SOLID_FILL, BLUE); fillpoly(7, k8); pnobody(); break; } case 'O': { setfillstyle(SOLID_FILL, GREEN); fillpoly(9, k9); pno(587); setfillstyle(SOLID_FILL, BLUE); fillpoly(9, k9); pnobody(); break; } case 'P': { setfillstyle(SOLID_FILL, RED); fillpoly(7, k10); pno(659); setfillstyle(SOLID_FILL, BLUE); fillpoly(7, k10); pnobody(); break; } case ' ': { break; } } c = getch(); } while (c != ' '); setviewport(0, 0, maxx, maxy, 1); cleardevice(); for (j = 0; j <= 1100; j++) { putpixel(random(maxx), random(maxy), 4); delay(1); } setcolor(4); outtextxy(270, 150, "C R E D I T S"); for (int i = 0; i <= 3; i++) { outtextxy(260, 155 + i, "_______________"); } delay(600); outtextxy(150, 200, " #Suvojit Manna:Concept & Design,Core Programing"); outtextxy(160, 205, "_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ "); delay(600); outtextxy(165, 250, " #Prangshu Shyam:Graphical Assisstance"); outtextxy(180, 255, "_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ "); delay(600); outtextxy(200, 300, " #Sourav Kundu:Final Compilation"); outtextxy(210, 305, "_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ "); getch(); return 0; }
void draw(int xmax,int ymax,int *poly) { x=60; int i=0; START: setfillstyle(7,RED); cleardevice(); int fire_poly[]={65,80+i,65,180+i,55,130+i,25,200+i,25,100+i,40,140+i,65,80+i}; switch(i) { case 0: drawpoly(5, poly); //tree(x,ymax); drawpoly(7,fire_poly); setfillstyle(5,YELLOW); fillpoly(7,fire_poly); man_mv(x,ymax); delay(300); switch(path) { case 0: if(p==11) { getch(); cleardevice(); outtextxy(xmax/2,ymax/2,"LOST LIFE\n Press any key to Continue........\n"); p=-1; path=random(3); getch(); } else if(p==9) p=-1; switch(p) { case -1: bird(20,1); p++; break; case 0: bird(a,b); p++; break; case 1: bird(2*a,b); p++; break; case 2: bird(3*a,2*b); p++; break; case 3: bird(2*a,3*b); p++; break; case 4: bird(4*a,4*b); p++; if(x==380) p++; break; case 5: bird(4*a,ymax-60); break; case 6: bird(4*a,3*b); p++; break; case 7: bird(2*a,2*b); p++; break; case 8: bird(a,4*b); if(x==60) p=9; else p=11; break; case 9: bird(a-20,3*b); delay(1000); break; /*case 10:bird(4*a,ymax-60); getch(); //delay(1000); break; */ case 11:bird(a,ymax-60); //delay(1000); break; } i+=150; if(!kbhit()) { delay(300); goto START; } ch=getch(); delay(100); switch(ch) { case 'a': if(x==60) ; else x-=160; break; case 'd': if(x==540) ; else x+=160; break; } goto START; case 1: if(p==11) { getch(); cleardevice(); outtextxy(xmax/2,ymax/2,"LOST LIFE\n Press any key to Continue........\n"); p=-1; path=random(3); getch(); } else if(p==9) p=-1; switch(p) { case -1: bird(20,1); p++; break; case 0: bird(a,b); p++; break; case 1: bird(2*a,3*b); p++; break; case 2: bird(3*a,2*b); p++; break; case 3: bird(4*a,3*b); p++; break; case 4: bird(5*a,4*b); p++; if(x==540) p++; break; case 5: bird(5*a,ymax-60); break; case 6: bird(4*a,3*b); p++; break; case 7: bird(2*a,3*b); p++; break; case 8: bird(a,4*b); if(x==60) p=9; else p=11; break; case 9: bird(a-20,3*b); delay(1000); break; /*case 10:bird(4*a,ymax-60); getch(); //delay(1000); break; */ case 11:bird(a,ymax-60); //delay(1000); break; } i+=150; if(!kbhit()) { delay(300); goto START; } ch=getch(); delay(100); switch(ch) { case 'a': if(x==60) ; else x-=160; break; case 'd': if(x==540) ; else x+=160; break; } goto START; } break; case 150: drawpoly(5, poly); //tree(x,ymax); drawpoly(7,fire_poly); setfillstyle(5,RED); fillpoly(7,fire_poly); man_mv(x,ymax); delay(300); switch(path) { case 0: if(p==5) { getch(); //cleardevice(); outtextxy(xmax/2,ymax/2,"LOST LIFE\n Press any key to Continue........\n"); p=-1; path=random(3); getch(); } else if(p==9) p=-1; switch(p) { case -1: bird(20,1); p++; break; case 0: bird(a,b); p++; break; case 1: bird(2*a,b); p++; break; case 2: bird(3*a,2*b); p++; break; case 3: bird(2*a,3*b); p++; break; case 4: bird(4*a,4*b); p++; if(x==380) p++; break; case 5: bird(4*a,ymax-60); break; case 6: bird(4*a,3*b); p++; break; case 7: bird(2*a,2*b); p++; break; case 8: bird(a,4*b); if(x==60) p=9; else p=11; break; case 9: bird(a-20,3*b); delay(1000); break; /*case 10:bird(4*a,ymax-60); getch(); // delay(1000); break; */ case 11:bird(a,ymax-60); // delay(1000); break; } i=0; if(!kbhit()) { delay(600); goto START; } ch=getch(); delay(100); switch(ch) { case 'a': if(x==60) ; else x-=160; break; case 'd': if(x==540) ; else x+=160; break; } goto START; case 1: if(p==5) { getch(); cleardevice(); outtextxy(xmax/2,ymax/2,"LOST LIFE\n Press any key to Continue........\n"); p=-1; path=random(3); getch(); } else if(p==9) p=-1; switch(p) { case -1: bird(20,1); p++; break; case 0: bird(a,b); p++; break; case 1: bird(2*a,3*b); p++; break; case 2: bird(3*a,2*b); p++; break; case 3: bird(4*a,3*b); p++; break; case 4: bird(5*a,4*b); p++; if(x==540) p++; break; case 5: bird(5*a,ymax-60); break; case 6: bird(4*a,3*b); p++; break; case 7: bird(2*a,3*b); p++; break; case 8: bird(a,4*b); if(x==60) p=9; else p=11; break; case 9: bird(a-20,3*b); delay(1000); break; /*case 10:bird(4*a,ymax-60); getch(); //delay(1000); break; */ case 11:bird(a,ymax-60); //delay(1000); break; } i=0; if(!kbhit()) { delay(600); goto START; } ch=getch(); delay(100); switch(ch) { case 'a': if(x==60) ; else x-=160; break; case 'd': if(x==540) ; else x+=160; break; } goto START; } break; } }
int main(void) { /* request auto detection */ int gdriver = DETECT, gmode, errorcode; int xmax, ymax; /* initialize graphics and local variables */ initgraph(&gdriver, &gmode, "c:\\TurboC3\\BGI"); /* read result of initialization */ errorcode = graphresult(); /* an error occurred */ if (errorcode != grOk) { printf("Graphics error: %s\n", grapherrormsg(errorcode)); printf("Press any key to halt:"); getch(); exit(1); } setcolor(getmaxcolor()); xmax = getmaxx(); ymax = getmaxy(); int level=0,flag=0,t1=500,t2=300; int well[8]={350-85,250,350-85,400,350+85,400,350+85,250}; while(!kbhit()) { int bucketwater[8]={310,470-level,370,470-level,370,getmaxy(),310,getmaxy()}; int bucket[10]={310,430,370,430,370,getmaxy(),310,getmaxy(),310,430}; drawpoly(5,bucket); int y=0,x=0,y1=0,y2=0,s=0; while(level<50) { cleardevice(); circle(500,200,30); //head line(500,230,500,400); //body line(500,400,450,450); //left leg line(500,400,550,450); //right leg /* int s=0; while(s<25) { line(500,250,450,220+s); line(500,250,450,210+s); setcolor(BLACK); line(500,250,450,220+s); line(500,250,450,210+s); setcolor(WHITE); s=s++; } */ if(flag!=0) { setfillstyle(1,BLUE); fillpoly(4,bucketwater); } drawpoly(5,bucket); if(y2<70) { ellipse(340,220+y2,0,360,10,5); line(340,220,340,225); line(330,220+y2,330,245+y2); line(350,220+y2,350,245+y2); line(330,245+y2,350,245+y2); line(358,170,t1-x,t2-y); line(500,270,450,240); line(500,270,450,230); y2++; } if((y2<90)&&(y2>20)) y2++; // line(350-85,250,350-85,400); //walls // line(350+85,250,350+85,400); //wall // arc(350,235,242,298,185); //base setfillstyle(1,BROWN); fillpoly(4,well); setfillstyle(1,LIGHTGRAY); fillellipse(350,250,85,20); //top line(350-85,250,350-85,150);//structure line(350+85,250,350+85,150);//to hold line(350-85,150,350+85,150);//pulley if(x%2==0) { line(350,165,350,185); line(340,175,360,175); } else { line(350+5,165+2,350-5,185-2); line(350-5,165+2,350+5,185-2); } line(350,150,350,165); circle(350,175,10); //pulley if(y>90) { line(360-2,165+5,400+x,200+y); // t1=x; // t2=y; } // int s=10; if((y>=50)&&(y<90)) { ellipse(340,240-y1,0,360,10,5); line(340,175,340,240-y1); line(330,240-y1,330,265-y1); line(350,240-y1,350,265-y1); line(330,265-y1,350,265-y1); line(360-2,165+5,400+x,200+y); if(s<20) { line(500,270,450,240+s); line(500,270,450,230+s); s++; } // line(450,250,400,220+s); //line(450,250,400,210+s); t1=400+x; t2=200+y; // floodfill(335,280,BLUE); y1++; } else if(y>=90) { int water[8]={330,270-y1,330,470-y1,350,470-y1,350,270-y1}; { line(500,250,350,220); line(500,250,350,210); } ellipse(340,270-y1,0,360,10,10); line(340,175,340,270-y1-10); // line(330,270-y1,330,295-y1); // line(350,270-y1,350,295-y1); // line(330,295-y1,350,295-y1); setfillstyle(1,BLUE); fillpoly(4,water); // delay(15); fillpoly(4,bucketwater); level++; if(level%10==0) { flag=1; break; } } else { line(340,175,340,250); } y++; x++; // s+=3; delay(20); } int overflow[8]={370,430,370,getmaxy(),380,getmaxy(),380,430}; setfillstyle(1,LIGHTBLUE); fillpoly(4,overflow); } /* clean up */ getch(); closegraph(); return 0; }
void main() { int gd=DETECT,gm; int left,top,right,bottom; int x1,x2,y1,y2; int maxx, maxy; /* our polygon array */ int poly[10]; void clipline(dcpt,dcpt,wcpt2,wcpt2); clrscr(); initgraph(&gd,&gm,"c:\\tc30\\bgi"); maxx = getmaxx()/4; maxy = getmaxy()/4; poly[0] = 20; /* 1st vertex */ poly[1] = maxy / 2; poly[2] = maxx - 10; /* 2nd */ poly[3] = 10; poly[4] = maxx - 50; /* 3rd */ poly[5] = maxy - 20; poly[6] = maxx / 2; /* 4th */ poly[7] = maxy / 2; /* drawpoly doesn't automatically close the polygon, so we close it. */ poly[8] = poly[0]; poly[9] = poly[1]; /* draw the polygon */ drawpoly(5, poly); rectangle(20,25,80,125); wcpt2 pt1,pt2; dcpt winmin,winmax; winmin.x=20; winmin.y=25; winmax.x=80; winmax.y=125; pt1.x=20; pt1.y=maxy/2; pt2.x=maxx-10; pt2.y=10; // clipline(winmin,winmax,pt1,pt2); int i=0; for(int index=0;index<n;index++) { if(index==n-1) { pt1.x=poly[i]; pt1.y=poly[i+1]; i=0; pt2.x=poly[i]; pt2.y=poly[i+1]; clipline(winmin,winmax,pt1,pt2); } else { pt1.x=poly[i]; pt1.y=poly[i+1]; pt2.x=poly[i+2]; pt2.y=poly[i+3]; clipline(winmin,winmax,pt1,pt2); } i+=2; } pt1.x=poly[i]; pt1.y=poly[i+1]; clipline(winmin,winmax,pt1,pt2); getch(); }