void draw(char c, int x,int y,int r,int length) // The function responsible for drawing multiple circles of snake { for(int i=0;i<length;i++)// This loop is to generate different unit circles of snake { if(c=='a') { ellipse(x+2*r*i,y,0,360,r,r); fillellipse(x+2*r*i,y,r,r); } else if(c=='d') { ellipse(x-2*r*i,y,0,360,r,r); fillellipse(x-2*r*i,y,r,r); } else if(c=='w') { ellipse(x,y+2*r*i,0,360,r,r); fillellipse(x,y+2*r*i,r,r); } else if(c=='x') { ellipse(x,y-2*r*i,0,360,r,r); fillellipse(x,y-2*r*i,r,r); } } }
void ClearColor () { setfillstyle(5,15); // body color bar (175,225,225,300); // body setfillstyle(4,15); // hand and foot color bar (164,230,174,250); // left hand bar (226,230,236,250); // right hand bar (164,295,174,315); // left foot bar (226,295,236,315); // right foot setfillstyle(4,15); // hat color fillellipse( 200, 35, 75, 20 ); // hat setfillstyle(8,0); // eyes color fillellipse( 160, 100, 15, 15 ); // eyes fillellipse( 240, 100, 15, 15 ); // eyes setfillstyle(10,15); // nose color fillellipse( 200, 135, 22, 22 ); // nose setfillstyle(8,0); // mouth color fillellipse( 200, 185, 50, 15 ); // mouth }
static void drawAbsolutePosition(Drawable drawable, Point position) { setfillstyle(SOLID_FILL, drawable.color); switch (drawable.type) { case DRAWABLE_TILE: setcolor(drawable.color); setlinestyle(SOLID_LINE, 1, NORM_WIDTH); bar(position.x, position.y, position.x+TILE_SIZE, position.y+TILE_SIZE); break; case DRAWABLE_STATE: setcolor(drawable.color); setlinestyle(DASHED_LINE, 1, THICK_WIDTH); rectangle(position.x, position.y, position.x+TILE_SIZE, position.y+TILE_SIZE); break; case DRAWABLE_CHECKER: setcolor(DARKGRAY); setlinestyle(SOLID_LINE, 1, THICK_WIDTH); fillellipse(position.x + TILE_SIZE/2, position.y + TILE_SIZE/2, TILE_SIZE/3, TILE_SIZE/3); break; case DRAWABLE_CHECKER_CROWN: setcolor(drawable.color); setfillstyle(CLOSE_DOT_FILL, drawable.color); setlinestyle(SOLID_LINE, 1, NORM_WIDTH); fillellipse(position.x + TILE_SIZE/2, position.y + TILE_SIZE/2, TILE_SIZE/6, TILE_SIZE/6); break; } }
void dial(int x,int y) { int const size=200; setfillstyle(1,WBC); fillellipse(x,y,size,size); setfillstyle(1,WBC+1); fillellipse(x,y,size-20,size-20); outtextxy(x,y-(size-40),"12"); outtextxy(x,y+(size-40),"6"); outtextxy(x+(size-40),y,"3"); outtextxy(x-(size-40),y,"9"); outtextxy(x+size/3,y-2*size/3,"1"); outtextxy(x+2*size/3,y-size/3,"2"); outtextxy(x+2*size/3,y+size/3,"4"); outtextxy(x+size/3,y+2*size/3,"5"); outtextxy(x-size/3,y+2*size/3,"7"); outtextxy(x-2*size/3,y+size/3,"8"); outtextxy(x-size/3,y-2*size/3,"11"); outtextxy(x-2*size/3,y-size/3,"10"); circle(x,y,4); }
void car(int x, int y) { moveto(x+50, y+50); bar(x+20, y+50, x+100, y+60); fillellipse(x+35, y+60, 10, 10); fillellipse(x+85, y+60, 10, 10); moveto(x+70, y+50); lineto(x+70, y+40); lineto(x+100, y+50); }
static void draw_radio(control c, rect r) { int w; rect box, textrect; char *name; int style = (AlignLeft | AlignTop); font f; rgb old = currentcolour(); /* Calculate rectangles. */ f = gettextfont(c); setfont(f); w = strwidth(f,"W"); if (w > r.width) w = r.width; if (w > r.height) w = r.height; box = rect(r.x,r.y+1,w,w); if (w < getheight(f) - getdescent(f)) box.y += getheight(f) - getdescent(f) - w; textrect = rect(r.x+w+w/2,r.y,r.width-(w+w/2),r.height); /* Clear the check area. */ setlinewidth(1); setcolour(White); fillellipse(insetr(box,1)); /* Draw the check area */ if (isenabled(c)) setcolour(Black); else setcolour(Grey); drawellipse(box); /* Provide 'pressed button' effect by black border. */ if (ishighlighted(c)) { setlinewidth(2); drawellipse(box); setlinewidth(1); } /* Put o in circle if checked. */ if (ischecked(c)) fillellipse(insetr(box,3)); name = getname(c); if (isenabled(c)) { /* if (hasfocus(c)) { style |= Underline; setlinewidth(2); } */ setcolour(getforeground(c)); } drawtext(textrect, style, name); setcolour(old); }
void edge::display(int aa1,int bb1,int aa2,int bb2) { e[edgenum].id=edgenum; e[edgenum].x1=aa1; e[edgenum].y1=bb1; e[edgenum].x2=aa2; e[edgenum].y2=bb2; setcolor(RED); line(aa1,bb1,aa2,bb2); /////////////display 1st node again//////////////// setfillstyle(SOLID_FILL,RED); setcolor(RED); fillellipse(aa1,bb1,10,10); setcolor(15); char h[1],g[2]; int p,q; if(n_num1<=9) { *h=n_num1+48; *(h+1)='\0'; outtextxy(aa1-3,bb1-3,h); } else { p=n_num1/10; q=n_num1%10; *g=p+48; *(g+1)=q+48; *(g+2)='\0'; outtextxy(aa1-6,bb1-3,g); } // setcolor(RED); //////////////////////display 2nd node again//////////////// setfillstyle(SOLID_FILL,RED); setcolor(RED); fillellipse(aa2,bb2,10,10); setcolor(15); // char h[1],g[2];int p,q; if(n_num2<=9) { *h=n_num2+48; *(h+1)='\0'; outtextxy(aa2-3,bb2-3,h); } else { p=n_num2/10; q=n_num2%10; *g=p+48; *(g+1)=q+48; *(g+2)='\0'; outtextxy(aa2-6,bb2-3,g); } setcolor(RED); }
void Marble(int x,int y,int c) { setfillstyle(1,c); setcolor(c); fillellipse(x,y,8,8); if(c!=0) { if(c==15){setcolor(7);setfillstyle(1,7);} else {setfillstyle(1,15);setcolor(15);} fillellipse(x+3,y-2,1,2); } }
void cardio(int col,int lin,int r) { int p[6]; fillellipse(col-r,lin,r,r); fillellipse(col+r,lin,r,r); pieslice(col,lin,180,210,2*r); pieslice(col,lin,330,360,2*r); p[0]=col-(1.75*r);p[1]=0.98*r+lin; p[2]=col;p[3]=3.3*r+lin; p[4]=col+(1.75*r);p[5]=0.98*r+lin; fillpoly(3, p); p[2]=col; p[3]=lin; fillpoly(3, p); }
main() { int gd = DETECT, gm, area, temp1, temp2, left = 25, top = 75; void *p; initgraph(&gd,&gm,"C:\\TC\\BGI"); setcolor(YELLOW); circle(50,100,25); setfillstyle(SOLID_FILL,YELLOW); floodfill(50,100,YELLOW); setcolor(BLACK); setfillstyle(SOLID_FILL,BLACK); fillellipse(44,85,2,6); fillellipse(56,85,2,6); ellipse(50,100,205,335,20,9); ellipse(50,100,205,335,20,10); ellipse(50,100,205,335,20,11); area = imagesize(left, top, left + 50, top + 50); p = malloc(area); setcolor(WHITE); settextstyle(SANS_SERIF_FONT,HORIZ_DIR,2); outtextxy(155,451,"Smiling Face Animation"); setcolor(BLUE); rectangle(0,0,639,449); while(!kbhit()) { temp1 = 1 + random ( 588 ); temp2 = 1 + random ( 380 ); getimage(left, top, left + 50, top + 50, p); putimage(left, top, p, XOR_PUT); putimage(temp1 , temp2, p, XOR_PUT); delay(100); left = temp1; top = temp2; } getch(); closegraph(); return 0; }
/*displays the main menu */ int intro1() { int n,flag=0,i,cur,sel=0; char ch='a'; clrscr(); cleardevice(); setcolor(YELLOW); settextstyle(TRIPLEX_SCR_FONT,0,6); outtextxy(180,60,"CONNECT 4"); setcolor(YELLOW); settextstyle(1,0,3); outtextxy(280,120,"MENU"); outtextxy(30,180," INSTRUCTIONS"); setcolor(RED); setfillstyle(1,RED); fillellipse(20,195,20,20); cur=0; setcolor(YELLOW); outtextxy(30,240," SELECT A MODE"); outtextxy(30,300," HIGH SCORES"); outtextxy(30,360," QUIT"); outtextxy(10,440,"Navigate using arrow keys."); ch=getch(); while (ch!=13) {if (ch==80) //Down Arrow {setcolor(BLACK); setfillstyle(1,BLACK); fillellipse(20,195+(cur*60),20,20); ++cur; if (cur > 3) cur=3; setcolor(RED); setfillstyle(1,RED); fillellipse(20,195+(cur*60),20,20);} else if(ch==72) //UP Arrow {setcolor(BLACK); setfillstyle(1,BLACK); fillellipse(20,195+(cur*60),20,20); --cur; if (cur<0) cur=0; setcolor(RED); setfillstyle(1,RED); fillellipse(20,195+(cur*60),20,20);} ch=getch(); } return(cur+1); }
void uno() { clearviewport(); setbkcolor(0); fillellipse(320,240,100,50); getch(); }
void ellipse3d(Image *im, Point p, int rad, int i, Image **c, Point sp) { fillarc(im, p, rad, rad, c[0], sp, 45, 180); fillarc(im, p, rad, rad, c[1], sp, 45, -180); fillellipse(im, p, rad-i, rad-i, c[2], sp); }
void mainloop() { //x,y记录当前位置,dx,dy记录速度向量,r记录圆半径 int x = 0, y = 0, dx = 1, dy = 1, r = 100; for ( ; is_run(); delay_fps(60) ) { // todo: 逻辑更新 // 当前位置 + 速度 x += dx; y += dy; if (x < r) dx = 1; //碰左 if (y < r) dy = 1; //碰上 if (x >= ege::getwidth() - r) dx = -1; //碰右 if (y >= ege::getheight() - r) dy = -1; //碰下 // todo: 图形更新 cleardevice(); setcolor(GREEN); setfillcolor(BLUE); fillellipse(x, y, r, r); {// 画帧率文字 char str[20]; sprintf(str, "fps %.02f", getfps()); //调用getfps取得当前帧率 setcolor(WHITE); outtextxy(0, 0, str); } } }
void node::display(int a,int b,int c) { //int id; setfillstyle(SOLID_FILL,RED); setcolor(RED); fillellipse(a,b,10,10); setcolor(15); char h[1],g[2]; int p,q; if(c<=9) { *h=c+48; *(h+1)='\0'; outtextxy(a-3,b-3,h); } else { p=c/10; q=c%10; *g=p+48; *(g+1)=q+48; *(g+2)='\0'; outtextxy(a-6,b-3,g); } setcolor(RED); }
int main() { initgraph(640, 480); //设置绘图颜色,一般用于边界 setcolor(EGERGB(0xFF, 0xFF, 0x0)); //设置填充颜色,一般为图形内部颜色 setfillcolor(EGERGB(0xFF, 0x0, 0x80)); //画一带填充的椭圆 fillellipse(200, 200, 150, 100); //画一个空心圆 circle(500, 300, 100); //再次设置填充颜色,用于决定下一函数填充的颜色 setfillcolor(EGERGB(0x80, 0x0, 0xFF)); //手工填充 //x,y是开始填充的坐标,第三个参数是填充的边界颜色,或者说以这个颜色作为边界 //如果这个边界不封闭,那么会导致整个屏幕都是这个颜色 floodfill(500, 300, EGERGB(0xFF, 0xFF, 0x0)); getch(); closegraph(); return 0; }
//removes the ball from previous frame void removePreviousBall(){ setcolor(0); setfillstyle(1,0); fillellipse(abs(cx),abs(cy),radius,radius); setfillstyle(1,15); setcolor(15); }
void _draw_node(node *p, int x1, int x2, int y) { char content[2]; if (p != NULL) { _draw_node(p->left, x1, (x1+x2)/2, y+DY); content[0] = *((char*)(p+1)); content[1] = NULL; fillellipse((x1+x2)/2, y, textheight(content)/2+5, textheight(content)/2+5); outtextxy((x1+x2)/2, y-3, content); _draw_node(p->right, (x1+x2)/2, x2, y+DY); } else fillellipse((x1+x2)/2, y, 3, 3); }
int main() { PIMAGE img; initgraph(640, 480); //先随便画一些东西 setcolor(EGERGB(0xFF, 0xFF, 0x0)); setfillcolor(EGERGB(0xFF, 0x0, 0x80)); fillellipse(50, 50, 50, 50); img = newimage(); getimage(img, 0, 0, 160, 120); //先画一个非黑色背景,以便于比较 setbkcolor(EGERGB(0x80, 0x80, 0x80)); cleardevice(); //四种贴图比较 putimage(0, 0, img); putimage_alphablend(NULL, img, 160, 0, 0x80); //半透明度为0x80 putimage_transparent(NULL, img, 0, 80, BLACK); //透明贴图,关键色为BLACK,源图为这个颜色的地方会被忽略 putimage_alphatransparent(NULL, img, 160, 80, BLACK, 0xA0); //同时使用透明和半透明 getch(); delimage(img); closegraph(); return 0; }
void main(void) { int tarj,modo,x=320,y=240,c=1; unsigned int segment, offst; detectgraph(&tarj,&modo); initgraph(&tarj,&modo,"c:\\tc\\bgi"); setcolor(0); setfillstyle(1,c); do { t=inport(0x60); /* Leemos la entrada del teclado */ switch (t) { case 28: /* Si se ha pulsado INTRO */ if (c<15) c++; else c=1; setfillstyle(1,c); /* Cambiamos el color del c¡rculo */ break; case 72: /* Cursor arriba */ y--; break; case 75: x--; break; /* Cursor izquierda */ case 77: x++; break; /* Cursor derecha */ case 80: y++; break; /* Cursor abajo */ } fillellipse(x,y,40,40); /* dibujamos el c¡rculo */ /* Esta es una forma pr ctica de borrar la pantalla sin excesivos parpadeos */ *(char far *) MK_FP(0x40,0x1a)=*(char far *) MK_FP(0x40,0x1c); }while(t!=1); /* Mientras no se pulse ESC */ }
void Ocultar() { unsigned guardacolor; guardacolor= getcolor(); setcolor(getbkcolor()); ver=0; fillellipse(x,y,rx,ry); setcolor(guardacolor); }
void mainloop() { for (; is_run(); delay_fps(5)) { setfillcolor(EGERGB(random(255),random(255), random(255))); cleardevice(); fillellipse(200, 200, 50, 30); } }
/*Player is asked to enter password. In place of the character entered by the player, asterixes are printed. The entered string is compared with set password. If the passwords match, player is granted access to the game*/ int getPassword() {clrscr(); cleardevice(); int c=0,end=0,ch,i,j; char p[8]; setcolor(7); setfillstyle(SOLID_FILL,BLUE); rectangle(10,BLUE,635,470); floodfill(15,60,WHITE); setcolor(9); setfillstyle(1,WHITE); rectangle(212,165,387,315); floodfill(200,200,9); char title[13]; strcpy(title,"CONNECT FOUR"); setcolor(RED); settextstyle(TRIPLEX_FONT,0,6); outtextxy(160,60,title); for(i=0;i<7;i++) for(j=0;j<6;j++) {setcolor(WHITE); setfillstyle(1,WHITE); fillellipse((i+1)*25+198,(j)*25+178,ray/2,ray/2);} for(i=1;i<=24;i++) {cout<<"\n";} for (i=1;i<=5;i++) {cout<<"\t";} setcolor (WHITE); setfillstyle(1,WHITE); bar(0,370,330,400); setcolor(BLACK); settextstyle(1,0,1); outtextxy(170,378,"Enter Password: "******"*"; p[c]=ch; ++c; ch=getch();} end=0; if (c>8) end=1; else {for (i=0;i<8;i++) {if (p[i] != password[i]) end=1; } } if (end==1) return(1); else return(0); }
void PutButtons (int level) { // --------------------------------------------------------------------- // Buttons if (level == 5) { setfillstyle(1,4); // red button fillellipse( 400, 100, 20, 20 ); setfillstyle(1,2); // green button fillellipse( 450, 100, 20, 20 ); setfillstyle(1,1); // blue button fillellipse( 500, 100, 20, 20 ); setfillstyle(1,5); // purple button fillellipse( 550, 100, 20, 20 ); setfillstyle(1,14); // yellow button fillellipse( 600, 100, 20, 20 ); } if (level == 3) { setfillstyle(1,4); // red button fillellipse( 400, 100, 20, 20 ); setfillstyle(1,2); // green button fillellipse( 450, 100, 20, 20 ); setfillstyle(1,1); // blue button fillellipse( 500, 100, 20, 20 ); setfillstyle(0,0); // purple button fillellipse( 550, 100, 20, 20 ); setfillstyle(0,0); // yellow button fillellipse( 600, 100, 20, 20 ); } }
void drawlevel(void) { Point p; int x, y, rx, ry, d; char *s = nil; if(finished) draw(screen, screen->r, finished==Won?won:lost, nil, ZP); else draw(screen, screen->r, bg, nil, ZP); d = (Dx(screen->r) > Dy(screen->r)) ? Dy(screen->r) -20: Dx(screen->r) -20; rx = (int)ceil((float)(d-2*Border)/(float)SzX)/2; ry = (int)ceil((float)(d-2*Border)/(float)SzY)/2; for(x = 0; x < SzX; x++) { for(y = 0; y < SzY; y++) { p = board2pix(x, y); switch(grid[x][y]){ case 999: fillellipse(screen, addpt(screen->r.min, p), rx, ry, cc, ZP); break; case 1000: p = addpt(screen->r.min, p); fillellipse(screen, p, rx, ry, ec, ZP); p = subpt(p, Pt(24, 24)); draw(screen, Rpt(p, addpt(p, Pt(48, 48))), gl, glm, ZP); break; default: fillellipse(screen, addpt(screen->r.min, p), rx, ry, ec, ZP); USED(s); /* uncomment the following to see game state and field scores */ /*s = smprint("%d", grid[x][y]); string(screen, addpt(screen->r.min, p), display->black, ZP, font, s); free(s); */ break; } } } flushimage(display, 1); }
void main() {init(); //rectangle(getmaxx()/2-50,getmaxy()/2-150, // getmaxx()/2+150,getmaxy()/2+150); setfillstyle(SOLID_FILL,RED); fillellipse(getmaxx()/2,getmaxy()/2,80,80); setfillstyle(SOLID_FILL,GREEN); fillellipse(getmaxx()/2,getmaxy()/2,50,50); setfillstyle(SOLID_FILL,BLUE); fillellipse(getmaxx()/2,getmaxy()/2,30,30); getch(); boundryfill(getmaxx()/2,getmaxy()/2,BLACK,LIGHTCYAN); getch(); }
void ghost::drawghost(int x,int y) { int i; setcolor(DARKGRAY); setfillstyle(SOLID_FILL,DARKGRAY); //head circle(x,y,r); fillellipse(x,y,r,r); // to fill the head of ghost //body frame for(i=x-r/2;i<=x+r/2;i++) // "i" is the vertical line being chosen (x coordinate) { line(i,y+r,i,y+r+lb); } //right arm ....16 pixels down from the head for(i=0;i<wa;i++) // "i" is the lateral line being chosen (y coordinate) { line(x+r/2,y+i+16,x+r/2+la,y+i+24); } //left arm .... 16 pixels down from the head for(i=0;i<wa;i++) // "i" is the lateral line being chosen (y coordinate) { line(x-r/2,y+i+16,x-r/2-la,y+i+24); } //right leg ....4 pixels above the bottom of the body for(i=0;i<wl;i++) { line(x,y+r+lb+i-8,x+ll,y+r+lb+i+10); } //left leg ....4 pixels above the bottom of the body for(i=0;i<wl;i++) { line(x,y+r+lb+i-8,x-ll,y+r+lb+i+10); } //eyes putpixel(x-r/2,y-r/2,LIGHTGRAY); putpixel(x+r/2,y-r/2,LIGHTGRAY); putpixel(x-r/2-1,y-r/2,LIGHTGRAY); putpixel(x+r/2+1,y-r/2,LIGHTGRAY); putpixel(x-r/2,y-r/2+1,LIGHTGRAY); putpixel(x+r/2,y-r/2+1,LIGHTGRAY); //to draw the nose setcolor(LIGHTGRAY); line(x,y-2,x,y+2); }
void plotdisc(double xc, double yc, double r){ Point p; int rad; p.x=SCX(xc); p.y=SCY(yc); if (r < 0) rad=SCR(-r); else rad=SCR(r); fillellipse(screen, p, rad, rad, getcolor(e1->foregr), ZP); }
void FillColor (int feature, int color) { if (feature == 0) { setfillstyle(5,color); // hat color fillellipse( 200, 35, 75, 20 ); // hat } else if (feature == 1) { setfillstyle(5,color); // eyes color fillellipse( 160, 100, 15, 15 ); // eyes fillellipse( 240, 100, 15, 15 ); // eyes } else if (feature == 2) { setfillstyle(10,color); // nose color fillellipse( 200, 135, 22, 22 ); // nose } else if (feature == 3) { setfillstyle(8,color); // mouth color fillellipse( 200, 185, 50, 15 ); // mouth } else if (feature == 4) { setfillstyle(5,color); // body color bar (175,225,225,300); // body setfillstyle(4,color); // hand and foot color bar (164,230,174,250); // left hand bar (226,230,236,250); // right hand bar (164,295,174,315); // left foot bar (226,295,236,315); // right foot } }
void snake(int x1,int y1,int x2,int y2) { setlinestyle(3,0,3); setcolor(GREEN); line(x1,y1,x2,y2); //setcolor(8); setfillstyle(1,GREEN); fillellipse(x1,y1,4,4); for(int i=-2;i<3;i++) for(int j=-2;j<3;j++) putpixel(x2+i,y2+j,GREEN); }