Smiling face animation program in C

Computer graphics Smiling face Animation program in C with source code and explanation of Every C Function with suitable Programming Example learn step by step

Animation program in c with source code

//C smiling face animation

#include<graphics.h>

#include<conio.h>

#include<stdlib.h>

main()

{

   int gd = DETECT, gm, area, temp1, temp2, left = 25, top = 75;

   void *p;

   initgraph(&gd, &gm, “C:\\TC\\BGI“);

//This is face color

   setcolor(YELLOW);

   circle(50,100, 25);

   setfillstyle(SOLID_FILL,YELLOW);

   floodfill(50, 100, YELLOW);

//This color  for Eyes, and Mouth

   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);

//This is color of Font

   setcolor(WHITE);

//This is type of Text and Font Size is 2

   settextstyle(SANS_SERIF_FONT, HORIZ_DIR, 2);

//This is Message and Position of Message

   outtextxy(155, 451, “Smiling Face Animation“);

//This is Border Color

   setcolor(BLUE);

//This is Border size

   rectangle(0, 0, 639, 449);


while(
!kbhit())


{

//This is moving Ratio

      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);

//This is timer of Moving Face, Increse it for Slow Moving

      delay(200);

      left = temp1;

      top = temp2;


 }

   getch();

   closegraph();

   return 0;

}

Draw Smiling Face Animation

Smiling face Animation program in C
Smiling face Animation program in C
EXPLANATION

Computer graphics animation project in C

<stdio.h> :-file ‘stdio.h’ stands for Standard input-output, it is to be included at the beginning of the every C Program.

<conio.h> :- This header file ‘conio.h’ stands for Console input-output, it uses somewhere in the program when the program doesn’t give proper output. it is also return type which work with function ‘getch();’ .

<graphics.h> :-In the above program a ‘graphics.h’ the header file is included. This header file contains all prototype and the definition of all graphics functions. Before starting any Drawing action we need to initialize graphics mode.

 <dos.h>:- This DOS Disc Operating system, it is also a header file in C program for DOS type screen.

initgraph(); :- This function initialize the graphics system. Prototype is defined in ‘graphics.h’. It is declared as per given below.

 “void far initgraph (int far *gd , int far *gm, char far *path to driver);

gd (Graphics Driver)

gm (Graph Mode)” 

 

Circle(); :- This function Draw a circle at (x,y) of the given radius. This function is declared as under.void far circle(int x, int y, int radius); ‘or’circle(getmaxx, getmaxy, radius); .

getmaxx(); :- This function return maximum X coordinate on the screen. Its Prototype is defined in ‘graphics.h’ . And declared as under.int far getmaxx (void);

getmaxy(); :- This function return maximum Y coordinate on the screen. Its Prototype is defined in ‘graphics.h’ . And declared as under.int far getmaxy (void);

setcolor(); :- This function sets the current drawing color . This is declared as under.void for set color (int color);

closegraph(); :-This function shuts down the graphics system. The declaration is as under. Prototype is defined in ‘graphics.h’.void far closegraph(void); ‘or’ closegraph();

This was some important function of Any Graphics program. I hope you already know about other functions used in this program. Like

scanf(); :- It is used for taking input in C.

printf(); :- This function is use for print the output on screen.

getch(); :- This function work with Header file <conio.h>. It’s also an important function while your program doesn’t display proper output on Screen.

clrscr(); :- Clrscr stands for clear screen. After running any program, if you will show a rough Page with your Output. Then you can use this function to clear your Previous rough screen.

END

C program to draw a square using graphics (clickHere)

 

Note:- Maybe sometime above code doesn’t get user-friendly output, in codeblock ‘or’ any other EDITOR, All of C & C++ program tested in DOS compiler Turbo C.

Also Read

Types of functions in C    Read Here

I hope you will understand better if you study at M.U, in the exam of M.U you know how important this “Smiling face Animation program in C . So please don’t forget to give your valuable feedback. Go in the comment section and Give us some feedback about it. smiling face Animation program in C or My website.

Our team check your every Comment per day Because your one feedback helps us in growing Thesmolt

I request you if you have any doubt or question regarding our site, then please don’t hesitate. We always waiting for your Suggestion.

Note:- If you want to Download This article’s in PDF form, then simply go (Top or Bottom of) Right corner and click on the PRINT icon, and it’s saved as a PDF of  Smiling face Animation program in C

C smiling face animation

For further questions, you can contact us Via mail [email protected]  otherwise, Our Help Page and Contact us Page, which is included below. I hope I’ll able to say all the possible ways to reach us. Or Download My Android Application Below Download Button.

thesmolt App

 

 

Leave a Reply

x