Write text in different-different font,color and size



Here we are going to create a code for displaying the text in different-different font,size and colors by using C graphics programming.We are using settextstyle and setcolor function of c-graphics for this.It is a very important concept of c-graphics programming.So go through the following code for do so:

#include<stdio.h>

#include<conio.h>

#include<graphics.h>

void main()

{

int gd=DETECT,gm;

initgraph(&gd,&gm,"");

setcolor(RED);

settextstyle(0,HORIZ_DIR,2);

outtextxy(150,50,"EITWORLD.COM");

delay(500);

cleardevice();

setcolor(CYAN);

settextstyle(1,HORIZ_DIR,5);

outtextxy(150,100,"EITWORLD.COM");

delay(500);

cleardevice();

setcolor(GREEN);

settextstyle(2,HORIZ_DIR,20);

outtextxy(150,150,"EITWORLD.COM");

delay(500);

cleardevice();

setcolor(YELLOW);

settextstyle(3,HORIZ_DIR,5);

outtextxy(150,200,"EITWORLD.COM");

delay(500);

cleardevice();

setcolor(LIGHTCYAN);

settextstyle(4,HORIZ_DIR,5);

outtextxy(150,250,"EITWORLD.COM");

delay(500);

cleardevice();

setcolor(BLUE);

settextstyle(5,HORIZ_DIR,50);

outtextxy(150,320,"EITWORLD.COM");

delay(500);

cleardevice();

setcolor(LIGHTGREEN);

settextstyle(6,HORIZ_DIR,50);

outtextxy(150,360,"EITWORLD.COM");

delay(500);

cleardevice();

setcolor(LIGHTBLUE);

settextstyle(7,HORIZ_DIR,50);

outtextxy(150,400,"EITWORLD.COM");

delay(500);

cleardevice();

setcolor(RED);

settextstyle(0,HORIZ_DIR,2);

outtextxy(150,50,"EITWORLD.COM");

setcolor(CYAN);

settextstyle(1,HORIZ_DIR,5);

outtextxy(150,100,"EITWORLD.COM");

setcolor(GREEN);

settextstyle(2,HORIZ_DIR,20);

outtextxy(150,150,"EITWORLD.COM");

setcolor(YELLOW);

settextstyle(3,HORIZ_DIR,5);

outtextxy(150,200,"EITWORLD.COM");

setcolor(LIGHTCYAN);

settextstyle(4,HORIZ_DIR,5);

outtextxy(150,250,"EITWORLD.COM");

setcolor(BLUE);

settextstyle(5,HORIZ_DIR,50);

outtextxy(150,320,"EITWORLD.COM");

setcolor(LIGHTGREEN);

settextstyle(6,HORIZ_DIR,50);

outtextxy(150,360,"EITWORLD.COM");

setcolor(LIGHTBLUE);

settextstyle(7,HORIZ_DIR,50);

outtextxy(150,400,"EITWORLD.COM");

getch();

closegraph();

}



The above code display the text of different-different font,size and color.In the above code we used the settextstyle method in order to set the font,size and direction of text.setcolor method is setting the color of the text in the above code.outtextxy function is used for displaying the text at a specified location. settextstyle,setcolor and outtextxy methods are explained in detail in our tutorial graphics in C.delay() function is used to put the program in sleep mode for a while.Here you can see the output of the above program:



Output

c_graphics