Computer graphics program in c

Hello Student here we learn about, Graphics program Following Graphics Program with all Function. I hope you will learn here something New. How to Make a computer graphics program in c.

How to Make Number Pattern Program in C

 

Graphics program in c

# include<stdio.h>
# include<conio.h>
# include<graphics.h>
# include<dos.h>

    void main()
{
    int gd=DETECT,gm;
    int r,i;
 
  printf("\n ENTER RADIUS OF CIRCLE:-");

  scanf("%d",&r);

clrscr();

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

    for(i=1;r>0;r=r-10,i++)
{
    circle(getmaxx()/2,getmaxy()/2,r);

  setcolor(i);
  delay(1000);
}
  closegraph();

getch();

}


2d transformation in computer graphics program in c Output

computer graphics program in c
Here you will input your Radius.

 

 

computer graphics program in c
Result Press any key to continue 😍

Note:- Enter large Radius for Full Preview.

Graphics Function in C

Graphics functions in c with syntax

<stdio.h> :-file ‘stdio.h’ stands for Standard input-output, it is to be included at the beginning of the every C Program.

<conio.h> :- This header file ‘conio.h’ stands for Console input-output, it uses somewhere in the program when the program doesn’t give proper output. it is also return type which work with function ‘getch();’ .

<graphics.h> :-In the above program a ‘graphics.h’ the header file is included. This header file contains all prototype and the definition of all graphics functions. Before starting any Drawing action we need to initialize graphics mode.

 <dos.h>:- This DOS Disc Operating system, it is also a header file in C program for DOS type screen.

initgraph(); :- This function initialize the graphics system. Prototype is defined in ‘graphics.h’. It is declared as per given below.

 “void far initgraph (int far *gd , int far *gm, char far *path to driver);

gd (Graphics Driver)

gm (Graph Mode)” 

 

Circle(); :- This function Draw a circle at (x,y) of the given radius. This function is declared as under.void far circle(int x, int y, int radius); ‘or’circle(getmaxx, getmaxy, radius); .

getmaxx(); :- This function return maximum X coordinate on the screen. Its Prototype is defined in ‘graphics.h’ . And declared as under.int far getmaxx (void);

getmaxy(); :- This function return maximum Y coordinate on the screen. Its Prototype is defined in ‘graphics.h’ . And declared as under.int far getmaxy (void);

setcolor(); :- This function sets the current drawing color . This is declared as under.void for set color (int color);

closegraph(); :-This function shuts down the graphics system. The declaration is as under. Prototype is defined in ‘graphics.h’.void far closegraph(void); ‘or’ closegraph();

This was some important function of Any Graphics program. I hope you already know about other functions used in this program. Like

scanf(); :- It is used for taking input in C.

printf(); :- This function is use for print the output on screen.

getch(); :- This function work with Header file <conio.h>. It’s also an important function while your program doesn’t display proper output on Screen.

clrscr(); :- Clrscr stands for clear screen. After running any program, if you will show a rough Page with your Output. Then you can use this function to clear your Previous rough screen.

etc.

Note:- If you want to Increase ‘or’ Decrease space of Circle line then you can simply change here in For Loop:-
for(i=1;r>0;r=r-10,i++) //for less space r-5

Read the Story….

I hope you will learn here computer graphics program in c. ???

Give your valuable feedback for How to Make Graphics Program in C.

Leave a Reply

x