Below is the program to draw smily face animation icon on random position of screen.
Below is the definition for list of functions used in.
- setcolor(RED) or setcolor(4) :- void setcolor(int color): , Set the current drawing color to RED
- circle(x,y) :- Circle function is used to draw a circle with center (x,y)
- setfillstyle() :- setfillstyle( int pattern, int color); set the current fill pattern and fill color
- floodfill() :- void floodfill(int x, int y, int border); , used to fill an enclosed area
- fillellipse() :- void fillellipse(int x, int y, int xradius, int yradius);
- ellipse() :- void ellipse(int x, int y, int stangle, int endangle, int xradius, int yradius);
- imagesize() :- Declaration:- unsigned int imagesize(int left, int top, int right, int bottom);
- settextstyle() :- Declaration :- void settextstyle( int font, int direction, int charsize);
- outtextxy() :- Declaration :- void outtextxy(int x, int y, char *string);
- rectangle() :- Declaration :- void rectangle(int left, int top, int right, int bottom);
- getimage() :- Declaration:- void getimage(int left, int top, int right, int bottom, void *bitmap);
- putimage() :- Declaration:- void putimage(int left, int top, void *ptr, int op);
- delay() :- Declaration :- void delay(unsigned int);
Below is the definition for list of functions used in.
- setcolor(RED) or setcolor(4) :- void setcolor(int color): , Set the current drawing color to RED
- circle(x,y) :- Circle function is used to draw a circle with center (x,y)
- setfillstyle() :- setfillstyle( int pattern, int color); set the current fill pattern and fill color
- floodfill() :- void floodfill(int x, int y, int border); , used to fill an enclosed area
- fillellipse() :- void fillellipse(int x, int y, int xradius, int yradius);
- ellipse() :- void ellipse(int x, int y, int stangle, int endangle, int xradius, int yradius);
- imagesize() :- Declaration:- unsigned int imagesize(int left, int top, int right, int bottom);
- settextstyle() :- Declaration :- void settextstyle( int font, int direction, int charsize);
- outtextxy() :- Declaration :- void outtextxy(int x, int y, char *string);
- rectangle() :- Declaration :- void rectangle(int left, int top, int right, int bottom);
- getimage() :- Declaration:- void getimage(int left, int top, int right, int bottom, void *bitmap);
- putimage() :- Declaration:- void putimage(int left, int top, void *ptr, int op);
- delay() :- Declaration :- void delay(unsigned int);
#include<graphics.h>
#include<conio.h>
#include<stdlib.h>
main()
{
int gd = DETECT, gm, area, temp1, temp2, left = 30, top = 80;
void *p;
initgraph(&gd,&gm,"C:\\TC\\BGI");
setcolor(RED);
circle(50,100,25);
setfillstyle(SOLID_FILL,RED);
floodfill(50,100,RED);
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 Icon 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(99);
left = temp1;
top = temp2;
}
getch();
closegraph();
return 0;
}
#include<conio.h>
#include<stdlib.h>
main()
{
int gd = DETECT, gm, area, temp1, temp2, left = 30, top = 80;
void *p;
initgraph(&gd,&gm,"C:\\TC\\BGI");
setcolor(RED);
circle(50,100,25);
setfillstyle(SOLID_FILL,RED);
floodfill(50,100,RED);
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 Icon 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(99);
left = temp1;
top = temp2;
}
getch();
closegraph();
return 0;
}
0 Comments