Text Generation Program In Computer Graphics


 Character Generation Using Display File


text generation program in computer graphics,text generation program in c graphics,text generation program in computer graphics using display file,text generation program in c graphics using display file,text generation program,text primitives in c graphics,text primitives in computer graphics

#include<stdio.h>

#include<conio.h>

#include<math.h>

#include<graphics.h>

#include<string.h>

#define size 25


int gdriver=DETECT, gmode;

float df_penx, df_peny, ch, cw, char_sep, xcharsp, ycharsp, df_op[size], df_x[size], df_y[size];

float hs, he, h, we, ws, w, x, y, s, ds, dx, ts, dy;

int op, fre, erase_flag=0, x1, f_y, f_x, n;


void new_frame();

void putpoint(int op, float x, float y);

void display_file(int op);

void move_abs(float x, float y);

void getpoint(int n);

void interpret(int s, int count);

void make_pic();

void erase();

void initialize();

void char_up(int, int);

void char_up1(int, int);

void char_up2(int, int);

void char_up3(int, int);

void char_up4(int, int);

void char_up5(int, int);

void char_up6(int, int);

void char_up7(int, int);

void s1(int, int);

void hn(int, int);

void u(int, int);

void b(int, int);

void h2(int, int);

void a(int, int);

void nn(int, int);

void k(int, int);

void text();

void dochar();



void main()

{

clrscr();

initgraph(&gdriver, &gmode, "C:\\Turboc3\\bgi");

initialize();

new_frame();

char_up(1, 1);

move_abs(0.5, 0.5);

text();

make_pic();

initialize();

new_frame();

char_up1(1, 1);

move_abs(0.5, 0.5);

text();

make_pic();

initialize();

new_frame();

char_up2(1, 1);

move_abs(0.5, 0.5);

text();

make_pic();

initialize();

new_frame();

char_up3(1, 1);

move_abs(0.5, 0.5);

text();

make_pic();

initialize();

new_frame();

char_up4(0, 1);

move_abs(0.5, 0.5);

text();

make_pic();

initialize();

new_frame();

char_up5(1, 0);

move_abs(0.5, 0.5);

text();

make_pic();

initialize();

new_frame();

char_up6(-1, 0);

move_abs(0.5, 0.5);

text();

make_pic();

initialize();

new_frame();

char_up7(0, -1);

move_abs(0.5, 0.5);

text();

make_pic();

getch();

}


void initialize()

{

fre=0;

df_penx=0;

df_peny=0;

ch=0.06;

cw=0.06;

hs=0;

char_sep=0.0;

he=getmaxy();

h=he-hs;

ws=0;

we=getmaxy();

w=we-ws;

}


void move_abs(float x, float y)

{

df_penx=x;

df_peny=y;

display_file(1);

}


void display_file(int op)

{

putpoint(op, df_penx, df_peny);

}


void putpoint(int op, float x, float y)

{

if(fre>size)

printf("Display file full...");

else

{

df_op[fre]=op;

df_x[fre]=x;

df_y[fre]=y;

fre++;

}

}


void make_pic()

{

/*if(erase_flag==1)

{

erase();

erase_flag=0;

}*/

if(fre>1)

interpret(1, fre-1);

fre=0;

}


void interpret(int s, int count)

{

for(n=s;n<=count;n++)

{

getpoint(n);

if(op<<-31 && op>>-127)

dochar();

else

printf("Wrong OPCode...");

}

}


void dochar()

{

char c;

int ych, xch, i=0;

xch=x*we;

ych=y*he;

f_y=he-ych;

if(dx==0)

f_x=we-xch;

else

f_x=xch;

op=-op;

i++;

c=op;

switch(c)

{

case 'S' : s1(f_x, f_y); break;

case 'H' : hn(f_x, f_y); break;

case 'U' : u(f_x, f_y); break;

case 'B' : b(f_x, f_y); break;

case 'HH': h2(f_x, f_y); break;

case 'A' : a(f_x, f_y); break;

case 'N' : nn(f_x, f_y); break;

case 'K' : k(f_x, f_y); break;

}

}


void getpoint(int i)

{

op=df_op[i];

x=df_x[i];

y=df_y[i];

}


void new_frame()

{

erase_flag=1;

}


void erase()

{

int j;

for(n=1;n<we+1;n++)

for(j=1;j<he+1;j++)

putpixel(n, j, 0);

}


void char_up(int x, int y)

{

dx=x;

dy=y;

s=sqrt(pow(dx,2)+pow(dy,2));

ds=(float)(fabs(cw*(float)dy)+fabs(ch*(float)dx))/s;

ts=ds*(1+char_sep);

xcharsp=ts*(dy/s);

ycharsp=ts*(-dx/s);

}

void char_up1(int x, int y)

{

dx=x;

dy=y;

s=sqrt(pow(dx,2)+pow(dy,2));

ds=(float)(fabs(cw*(float)dy)+fabs(ch*(float)dx))/s;

ts=ds*(1+char_sep);

xcharsp=ts*(dy/s);

ycharsp=ts*(dx/s);

}

void char_up2(int x, int y)

{

dx=x;

dy=y;

s=sqrt(pow(dx,2)+pow(dy,2));

ds=(float)(fabs(cw*(float)dy)+fabs(ch*(float)dx))/s;

ts=ds*(1+char_sep);

xcharsp=ts*(-dy/s);

ycharsp=ts*(-dx/s);

}

