This program generates pattern of ‘*’ of given input string.It has also chessboard type background. It is animated and continuously changes colour.
- /*This Program Makes Pattern Of String You Enter.
- Input must be string without numbers and capital letters.*/
- /* Variable info
- r = radius of curve in characters like B and O
- bkp = horisontal position of cursor
- hkp = vertical position of cursor
- dly = time delay in miliseconds between to animation screens
- name = input string
- other are temporary variables
- */
- #include
- #include
- #define r 5
- #include
- #include
- void main()
- {
- clrscr();
- int i,bkp=0,hkp=1,x,y,k=30,dly,cc,j,m=0;
- char name[12],p;
- //textbackground(BLACK);
- cprintf("Enter Your name(only small chars eg. hello): ");
- scanf("%s",name);
- cprintf("Enter color change speed(eg. 30) : ");
- scanf("%d",&dly);
- gotoxy(40,1);
- cprintf("\tBhargav Patel");
- _setcursortype(_NOCURSOR);
- bkp:
- bkp=0;
- hkp=1;
- clrscr();
- //klp:
- for(cc=0;cc<24;cc++)
- {
- for(j=0;j<72;j++)
- {
- if(cc%8<4)
- {
- if(j%16<8)
- {
- textcolor(m);
- }
- else
- {
- textcolor(m+1);
- }
- }
- else
- {
- if(j%16>=8)
- {
- textcolor(m);
- }
- else
- {
- textcolor(m+1);
- }
- }
- cprintf("%c",219);
- }
- printf("\n");
- }
- m++;
- delay(500);
- //goto klp;
- for(i=0;name[i]!='\0';i++)
- {
- textcolor(k-(i%9));
- //cprintf("%c",name[i]);
- switch(name[i])
- {
- case 'a':
- for(x=1;x<=8;x++)
- {
- y=x;
- delay(dly);
- gotoxy(bkp+(7+y),hkp+(x));
- cprintf("**");
- delay(dly);
- gotoxy(bkp+(9-x),hkp+(y));
- cprintf("**");
- }
- gotoxy(bkp+(6),hkp+(5));
- for(x=1;x<=7;x++)
- {
- delay(dly);
- cprintf("*");
- }
- bkp+=17;
- break;
- case 'b':
- for(x=1;x<=4;x++)
- {
- y=2*sqrt((r*r)-(x*x));
- gotoxy(bkp+(y-3),hkp+(3+x));
- delay(dly);
- cprintf("***");
- gotoxy(bkp+(y-3),hkp+(5-x));
- delay(dly);
- cprintf("***");
- gotoxy(bkp+(y-3),hkp+(9+x));
- delay(dly);cprintf("***");
- gotoxy(bkp+(y-3),hkp+(11-x));
- delay(dly);cprintf("***");
- }
- for(x=1;x<=13;x++)
- {
- gotoxy(bkp+(1),hkp+(x));
- delay(dly);cprintf("**");
- }
- bkp+=9;
- break;
- case 'c':
- for(x=1;x<=4;x++)
- {
- y=4*sqrt((r*r)-(x*x));
- gotoxy(bkp+(20-y),hkp+(4+x));
- delay(dly);cprintf("***");
- gotoxy(bkp+(20-y),hkp+(6-x));
- delay(dly);cprintf("***");
- }
- bkp+=11;
- break;
- case 'd':
- for(x=1;x<=5;x++)
- {
- y=4*sqrt((100)-(x*x));
- gotoxy(bkp+(y-31),hkp+(4+x));
- delay(dly);cprintf("***");
- gotoxy(bkp+(y-31),hkp+(6-x));
- delay(dly);cprintf("***");
- }
- for(x=1;x<=9;x++)
- {
- gotoxy(bkp+(1),hkp+(x));
- delay(dly);cprintf("**");
- }
- bkp+=11;
- break;
- case 'e':
- for(x=1;x<=10;x++)
- {
- gotoxy(bkp+1,hkp+x);
- delay(dly);cprintf("**");
- }
- for(x=3;x<=7;x++)
- {
- gotoxy(bkp+x,hkp+1);
- delay(dly);cprintf("*");
- gotoxy(bkp+x,hkp+2);
- delay(dly);cprintf("*");
- gotoxy(bkp+x,hkp+5);
- delay(dly);cprintf("*");
- gotoxy(bkp+x,hkp+6);
- delay(dly);cprintf("*");
- gotoxy(bkp+x,hkp+9);
- delay(dly);cprintf("*");
- gotoxy(bkp+x,hkp+10);
- delay(dly);cprintf("*");
- }
- bkp+=8;
- break;
- case 'f':
- for(x=1;x<=10;x++)
- {
- gotoxy(bkp+1,hkp+x);
- delay(dly);cprintf("**");
- }
- for(x=3;x<=7;x++)
- {
- gotoxy(bkp+x,hkp+1);
- delay(dly);cprintf("*");
- gotoxy(bkp+x,hkp+2);
- delay(dly);cprintf("*");
- gotoxy(bkp+x,hkp+5);
- delay(dly);cprintf("*");
- gotoxy(bkp+x,hkp+6);
- delay(dly);cprintf("*");
- }
- bkp+=8;
- break;
- case 'g':
- for(x=1;x<=5;x++)
- {
- y=3*sqrt((100)-(x*x));
- gotoxy(bkp+(30-y),hkp+(4+x));
- delay(dly);cprintf("***");
- gotoxy(bkp+(30-y),hkp+(6-x));
- delay(dly);cprintf("***");
- gotoxy(bkp+(y-19),hkp+(4+x));
- delay(dly);cprintf("***");
- }
- gotoxy(bkp+7,hkp+5);
- for(x=1;x<=7;x++)
- {
- delay(dly);cprintf("*");
- }
- bkp+=13;
- break;
- case 'h':
- for(x=1;x<=10;x++)
- {
- gotoxy(bkp+1,hkp+x);
- delay(dly);cprintf("**");
- gotoxy(bkp+7,hkp+x);
- delay(dly);cprintf("**");
- }
- for(x=3;x<=7;x++)
- {
- gotoxy(bkp+x,hkp+5);
- delay(dly);cprintf("*");
- gotoxy(bkp+x,hkp+6);
- delay(dly);cprintf("*");
- }
- bkp+=9;
- break;
- case 'i':
- for(x=1;x<=10;x++)
- {
- gotoxy(bkp+4,hkp+x);
- delay(dly);cprintf("**");
- }
- for(x=1;x<=8;x++)
- {
- gotoxy(bkp+x,hkp+1);
- delay(dly);cprintf("*");
- gotoxy(bkp+x,hkp+2);
- delay(dly);cprintf("*");
- gotoxy(bkp+x,hkp+9);
- delay(dly);cprintf("*");
- gotoxy(bkp+x,hkp+10);
- delay(dly);cprintf("*");
- }
- bkp+=9;
- break;
- case 'j':
- for(x=1;x<=5;x++)
- {
- y=3*sqrt((100)-(x*x));
- gotoxy(bkp+(30-y),hkp+(6+x));
- delay(dly);cprintf("**");
- //gotoxy(bkp+(30-y),hkp+(6-x));
- //delay(dly);cprintf("***");
- gotoxy(bkp+(y-21),hkp+(6+x));
- delay(dly);cprintf("**");
- }
- for(x=1;x<=7;x++)
- {
- gotoxy(bkp+8,hkp+x);
- delay(dly);cprintf("**");
- }
- for(x=3;x<=13;x++)
- {
- gotoxy(bkp+x,hkp+1);
- delay(dly);cprintf("*");
- gotoxy(bkp+x,hkp+2);
- delay(dly);cprintf("*");
- }
- bkp+=14;
- break;
- case 'k':
- for(x=1;x<=10;x++)
- {
- gotoxy(bkp+1,hkp+x);
- delay(dly);cprintf("**");
- }
- for(x=1;x<=6;x++)
- {
- y=x;
- gotoxy(bkp+(y),hkp+(x+4));
- delay(dly);cprintf("**");
- gotoxy(bkp+(8-x),hkp+(y));
- delay(dly);cprintf("**");
- }
- bkp+=9;
- break;
- case 'l':
- for(x=1;x<=10;x++)
- {
- gotoxy(bkp+1,hkp+x);
- delay(dly);cprintf("**");
- }
- for(x=3;x<=7;x++)
- {
- gotoxy(bkp+x,hkp+9);
- delay(dly);cprintf("*");
- gotoxy(bkp+x,hkp+10);
- delay(dly);cprintf("*");
- }
- bkp+=8;
- break;
- case 'm':
- for(x=1;x<=10;x++)
- {
- gotoxy(bkp+1,hkp+x);
- delay(dly);cprintf("**");
- gotoxy(bkp+11,hkp+x);
- delay(dly);cprintf("**");
- }
- for(x=1;x<=6;x++)
- {
- y=x;
- gotoxy(bkp+(y),hkp+(x));
- delay(dly);cprintf("**");
- gotoxy(bkp+(12-x),hkp+(y));
- delay(dly);cprintf("**");
- }
- bkp+=13;
- break;
- case 'n':
- for(x=1;x<=10;x++)
- {
- gotoxy(bkp+1,hkp+x);
- delay(dly);cprintf("**");
- gotoxy(bkp+10,hkp+x);
- delay(dly);cprintf("**");
- }
- for(x=1;x<=10;x++)
- {
- y=x;
- gotoxy(bkp+(y),hkp+(x));
- delay(dly);cprintf("**");
- }
- bkp+=13;
- break;
- case 'o':
- for(x=1;x<=5;x++)
- {
- y=2*sqrt((100)-(x*x));
- gotoxy(bkp+(20-y),hkp+(4+x));
- delay(dly);cprintf("***");
- gotoxy(bkp+(20-y),hkp+(6-x));
- delay(dly);cprintf("***");
- gotoxy(bkp+(y-11),hkp+(4+x));
- delay(dly);cprintf("***");
- gotoxy(bkp+(y-11),hkp+(6-x));
- delay(dly);cprintf("***");
- }
- bkp+=10;
- break;
- case 'p':
- for(x=1;x<=4;x++)
- {
- y=2*sqrt((r*r)-(x*x));
- gotoxy(bkp+(y-3),hkp+(3+x));
- delay(dly);cprintf("***");
- gotoxy(bkp+(y-3),hkp+(5-x));
- delay(dly);cprintf("***");
- }
- for(x=1;x<=11;x++)
- {
- gotoxy(bkp+(1),hkp+(x));
- delay(dly);cprintf("**");
- }
- bkp+=8;
- break;
- case 'q':
- for(x=1;x<=5;x++)
- {
- y=2*sqrt((100)-(x*x));
- gotoxy(bkp+(20-y),hkp+(4+x));
- delay(dly);cprintf("***");
- gotoxy(bkp+(20-y),hkp+(6-x));
- delay(dly);cprintf("***");
- gotoxy(bkp+(y-11),hkp+(4+x));
- delay(dly);cprintf("***");
- gotoxy(bkp+(y-11),hkp+(6-x));
- delay(dly);cprintf("***");
- }
- for(x=1;x<=5;x++)
- {
- y=x;
- gotoxy(bkp+(y+4),hkp+(x+5));
- delay(dly);cprintf("**");
- }
- bkp+=11;
- break;
- case 'r':
- for(x=1;x<=4;x++)
- {
- y=2*sqrt((r*r)-(x*x));
- gotoxy(bkp+(y-3),hkp+(3+x));
- delay(dly);cprintf("***");
- gotoxy(bkp+(y-3),hkp+(5-x));
- delay(dly);cprintf("***");
- }
- for(x=1;x<=11;x++)
- {
- gotoxy(bkp+(1),hkp+(x));
- delay(dly);cprintf("**");
- }
- for(x=1;x<=5;x++)
- {
- y=x;
- gotoxy(bkp+(y+3),hkp+(x+6));
- delay(dly);cprintf("**");
- }
- bkp+=9;
- break;
- case 's':
- for(x=1;x<=4;x++)
- {
- y=3*sqrt((r*r)-(x*x));
- gotoxy(bkp+(y-7),hkp+(x+9));
- delay(dly);cprintf("**");
- gotoxy(bkp+(y-7),hkp+(10-x));
- delay(dly);cprintf("**");
- gotoxy(bkp+(15-y),hkp+(x+4));
- delay(dly);cprintf("**");
- gotoxy(bkp+(15-y),hkp+(5-x));
- delay(dly);cprintf("**");
- }
- bkp+=9;
- break;
- case 't':
- for(x=1;x<=10;x++)
- {
- gotoxy(bkp+4,hkp+x);
- delay(dly);cprintf("**");
- }
- for(x=1;x<=8;x++)
- {
- gotoxy(bkp+x,hkp+1);
- delay(dly);cprintf("*");
- gotoxy(bkp+x,hkp+2);
- delay(dly);cprintf("*");
- }
- bkp+=9;
- break;
- case 'u':
- for(x=1;x<=5;x++)
- {
- y=3*sqrt((100)-(x*x));
- gotoxy(bkp+(30-y),hkp+(5+x));
- delay(dly);cprintf("**");
- //gotoxy(bkp+(30-y),hkp+(6-x));
- //delay(dly);cprintf("***");
- gotoxy(bkp+(y-20),hkp+(5+x));
- delay(dly);cprintf("**");
- }
- for(x=1;x<=5;x++)
- {
- gotoxy(bkp+1,hkp+x);
- delay(dly);cprintf("**");
- gotoxy(bkp+9,hkp+x);
- delay(dly);cprintf("**");
- }
- bkp+=11;
- break;
- case 'v':
- for(x=1;x<=3;x++)
- {
- gotoxy(bkp+1,hkp+x);
- delay(dly);cprintf("**");
- gotoxy(bkp+10,hkp+x);
- delay(dly);cprintf("**");
- }
- for(x=1;x<=4;x++)
- {
- y=x;
- gotoxy(bkp+(y+1),hkp+(x+3));
- delay(dly);cprintf("**");
- gotoxy(bkp+(10-x),hkp+(y+3));
- delay(dly);cprintf("**");
- }
- bkp+=12;
- break;
- case 'w':
- for(x=1;x<=3;x++)
- {
- gotoxy(bkp+1,hkp+x);
- delay(dly);cprintf("**");
- gotoxy(bkp+15,hkp+x);
- delay(dly);cprintf("**");
- }
- for(x=1;x<=4;x++)
- {
- y=x;
- gotoxy(bkp+(y),hkp+(x+2));
- delay(dly);cprintf("**");
- gotoxy(bkp+(9-x),hkp+(y+2));
- delay(dly);cprintf("**");
- }
- for(x=1;x<=4;x++)
- {
- y=x;
- gotoxy(bkp+(y+6),hkp+(x+2));
- delay(dly);cprintf("**");
- gotoxy(bkp+(16-x),hkp+(y+2));
- delay(dly);cprintf("**");
- }
- bkp+=17;
- break;
- case 'x':
- for(x=1;x<=8;x++)
- {
- y=x;
- gotoxy(bkp+(y),hkp+(x));
- delay(dly);cprintf("**");
- gotoxy(bkp+(9-x),hkp+(y));
- delay(dly);cprintf("**");
- }
- bkp+=10;
- break;
- case 'y':
- for(x=1;x<=4;x++)
- {
- y=x;
- gotoxy(bkp+(y),hkp+(x));
- delay(dly);cprintf("**");
- gotoxy(bkp+(8-x),hkp+(y));
- delay(dly);cprintf("**");
- }
- for(x=3;x<=6;x++)
- {
- gotoxy(bkp+4,hkp+x);
- delay(dly);cprintf("**");
- }
- bkp+=8;
- break;
- case 'z':
- for(x=1;x<=8;x++)
- {
- y=x;
- gotoxy(bkp+(9-x),hkp+(y));
- delay(dly);cprintf("**");
- }
- for(x=1;x<=8;x++)
- {
- gotoxy(bkp+x,hkp+1);
- delay(dly);cprintf("*");
- gotoxy(bkp+x,hkp+2);
- delay(dly);cprintf("*");
- gotoxy(bkp+(x),hkp+8);
- delay(dly);cprintf("*");
- gotoxy(bkp+(x),hkp+9);
- delay(dly);cprintf("*");
- }
- bkp+=10;
- break;
- default:
- delay(dly);cprintf("Error in Input Or String is large to fit in Screen. Try Again");
- break;
- }
- bkp++;
- if(bkp>=70)
- {
- bkp=0;
- hkp+=11;
- }
- }
- k++;
- delay(1500);
- goto bkp;
- }
No comments:
Post a Comment