#include "graphics.h"
#include "stdlib.h"
#include "stdio.h"
#include "malloc.h"
#include "dos.h"
#include "conio.h"
int xasp,yasp,gdriver = VGA, gmode=VGAMED, errorcode;
struct pos
{
int x;
int y;
};
struct face
{
int radius;
struct pos position;
int mood;
};
typedef struct face face;
face *face1;
void getposition()
{
printf("Enter X Co-ordinate:");
scanf("%d",&face1->position.x);
printf("Enter X Co-ordinate:");
scanf("%d",&face1->position.y);
}
void drawface()
{
char ch='x';
int i=0,x,y,color,r,imgsize,dif;
x=face1->position.x=320;
y=face1->position.y=180;
face1->radius=150;
color=15;
r=face1->radius;
setbkcolor(0);
getaspectratio(&xasp,&yasp);
setcolor(8);
circle(x,y,face1->radius);
setfillstyle(1,color);
floodfill(x,y,getcolor());
draweyes(face1);
drawhair(face1);
drawmouth(face1);
drawnose(face1);
}
drawnose()
{
int i,x,y,r;
x=face1->position.x;
y=face1->position.y;
r=face1->radius;
setcolor(0);
for(i=0;i<2;i++) r="face1-">radius;
x1=face1->position.x-r/2;
y1=face1->position.y-r/4;
x2=face1->position.x+r/2;
y2=face1->position.y-r/4;
setaspectratio(xasp/2,yasp);
arc(x1,y1-r/8,40,140,r/4);//left eyebrow
arc(x1,y1-r/8+1,40,140,r/4);//left eyebrow
arc(x1,y1-r/8+2,40,140,r/4);//left eyebrow
setaspectratio(xasp,yasp);
for(i=0;i<2;i++) i="0;i<2;i++)" x="face1-">position.x;
y=face1->position.y+(face1->radius/1.5);
r=face1->radius;
setcolor(BLACK);
if((face1->mood)==1)
for(i=0;i<4;i++)>mood)==0)
for(i=0;i<4;i++) r="face1-">radius;
x=face1->position.x-r/2;
y=face1->position.y-r/3;
arc(x,y,34,225,100);
arc(x+r,y,314,138,100);
setfillstyle(1,RED);
floodfill(x,y-70,getcolor());
floodfill(x+r,y-70,getcolor());
setaspectratio(xasp,yasp);
}
void main(void)
{
int i=0;
initgraph(&gdriver, &gmode,"");
while(!kbhit())
{
if((i%2)==1)
{
setvisualpage(1);
setactivepage(0);
clearviewport();
face1->mood=0;
drawface();
delay(1000);
}
else
{
setvisualpage(0);
setactivepage(1);
clearviewport();
face1->mood=1;
drawface();
delay(300);
}
i++;
}
getch();
closegraph();
}
#include "stdlib.h"
#include "stdio.h"
#include "malloc.h"
#include "dos.h"
#include "conio.h"
int xasp,yasp,gdriver = VGA, gmode=VGAMED, errorcode;
struct pos
{
int x;
int y;
};
struct face
{
int radius;
struct pos position;
int mood;
};
typedef struct face face;
face *face1;
void getposition()
{
printf("Enter X Co-ordinate:");
scanf("%d",&face1->position.x);
printf("Enter X Co-ordinate:");
scanf("%d",&face1->position.y);
}
void drawface()
{
char ch='x';
int i=0,x,y,color,r,imgsize,dif;
x=face1->position.x=320;
y=face1->position.y=180;
face1->radius=150;
color=15;
r=face1->radius;
setbkcolor(0);
getaspectratio(&xasp,&yasp);
setcolor(8);
circle(x,y,face1->radius);
setfillstyle(1,color);
floodfill(x,y,getcolor());
draweyes(face1);
drawhair(face1);
drawmouth(face1);
drawnose(face1);
}
drawnose()
{
int i,x,y,r;
x=face1->position.x;
y=face1->position.y;
r=face1->radius;
setcolor(0);
for(i=0;i<2;i++) r="face1-">radius;
x1=face1->position.x-r/2;
y1=face1->position.y-r/4;
x2=face1->position.x+r/2;
y2=face1->position.y-r/4;
setaspectratio(xasp/2,yasp);
arc(x1,y1-r/8,40,140,r/4);//left eyebrow
arc(x1,y1-r/8+1,40,140,r/4);//left eyebrow
arc(x1,y1-r/8+2,40,140,r/4);//left eyebrow
setaspectratio(xasp,yasp);
for(i=0;i<2;i++) i="0;i<2;i++)" x="face1-">position.x;
y=face1->position.y+(face1->radius/1.5);
r=face1->radius;
setcolor(BLACK);
if((face1->mood)==1)
for(i=0;i<4;i++)>mood)==0)
for(i=0;i<4;i++) r="face1-">radius;
x=face1->position.x-r/2;
y=face1->position.y-r/3;
arc(x,y,34,225,100);
arc(x+r,y,314,138,100);
setfillstyle(1,RED);
floodfill(x,y-70,getcolor());
floodfill(x+r,y-70,getcolor());
setaspectratio(xasp,yasp);
}
void main(void)
{
int i=0;
initgraph(&gdriver, &gmode,"");
while(!kbhit())
{
if((i%2)==1)
{
setvisualpage(1);
setactivepage(0);
clearviewport();
face1->mood=0;
drawface();
delay(1000);
}
else
{
setvisualpage(0);
setactivepage(1);
clearviewport();
face1->mood=1;
drawface();
delay(300);
}
i++;
}
getch();
closegraph();
}
No comments:
Post a Comment