void char_up3(int x, int y)

{

dx=x;

dy=y;

s=sqrt(pow(dx,2)+pow(dy,2));

ds=(float)(fabs(cw*(float)dy)+fabs(ch*(float)dx))/s;

ts=ds*(1+char_sep);

xcharsp=ts*(-dy/s);

ycharsp=ts*(dx/s);

}

void char_up4(int x, int y)

{

dx=x;

dy=y;

s=sqrt(pow(dx,2)+pow(dy,2));

ds=(float)(fabs(cw*(float)dy)+fabs(ch*(float)dx))/s;

ts=ds*(1+char_sep);

xcharsp=ts*(-dy/s);

ycharsp=ts*(dx/s);

}

void char_up5(int x, int y)

{

dx=x;

dy=y;

s=sqrt(pow(dx,2)+pow(dy,2));

ds=(float)(fabs(cw*(float)dy)+fabs(ch*(float)dx))/s;

ts=ds*(1+char_sep);

xcharsp=ts*(-dy/s);

ycharsp=ts*(dx/s);

}

void char_up6(int x, int y)

{

dx=x;

dy=y;

s=sqrt(pow(dx,2)+pow(dy,2));

ds=(float)(fabs(cw*(float)dy)+fabs(ch*(float)dx))/s;

ts=ds*(1+char_sep);

xcharsp=ts*(-dy/s);

ycharsp=ts*(dx/s);

}

void char_up7(int x, int y)

{

dx=x;

dy=y;

s=sqrt(pow(dx,2)+pow(dy,2));

ds=(float)(fabs(cw*(float)dy)+fabs(ch*(float)dx))/s;

ts=ds*(1+char_sep);

xcharsp=ts*(-dy/s);

ycharsp=ts*(dx/s);

}

void text()

{

int j, l;

char c;

char s[]={'S','H','U','B','HH','A','N','K'};

l=8;

x=df_penx;

y=df_peny;

for(j=0;j<l;j++)

{

c=s[j];

op=c;

op=-op;

display_file(op);

df_penx=df_penx+xcharsp;

df_peny=df_peny+ycharsp;

}

}


void s1(int f_x, int f_y)

{

int i,j,s2[20][20]={

       {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},

       {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},

       {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},

       };


int o=f_x;

for(i=0;i<20;i++)

{

for(j=0;j<20;j++)

{

if(s2[i][j]==1)

putpixel(f_x,f_y,2);

f_x++;

}

f_y++;

f_x=o;

}


}

void hn(int f_x,int f_y)

{

int i,j;

int hm[20][20]={

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       };

int o=f_x;

for(i=0;i<20;i++)

{

for(j=0;j<20;j++)

{

if(hm[i][j]==1)

putpixel(f_x,f_y,2);

f_x++;

}

f_y++;

f_x=o;

}

}

void u(int f_x,int f_y)

{

int i,j,u1[20][20]={

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},

       };

int o=f_x;

for(i=0;i<20;i++)

{

for(j=0;j<20;j++)

{

if(u1[i][j]==1)

putpixel(f_x,f_y,2);

f_x++;

}

f_y++;

f_x=o;

}


}

void b(int f_x,int f_y)

{

int i,j,b1[20][20]={

       {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},

       };

int o=f_x;

for(i=0;i<20;i++)

{

for(j=0;j<20;j++)

{

if(b1[i][j]==1)

putpixel(f_x,f_y,2);

f_x++;

}

f_y++;

f_x=o;

}


}

void h2(int f_x,int f_y)

{

int i,j,h3[20][20]={

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       };

int o=f_x;

for(i=0;i<20;i++)

{

for(j=0;j<20;j++)

{

if(h3[i][j]==1)

putpixel(f_x,f_y,2);

f_x++;

}

f_y++;

f_x=o;

}


}

void a(int f_x,int f_y)

{

int i,j,a1[20][20]={

       {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       };

int o=f_x;

for(i=0;i<20;i++)

{

for(j=0;j<20;j++)

{

if(a1[i][j]==1)

putpixel(f_x,f_y,2);

f_x++;

}

f_y++;

f_x=o;

}


}

void nn(int f_x,int f_y)

{

int i,j,nj[20][20]={

       {1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,1},

       {1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1},

       {1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1},

       {1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1},

       {1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1},

       {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1},

       };

int o=f_x;

for(i=0;i<20;i++)

{

for(j=0;j<20;j++)

{

if(nj[i][j]==1)

putpixel(f_x,f_y,2);

f_x++;

}

f_y++;

f_x=o;

}


}

void k(int f_x,int f_y)

{

int i,j,k1[20][20]={

       {1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0},

       {1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0},

       {1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0},

       {1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0},

       {1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0},

       {1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},

       {1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},

       {1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},

       {1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},

       {1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},

       {1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},

       {1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},

       {1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0},

       {1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0},

       {1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0},

       {1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0},

       {1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0},

       };

int o=f_x;

for(i=0;i<20;i++)

{

for(j=0;j<20;j++)

{

if(k1[i][j]==1)

putpixel(f_x,f_y,2);

f_x++;

}

f_y++;

f_x=o;

}


}

Java Program

Polygon Relative in C Graphics

Comment your views on this Article :)


Thank you for visiting my blog :)


No comments

Comment your views on this article

Powered by Blogger.