0% found this document useful (0 votes)
5 views8 pages

Line Drawing Algorithms in Computer Graphics

The document is an activity report on the 'Line Drawing Algorithm in Computer Graphics' submitted by students of K S Institute of Technology for their Bachelor of Engineering degree. It details the implementation and analysis of five line drawing algorithms, including DDA and Bresenham's, focusing on their mathematical foundations and visual outcomes. The project aims to enhance understanding of computer graphics through practical coding and comparative analysis of algorithm performance.

Uploaded by

yaduy387
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views8 pages

Line Drawing Algorithms in Computer Graphics

The document is an activity report on the 'Line Drawing Algorithm in Computer Graphics' submitted by students of K S Institute of Technology for their Bachelor of Engineering degree. It details the implementation and analysis of five line drawing algorithms, including DDA and Bresenham's, focusing on their mathematical foundations and visual outcomes. The project aims to enhance understanding of computer graphics through practical coding and comparative analysis of algorithm performance.

Uploaded by

yaduy387
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

VISVESVARAYA TECHNOLOGICAL UNIVERSITY

“JNANASANGAMA,” BELAGAVI-590018

Activity Report on
Line Drawing Algorithm in Computer Graphics

Submitted in Partial fulfilment for the award of Degree for the academic
Year 2025-2026

Submitted by

NAME Roll No.


VISHAL RAJ 46
YADUNANDN G N 47
SHRAYAA SHEKAR 48
VANSHIKA 49
TARUN P 50

Department of Computer Science and Engineering

K S INSTITUTE OF TECHNOLOGY
An Autonomous Institution under VTU
No. 14, Raghuvanahalli, Kanakapura Main Road, Bangalore –
560109
2025 – 2026

1|Page
K S INSTITUTE OF TECHNOLOGY
An Autonomous Institution under VTU
No. 14, Raghuvanahalli, Kanakapura Main Road, Bangalore – 560109

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

CERTIFICATE

This is to certify that the project entitled on ‘Line Drawing Algorithm in Computer
Graphic’ is a Bonafide work carried out by

NAME Roll No.


VISHAL RAJ 46
YADUNANDN G N 47
SHRAYAA SHEKAR 48
VANSHIKA 49
TARUN P 50

in partial fulfilment for the award of Bachelor of Engineering in Computer Science


and Design of the Visvesvaraya Technological University, Belgaum during the year
2025–2026. It is certified that all corrections / suggestions indicated for internal
assessment have been incorporated in the report deposited in the departmental library.
The report has been approved as it satisfies the academic requirement in respect of
course prescribed for the Degree.

Signature of Course In-charge Signature of HOD Signature of Principal

DATE:
PLACE:

2|Page
ACKNOWLEDGEMENT

Any achievement, be it scholastic or otherwise does not depend solely on the individual
efforts but on the guidance, encouragement and cooperation of intellectuals, elders, and
friends. Several personalities, in their own capacities have helped me in carrying out these
activities. I would like to take this opportunity to thank them all.

I would like to thank Dr. Dilip Kumar K, Principal, K.S. Institute of Technology,
Bangalore for their timely advice on the academics and regular assistance throughout our
semester.

I am greatly indebted to Dr. Deepa S R, Head of Department, Computer Science and


Design who has been inspiring and has guided me towards becoming technically more
competent, & also for having taken the pains to provide us the necessary facility.

I am greatly indebted to Dr. Jalaja P, Head of Department, Mathematics who has been
inspiring and has guided me towards becoming technically more competent, & also for
having taken the pains to provide us the necessary facility.

I would like to thank Mr. Supriya M D, Assistant Professor, Department of Mathematics


in for his constant support and for providing invaluable insights and direction.

I also extend my sense of gratitude and sincere thanks to all the faculty members of the
Computer Science and Design, KSIT, Bangalore, for their constant encouragement and
support.

Last but not the least I pay my respect and love to my beloved Parents and all other family
members and friends for their love and encouragement towards the completion of work.

3|Page
ABSTRACT
Computer Graphics is a fundamental area of computer science that focuses on the creation and
manipulation of image data by a computer. One of the most basic yet critical tasks in computer
graphics is the process of Scan Conversion or Rasterization, which involves approximating
continuous geometric primitives, such as lines, onto a discrete grid of pixels. This project report
focuses on the detailed analysis, mathematical derivation, and implementation of five primary
line drawing algorithms:

1. Digital Differential Analyzer (DDA): A fundamental algorithm using floating-point arithmetic


2. Bresenham’s Line Algorithm: An optimized integer-based approach for efficient rendering.
3. Midpoint Line Algorithm: A variation of Bresenham’s using implicit line equations.
4. Xiaolin Wu’s Algorithm: An advanced technique for anti-aliasing to reduce jagged edges
5. Gupta-Sproull Algorithm: A sophisticated signal-processing approach to high-quality line
generation.
.

