Search This Blog

Showing posts with label bresenham. Show all posts
Showing posts with label bresenham. Show all posts

Bresenham's Line Drawing Algorithm Implementation in C - Generalized Algorithm

Bresenham's line drawing algorithm is an efficient algorithm to draw any line. Unlike DDA algorithm, it uses only integer incremental calculations during the process. This saves much of the CPU time. I am posting a generalized Bresenham's line drawing algorithm (an algorithm that can draw any line in any quadrant with any slope). The main function in this program draws lines of almost all slopes by drawing radial lines for a circle. The entered endpoints of the line are marked in red color. The rest of the line is drawn in the default stroke color in BGI graphics. You can change it by calling setcolor() function.

Output:


Program is given below:

Bresenhams Circle Drawing Algorithm Implementation in C

Bresenham's circle drawing algorithm is one of the basic algorithms in computer graphics. Bresenham's circle drawing algorithm helps to draw circles with minimal calculations. Here is a simple c program that implements Bresenham's circle drawing algorithm.

The program is as follows: