Computer Graphics(313014)
Practical No:04 - Write a C program to draw a circle using Bresenham’s algorithm.
I. Practical Significance:
Bresenham's circle drawing algorithm is a fundamental algorithm in computer graphics that
allows for the efficient and accurate rendering of circles. This algorithm uses integer
arithmetic to plot points of a circle, which enhances performance on raster displays by
avoiding floating-point calculations.
II. Industry, Employer Expected outcomes:
This practical aims to develop the following skills:
Develop C programs to draw basic graphics objects.
1. Write syntax for graphics functions.
2. Set up graphics driver, mode, and directory to run graphics programs.
3. Compile C programs using Turbo C.
4. Debug and execute programs effectively.
III. Course Level Learning Outcomes:
Develop programs in C applying standard graphics algorithms.
1. Develop and implement programs in C using advanced graphics algorithms.
2. Apply Bresenham's algorithm to draw circles in graphics applications.
3. Gain a deeper understanding of fundamental drawing algorithms in computer
graphics.
IV. Laboratory Learning outcomes:
LLO 4.1 Implement a C program to draw circle using Bresenham's algorithm.
V. Relevant Affective Domain Related Outcomes:
- Demonstrate patience and attention to detail when debugging graphics code.
- Show creativity in designing visual representations.
VI. Relevant Theoretical Domain Related outcomes(with Diagram if required):
The equation of a circle x2 + y2 = r2, where (x, y) are the coordinates of the
center and (r) is the radius. To draw a circle on a computer, we can utilize algorithms like
the Bresenham's circle drawing algorithm or the midpoint circle drawing algorithm.
Due to the discrete nature of raster displays, displaying a continuous arc is challenging.
Instead, we must select the nearest pixel position to complete the arc, resulting in an
approximation of the desired curve. These algorithms efficiently plot points along the
circumference of the circle, ensuring that it is recognizable despite the limitations of raster
displays.
Maharashtra State Board Of Technical Education 23
Computer Graphics(313014)
Bresenham’s Circle Algorithm
Bresenham's circle algorithm is based on the idea of determining the subsequent pixel
required to draw a circle. (x+1, y) is used to find the next pixel to draw the circle.
In the context of Bresenham's circle algorithm, f(n)typically refers to the decision
variable used to determine the next pixel position along the circle.Similarly, f(s)
represents the value of the decision variable at the symmetric position.As for (x+1, y)
and (x+1, y-1) , they are the candidate pixels that are evaluated to determine the next
pixel position along the circle's circumference. The decision is based on choosing the
midpoint that is closer to the true circle
VII.Required Resources/apparatus/equipment with specification:
Sr. Name of
Specification Qty. Remarks
Resource
Hardware: Computer(i3-if preferable),
Computer RAM minimum 2 Gb and
1. System onwards but not limited
As per batch For All
Operating Windows XP/ Windows Experiment
2. Size
System 7/LINUX version 5.0 or later s
Turbo C/C++ Version 3.0 or later
2. Software with DOSBOX
VIII. Precautions to be followed :
- Ensure the graphics library is properly installed and configured.
- Check for compatibility of the graphics library with the compiler.
- Handle errors and exceptions to avoid crashes.
IX. Procedure :
1. Start
2. Declare x, y, r, D, xc, yc where (xc, yc) are center coordinates, x and y points to be plotted,
r
is the radius, D is decision factor.
3. Calculate decision parameter D as: D = 3–(2 * r)
4. Initialize x = 0, y = r
5. Compute next pixels on circle based upon decision parameter
While x ≤ y
Plot (x, y)
if D<0,
then D = D + 4x + 6
Else
D = D + 4(x - y) + 10
y=y–1
end if
Maharashtra State Board Of Technical Education 24
Computer Graphics(313014)
x=x+1
6. End
Sample Output of The Source Example:
X. Resources used
Sr.
Name of Resource Specification
No.
Computer System
1.
with broad specifications
2. Software
3. Any other resource used
Algorithm:
Maharashtra State Board Of Technical Education 25
Computer Graphics(313014)
Flowchart:
‘C’ program code
Maharashtra State Board Of Technical Education 26
Computer Graphics(313014)
XI. Result :
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
XII.Conclusions and recommendation:
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
XIII. Practical Related Questions:
Note: Below given are few sample questions for reference. Teachers must
design more such questions so as to ensure the achievement of identified CO.
1. Write equation for Circle.
2. Write algorithm to draw 8-way symmetry of circle.
3. How the Value of Decision Parameter (d) is calculated. Explain with Example.
(Space for Answer)
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
Maharashtra State Board Of Technical Education 27
Computer Graphics(313014)
………………………………………………………………………………………………………
XIV. Excersize:
1. Calculate pixels for a circle with radius 10 using Bresenham’s Circle Algorithm
d x y Plot(x,y)
2. Draw a circle with center(50,50) and radius 20 by using Bresenham’s Circle Algorithm
(Space for Answer)
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
Maharashtra State Board Of Technical Education 28
Computer Graphics(313014)
………………………………………………………………………………………………………
XV. References/Suggestions for further reading: include Website. Link:
1. https://books.google.co.in/books?isbn=8184317379
2. https://math.hws.edu/eck/cs424/downloads/graphicsbook-linked.pdf
3. https://books.google.com/books/about/Computer_Graphics.html?id=XgAeEAAAQBAJ
4. https://www.freebookcentre.net/CompuScience/Free-Computer-Graphics-Books-
Download.html#google_vignette
XVI. Assessment Scheme
Performance indicators Weightage
Process related: 15 Marks 60%
1. Debugging ability 20%
2. Correctness of Program codes 30%
3. Quality of output achieved(LLO mapped) 10%
Product related: 10 Marks 40%
1. Completion and submission of practical in time 20%
2. Answer to sample questions 20%
Total 25 Marks 100%
List of Student /Team Members
1. ………..………..………..
2. ………..………..………..
3. ………..………..………..
4. ………..………..………..
Marks obtained Dated Sign of Teacher
Process Product
Related(15) Related(10) Total(25)
Maharashtra State Board Of Technical Education 29