Posts

Showing posts from 2020

Circle and Line Function in Computer Graphics

Hello Guys, Circle Function:-  Declaration: void circle(int x, int y, int radius); Circle function is used to draw a circle with center (x,y) and third parameter specifies the radius of the circle. The code given below draws a circle. C program for circle #include<graphics.h> #include<conio.h> void main ( ) {     int  gd  =  DETECT ,  gm ;    initgraph ( & gd ,   & gm ,   "C: \\ TC \\ BGI" ) ;    circle ( 100 ,   100 ,   50 ) ;       getch ( ) ;    closegraph ( ) ;     return   0 ; } In the above program (100, 100) are coordinates of center of the circle and 50 is the radius of circle. Line Function:- Line function is used to draw a line from a point(x1,y1) to point(x2,y2) i.e. (x1,y1) and (x2,y2) are end points of the line.The code given below draws a line. Declaration: void line(int x1, int y1, int x2,...

Graphics Programming in C

Hey Guys, This blog is for all those who wish to learn C graphics programming, no knowledge of graphics concepts is required. C Graphics programming is very easy and interesting. You can use graphics programming for developing your games, in making projects, for animation etc. It's not like traditional C programming in which you have to apply complex logic in your program and then you end up with a lot of errors and warnings in your program. To make things easy you are provided with executable files which you can download and execute. Firstly you should know the function initgraph which is used to initialize the graphics mode . To initialize graphics mode we use initgraph function in our program. initgraph function is present in "graphics.h" header file, so your every graphics program should include "graphics.h" header file. We will discuss initgraph with the help of the following sample program: Sample graphics code #include<graphics.h> #in...