Posts

Showing posts from November, 2013

Smiley Face : Using C/C++ and Graphics

Image
Hey guys, today I am going to post very simple  yet beautiful program. This program generates smiley face at random position with different colors. If you guys like only particular color then eliminate the code to change color in while loop. And also if you like to see bigger or smaller smiley face then change the radius value. Here is the screen output of the code. Here's the code, enjoy coding... /*       Programmer : Ashok Kumar Shrestha (ak007)      Program details : Smiley face using C/C++ and graphics */ #include<graphics.h> #include<conio.h> #include<stdlib.h> #include<dos.h> main() {    int gd = DETECT, gm;    int x,y,color=14,radius=30,count=0;    initgraph(&gd,&gm,"C:\\TC\\BGI");    while(!kbhit())    {    x=rand()%600+20;    y=rand()%600+20;    setfillstyle(1,color);    fillellipse(x,y,radius,radius);    setfillstyle(1,0);    fillellipse(x-radius/2.5,y-radius/2.5,radius/8,radius/4);    fillellipse(x+radius/2.5,y-radi

Piano : Using C/C++ and Graphics

Image
Hey guys, today I am going to post one awesome program which I have been working for a quiet long time. It's not complete yet though, I will try to complete it soon. It's mini piano which we can play using keyboard. Press the keys as shown in the keyboard layout in the out put screen to play piano. If you want to exit, press Esc key. Here's the screenshot of the output. Here's the code: Note: Please save the file in .cpp extension if it is showing error. Make sure your speaker works properly because this program generates different sound according to key pressed. /*     Programmer: Ashok Kumar Shrestha (ak007)     Program Description: mini piano v 1.0 */ #include<stdio.h> #include<conio.h> #include<dos.h> #include<graphics.h> #include<process.h> getkey() {     union REGS i,o;     while(!kbhit());     i.h.ah=0;     int86(22,&i,&o);     return (o.h.ah); } void welcome() {     clrscr();     gotoxy(30,

Architectural pattern: Using C/C++ and graphics

Image
Hey guys its very simple but beautiful architectural pattern using C/C++ with graphics.  I don't know its name, if you guys know then please leave a comment below. Here's the screen shot of the output. Now, let us see the codes. Here by changing the value of the n we can create different pattern. For this program I have choosen value as 15 but do try with other values also. Here's the code. /*     Programmer: Ashok Kumar Shrestha (ak007)     Program Details: Generates Awesome Circular pattern 3.1 */ #include<graphics.h> #include<conio.h> #include<dos.h> #include<stdio.h> main() {    int gd = DETECT, gm, x, y, color, angle = 0,i,j;        char sstr[20];    int pat[2][200]={0};    int n=15;    struct arccoordstype a, b;    initgraph(&gd, &gm, "..\\BGI");    delay(200); for(i=0;i<n;i++)    {     setcolor(11);     arc(getmaxx()/2,getmaxy()/2,i*360/n,(i+1)*360/n,225);     getarccoords(&a);     pat[0][i]=a.xstart;     p

Loading..: Using C and graphics

Image
Hey guys, today I am posting a simple program which illustrate loading any videos or files. You might have seen this in while watching videos online. Well, here's the screen shot of the output. Let us see the codes now, hope you guys like it.. /*     Programmer: Ashok Kumar Shrestha (ak007)     Program Details: Generates Circular pattern2.1  for loading */ #include<graphics.h> #include<conio.h> #include<dos.h> main() {    int gd = DETECT, gm, x, y, color, angle = 0;    struct arccoordstype a, b;    initgraph(&gd, &gm, "..\\BGI");    delay(200);    setcolor(11);    settextstyle(1,0,4);    outtextxy(260,380,"Loading...");    while(!kbhit())    {       setcolor(BLACK);       arc(getmaxx()/2,getmaxy()/2,angle,angle+2,100);       setcolor(8);       getarccoords(&a);       setfillstyle(SOLID_FILL,8);       circle(a.xstart,a.ystart,15);       floodfill(a.xstart,a.ystart,8);       setcolor(BLACK);       arc(getmaxx()/2,getmaxy()/2,(

Circular Pattern2: Using C and graphics

Image
Hey guys, today I am going to post very simple yet beautiful graphics program written in c. This program is derived from previous program that I have posted to draw circular pattern, you can say its the alternate form. Here's the screen shot of the output. This pattern revolves in 360 degree, which is similar to buffering circle you may find in youtube or other video streamer. In next post I will be writting how to design simple graphics program for buffering circle. Without further delay let us see the program.. /*     Programmer: Ashok Kumar Shrestha (ak007)     Program Details: Generates Circular pattern2 */ #include<graphics.h> #include<conio.h> #include<dos.h> main() {    int gd = DETECT, gm, x, y, color, angle = 0;    struct arccoordstype a, b;    initgraph(&gd, &gm, "..\\BGI");    delay(200);    while(!kbhit())    {       setcolor(BLACK);       arc(getmaxx()/2,getmaxy()/2,angle,angle+2,100);       setcolor(RED);       getarccoord

Concurrent circular patterns: Using C and graphics

Image
Hey guys its very easy and small program to generate concurrent circular patterns. Here's the screen shot of the out put. Let us see the code, hope you guys like it.. /*     Programmer: Ashok Kumar Shrestha (ak007)     Program details: Generates concurrent circles by using circles. */ #include<graphics.h> #include<conio.h> #include<dos.h> main() {    int gd = DETECT, gm, x, y, color, angle = 0;    struct arccoordstype a, b;    initgraph(&gd, &gm, "..\\BGI");    delay(200);    while(angle<=360)    {       setcolor(BLACK);       arc(getmaxx()/2,getmaxy()/2,angle,angle+2,100);       setcolor(4);       getarccoords(&a);       circle(a.xstart,a.ystart,25);       setcolor(BLACK);       arc(getmaxx()/2,getmaxy()/2,angle,angle+2,150);       getarccoords(&a);       setcolor(2);       circle(a.xstart,a.ystart,25);       setcolor(BLACK);       arc(getmaxx()/2,getmaxy()/2,angle,angle+2,200);       getarccoords(&a);       setcolor(3);