The project aims to demonstrate how mathematical slope equations are translated into computer code to
illuminate specific pixels on a screen. We compare "Aliased" algorithms (DDA, Bresenham, Midpoint)
which produce jagged lines, against "Anti-Aliased" algorithms (Wu, Gupta-Sproull) which produce
smooth lines using pixel intensity modulation.

We have implemented these algorithms using Python to simulate the pixel grid and visualize the results.
The report further provides a comparative analysis of the time complexity, precision, and visual quality of
all methods.

4|Page
TABLE OF CONTENTS

Sl No: CONTENTS Page No:

1. NTRODUCTION

2. MATHEMATICAL CONCEPTS USED

3. SYSTEM DESIGN & FLOWCHARTS

4. IMPLEMENTATION & CODE

5. RESULT

6. COMPARATIVE ANALYSIS

7. CONCLUSION & FUTURE SCOPE

8. REFERENCES

5|Page
1. Introduction

Overview of Computer Graphics Computer graphics is an art of drawing pictures on


computer screens with the help of programming. It involves computations, creation, and
manipulation of data. In computer graphics, the two primary components are the hardware
(monitor, GPU) and the software (algorithms like OpenGL, DirectX, or custom
implementations).
The fundamental building block of any digital image is the Pixel (Picture Element). A
computer screen consists of a 2D grid of pixels. To draw shapes, the computer must decide
which pixels to turn on (illuminate) to approximate the shape.

The Rasterization Problem in mathematics, a line is a continuous set of points. There is an


infinite number of points between any two coordinates (x1, y1) and (x2, y2). However, a
computer monitor is discrete. It has a finite resolution (e.g., 1920 *1080).
The Challenge: When we want to draw a line from Point A to Point B, we cannot draw a "true"
straight line. We must approximate it by selecting the pixels that lie closest to the true
mathematical path. This process is called Scan Conversion or Rasterization.

Problem Statement:
To design and implement a software application that takes two coordinate points as input from
the user and visualizes the line connecting them using both the DDA and Bresenham
algorithms. The system must graphically display the grid and the selected pixels to
demonstrate the working of the algorithms.
Objectives of the Project:
1. Mathematical Understanding: To deeply understand the geometry of lines, specifically
the concept of slope (m) and how it dictates pixel selection.
2. Algorithm Implementation: To implement the DDA algorithm and observe its reliance on
floating-point calculations.
3. Optimization: To implement Bresenham’s algorithm and understand how integer
arithmetic offers superior performance for computer hardware.
4. Visualization: To use plotting tools (Matplotlib) to visually compare the "true"
mathematical line against the discrete pixels selected by the algorithms.
.

6|Page
2. Mathematical Concepts Used

1. The Equation Of a Line

The fundamental equation used in all line drawing algorithms is the slope-intercept form:
y = mx + c
Where:
 (x, y) are the coordinates of a point on the line.
 m is the Slope or Gradient of the line.
 c is the y-intercept (where the line crosses the Y-axis).
The slope $m$ is calculated as:
m = (y2-y1) / (x2-x1)= Delta y / Delta x
This slope is the critical factor. It tells us how much $y$ increases for every unit increase
in x
 If m = 1, the line is perfectly diagonal (45 degrees).
 If m < 1, the line is more horizontal. We step through x and calculate y.
 If m > 1$ the line is more vertical. We step through y and calculate x.

2. Digital Differential Analyzer(DDA)

The DDA is a scan-conversion line algorithm based on calculating either Delta y or


Delta x. It samples the line at unit intervals in one coordinate and determines the
corresponding integer values nearest the line path for the other coordinate.

The Logic:

7|Page
We know that m=delta y / delta x. therefore , delta y =m*delta x.

Case 1: Positive Slope, |m| <= 1 (Gentle Slope)

In this case, x changes faster than y. We increment x by 1 unit at every step

(Delta x = 1).

Using the equation above:

yk+1 = yk + (m*1)
yk+1 = yk +
The new y value will likely be a decimal number. Since pixels must be integers, we
round the result:

Pixel = (x,Round}(y))
Case 2: Positive Slope, |m| > 1 (Steep Slope)

In this case, y changes faster than x. We increment y by 1 unit at every step(Delta y =1).

We reverse the slope equation: Delta x = delta y /m.

xk+1 = xk + =1/m
Here, we must round the x value:

Pixel= (Round(x), y)
Disadvantages of DDA:

 Floating Point Arithmetic: The algorithm involves adding $m$ (a decimal)


repeatedly. Floating-point additions are slower than integer additions in computer
processors.
 Error Accumulation: Repeated addition of floating-point numbers can lead to
precision errors over very long lines, causing the pixels to drift away from the true
line.

8|Page

You might also like