Thursday, August 16, 2012
Text Animation Program Using C Programming
#include<stdio.h>
#include<math.h>
#include<conio.h>
#include<graphics.h>
#define round(val) (int)(val+0.5)
void main()
{ int gd=DETECT,gm,sx,sy,tx,ty;
char text[50];
void move(int,int,int,int,char[]);
printf("Enter the text:");
scanf("%s",text);
printf("Enter the initial points:");
scanf("%d%d",&sx,&sy);
printf("Enter the TARGET points:");
scanf("%d%d",&tx,&ty);
initgraph(&gd,&gm,"");
outtextxy(sx,sy,text);
move(sx,sy,tx,ty,text);
getch();
closegraph();
}
void move(int sx,int sy,int tx,int ty,char text[50])
{
int dx=tx-sx,dy=ty-sy,steps,k;
float xin,yin,x=sx,y=sy;
getch();
if(abs(dx)>abs(dy))
steps=abs(dy);
else
steps=abs(dy);
xin=dx/(float)steps;
yin=dy/(float)steps;
for(k=0;k<steps;k++)
{
cleardevice();
x+=xin;
y+=yin;
setcolor(15);
outtextxy(round(x),round(y),text);
delay(50);
}
}
Related Posts : C,
cg lab,
Computer Graphics programs,
programming
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment