Category Archives: Graphics

Cohen Sutherland Line Clipping Algorithm in C and C++

Here you will learn about cohen sutherland line clipping algorithm in C and C++. This is one of the oldest and most popular line clipping algorithm. To speed up the process this algorithm performs initial tests that reduce number of intersections that must be calculated. It does so by using a 4 bit code called as… Read More »

Liang Barsky Line Clipping Algorithm in C and C++

Here you will learn about liang barsky line clipping algorithm in C and C++. This Algorithm was developed by Liang and Barsky. It is used for line clipping as it is more efficient than Cyrus Beck algorithm and Cohen Sutherland algorithm because it uses more efficient parametric equations to clip the given line. These parametric equations… Read More »

Boundary Fill Algorithm in C and C++

Here you will learn about boundary fill algorithm in C and C++. Boundary Fill is another seed fill algorithm in which edges of the polygon are drawn. Then starting with some seed any point inside the polygon we examine the neighboring pixels to check whether the boundary pixel is reached. If boundary pixels are not… Read More »

Flood Fill Algorithm in C and C++

Here you will learn about flood fill algorithm in C and C++. Flood Fill is a seed fill algorithm similar to Boundary Fill algorithm but sometimes when it is required to fill in an area that is not defined within a single color boundary we use flood fill instead of boundary fill. For this purpose… Read More »

DDA Line Drawing Algorithm in C and C++

Here you will learn about dda line drawing algorithm in C and C++. In Computer Graphics the first basic line drawing algorithm is Digital Differential Analyzer (DDA) Algorithm. A line connects two points. It is a basic element in graphics. To draw a line, you need two points between which you can draw a line. Also… Read More »

Bresenham’s Line Drawing Algorithm in C and C++

Here you will get program for bresenham’s line drawing algorithm in C and C++. This algorithm is used in computer graphics for drawing line. The program will work in Turbo C or Turbo C++ compiler as it uses graphics.h header file. Make sure to change the path of BGI folder inside initgraph() function according to your… Read More »

Midpoint Circle Algorithm in C and C++

Here you will get program for midpoint circle algorithm in C and C++. It is an algorithm used in computer graphics for drawing circle. This program will work in Turbo C or Turbo C++ compiler as it uses graphics.h header file. Change the path of BGI file inside initgraph() function according to your system to… Read More »

Make Analog Clock in C Using Graphics

In this tutorial you will learn how you can create an analog clock in C using graphics. This tutorial is written in a way that a beginner C graphics programmer can also understand. Before getting into the main let me explain the functions I have used in the program. Also Read: C/C++ Program to Create a… Read More »

Simple program to create a moving car in graphics

#include<graphics.h> #include<conio.h> #include<dos.h> void main() { int gdriver=DETECT,gmode,i=0,j=0; initgraph(&gdriver,&gmode,”c:\turboc3\bgi”); for(i;i<420;++i) { line(0,245,650,245); line(0+i,200,210+i,200); line(50+i,200,70+i,170); line(70+i,170,140+i,170); line(140+i,170,160+i,200); line(85+i,170,85+i,200); line(125+i,170,125+i,200); line(0+i,200,0+i,230); line(210+i,200,210+i,230); line(0+i,230,50+i,230); circle(65+i,230,15); line(80+i,230,130+i,230); circle(145+i,230,15); line(210+i,230,160+i,230); pieslice(65+i,230,359-j,360-j,15); pieslice(65+i,230,179-j,180-j,15); pieslice(65+i,230,89-j,90-j,15); pieslice(65+i,230,269-j,270-j,15); pieslice(145+i,230,359-j,360-j,15); pieslice(145+i,230,179-j,180-j,15); pieslice(145+i,230,89-j,90-j,15); pieslice(145+i,230,269-j,270-j,15); if(j==179) j=0; ++j; delay(30); cleardevice(); } closegraph(); }