TUpapers logo TUpapers.com

Explore TUpapers

Study materials and tools in one place.

  • Dashboard
  • Blog
  • Search
  • About

Follow us

TUpapers on Facebook
TUpapers on Instagram
Contact TUpapers on WhatsApp
TUpapers subreddit on Reddit
Student Dashboard Student Dashboard
TUpapers logo TUpapers.com
  • Blog
  • About

Support Us

Your support helps us for further development and maintenance of site and resources!

Bank QR code for payment
eSewa QR code for payment
Khalti QR code for payment

The best way to support TUpapers is by purchasing a Premium Suscription or Notes Every purchase directly funds new features, better study resources, and platform maintenance.

On this chapter

Unit 1: Introduction

All Chapters

Dashboard

Select a chapter to start reading

Computer Graphics and Animation Notes | BCA Fifth Semester | TU Papers

1 Chapter 1 Preview

No preview available.

Notes for this subject are coming soon — check back later.

Student Dashboard

Continue Reading

Get full notes inside the dashboard, along with other study tools.

Unit 1: Introduction to Computer Graphics [6 Hours]

This unit forms the backbone of Computer code_snippetGraphics. It covers why graphics systems exist, what hardware and software run them, how displays work at the electron level, and how the computer draws lines, circles, and filled regions using mathematical algorithms. Every topic here has appeared in TU exams repeatedly — algorithms especially. Read carefully, work every numerical example yourself, and you will be exam-ready.

Tested Topics

  1. Raster scan vs. random/vector scan display systems — 4x (2025, 2024, 2023, 2022)
  2. DDA Line Drawing Algorithm — 3x (2025, 2023, 2022)
  3. Scan conversion / Bresenham's Line Drawing Algorithm — 2x (2024, 2023)
  4. Midpoint Circle Drawing Algorithm — 2x (2024, 2022)
  5. Area Filling Algorithms (Flood Fill / Boundary Fill) — 2x (2025, 2023)
  6. Video Controller in raster scan display — 1x (2024)
  7. Pixel and Resolution — 1x (2024)
  8. Beam penetration vs. shadow mask method — 1x (2023)
  9. Horizontal and vertical retrace of electron beam — 1x (2022)
  10. Bresenham's Circle / decision parameter — 1x (2022)
  11. Advantages and Applications of Computer Graphics — 1x (2025)

1.1 Advantages of Computer Graphics and Areas of Application

Core Definition

Computer Graphics is the field concerned with generating, manipulating, and displaying visual images using computational methods. It enables machines to represent, communicate, and interact with information visually rather than through text alone.
Think of it this way: instead of reading "the temperature rose from 20°C to 40°C," a graph shows it instantly. Computer Graphics is the technology behind that visual communication.

Detailed Explanation

Why Computer Graphics matters:

  • Speed and Accuracy: Complex diagrams, charts, and simulations that would take hours to draw manually can be generated in seconds.
  • Interactivity: Users can rotate, zoom, or change views in real time — something impossible with static paper.
  • Reusability: A graphic element created once can be copied, scaled, or modified infinitely at no extra cost.
  • Simulation: Flight simulators, weather models, and surgical trainers use graphics to mimic reality safely and cheaply.
  • Communication: Data visualization makes patterns in large datasets immediately visible.

Key Areas of Application (exam-important):

  • Computer-Aided Design (CAD): Engineers design cars, bridges, and circuits in 3D before building them (AutoCAD, SolidWorks).
  • Computer-Aided Manufacturing (CAM): Machines are programmed using graphical instructions to cut, weld, or shape materials.
  • Entertainment and Animation: Movies, video games, and virtual reality all run on real-time or pre-rendered graphics pipelines.
  • Medical Imaging: CT scans, MRI, and ultrasound produce graphical outputs that doctors interpret visually.
  • Scientific Visualization: Weather maps, molecular models, and astronomical simulations.
  • Education and Training: Interactive simulations for learning without physical risk.
  • Cartography and GIS: Digital maps and geographic information systems.
  • Business Presentation: Charts, dashboards, and infographics for data-driven decisions.

Let's Break It Down

Computer Graphics vs. Image Processing is a common exam question. Here is the clearest way to remember the distinction: Computer Graphics goes from data to image (you have numbers, you produce a picture). Image Processing goes from image to image or image to data (you have a picture, you improve, filter, or analyze it). Graphics creates; processing transforms.

Summary

  • Computer Graphics converts numerical/geometric data into visual form using computational methods.
  • Key advantages: speed, accuracy, reusability, interactivity, and realistic simulation.
  • Major application areas: CAD/CAM, entertainment, medical imaging, scientific visualization, education, GIS.
  • Graphics = data → image; Image Processing = image → processed image (important distinction).

One-Liner Revision

Computer Graphics generates and displays visual images from data — used in CAD, gaming, medicine, and education — and differs from image processing in that it creates images rather than transforming them.

1.2 Hardware and Software for Computer Graphics

Core Definition

Computer Graphics hardware refers to physical devices used to input, process, store, and output graphical information. Graphics software comprises programs and libraries that control these devices to generate and manipulate images.
Hardware is the body; software is the brain. You need both to render a single pixel on screen.

Detailed Explanation

Input Devices:

  • Keyboard: Text and coordinate input.
  • Mouse / Trackball: Pointing and selecting graphical elements.
  • Light Pen: Detects light emitted by the CRT phosphor to identify position on screen.
  • Digitizer / Tablet: Converts physical drawings into digital coordinates.
  • Scanner: Converts physical images into digital raster data.
  • Joystick / Data Glove: For interactive 3D navigation and VR.

Output Devices — Display Technologies:

  • CRT (Cathode Ray Tube): An electron gun fires a beam at a phosphor-coated screen. Where the beam hits, the phosphor glows. Still the foundation for understanding how raster and random scan systems work.
  • LCD (Liquid Crystal Display): Uses liquid crystals modulated by electric fields; backlighting illuminates pixels.
  • LED / OLED: Each pixel emits its own light — better contrast and thinner form factor.
  • Plasma Display: Uses ionized gas to emit UV light that excites phosphor cells.
  • Projector: Scales and projects image onto a large surface.

Hard Copy Devices (output you can hold):

  • Laser Printer: Uses a laser beam and electrostatic charge to fuse toner onto paper — high resolution raster output.
  • Inkjet Printer: Tiny droplets of ink sprayed onto paper; cheaper but slower for graphics.
  • Plotter: Moves a pen (or cuts with a blade) across paper following vector paths — ideal for CAD drawings because lines are drawn, not approximated by dots.
  • Thermal Printer: Uses heat-sensitive paper; common in receipt printers and older fax machines.
  • Film Recorder: Writes graphics directly onto photographic film for high-quality reproduction.

Processing Hardware:

  • GPU (Graphics Processing Unit): Specialized processor with thousands of small cores for massively parallel pixel computation. Modern GPUs handle real-time 3D rendering, physics simulation, and AI workloads.
  • Frame Buffer: A dedicated block of memory that stores the color value of every pixel currently on screen. The display controller reads this buffer continuously to drive the monitor.
  • Video Controller / Display Controller: Reads the frame buffer and generates the analog or digital signal that drives the monitor (covered deeply in 1.3).

Graphics Software:

  • System Software / Device Drivers: Low-level programs that communicate directly with hardware (GPU drivers).
  • Graphics APIs: Libraries that let applications draw without knowing hardware details (OpenGL, DirectX, Vulkan, WebGL).
  • Application Software: End-user tools built on top of APIs (Photoshop, Blender, AutoCAD).
  • Graphics Standards: PHIGS, GKS, OpenGL define portable interfaces so software works across different hardware.

Summary

  • Input devices capture data (mouse, scanner, tablet); output devices present results (CRT, LCD, printer, plotter).
  • Hard copy devices include laser/inkjet printers, plotters, and film recorders — plotters are vector-based, printers are raster-based.
  • GPU and frame buffer are the core processing hardware; the frame buffer holds every pixel's current color value.
  • Software layers: drivers → graphics API (OpenGL) → application software.

One-Liner Revision

Graphics hardware spans input devices, CRT/LCD displays, hard copy devices (printers and plotters), and GPU/frame buffer for processing — all controlled through layered software from drivers to APIs to applications.

1.3 Random Scan Display System, Video Controller, and Random Scan Display Processor

Core Definition

A Random Scan Display System (also called a vector display) is a display architecture where the electron beam is directed only to the locations where lines or shapes must be drawn, tracing each geometric primitive directly rather than sweeping the entire screen. The Video Controller is the hardware unit that reads the frame buffer and converts stored pixel data into the electrical signal that drives the monitor at the correct refresh rate.
Random scan draws like an artist with a pen — only where needed. Raster scan draws like a printer — every dot, left to right, top to bottom.

Detailed Explanation

Architecture of Random Scan Display System:

Raster Graphics Architecture Diagram

A random scan system has these components working together:

  • CPU / Application: The host computer issues a list of drawing commands — "draw line from A to B," "draw circle at center C with radius r."
  • Display File (Display List): A memory buffer that stores all the drawing commands as a structured list. This is not a pixel map — it is a command list.
  • Display Controller / Display Processor: Reads the display file continuously (typically 30–60 times per second) and converts each command into analog voltages that move the electron beam.
  • DAC (Digital-to-Analog Converter): Converts the digital x, y coordinates into voltage levels for the deflection system.
  • Deflection System: Two sets of plates (horizontal and vertical) that use the voltages to steer the electron beam to the correct (x, y) position on the CRT.
  • CRT with Phosphor Screen: The beam strikes the phosphor, which glows. The refresh rate must be fast enough (at least 30 Hz, typically 60 Hz) so the human eye sees a steady image, not flicker.

How a Random Scan System Renders a Diagonal Line:

To draw a line from point A(x1, y1) to point B(x2, y2):

  1. The display processor reads the "draw line A→B" command from the display file.
  2. It computes the start position (x1, y1) and end position (x2, y2).
  3. The deflection system moves the beam from A to B in a single smooth sweep — the beam moves continuously and the phosphor glows along the path.
  4. The line is drawn perfectly as a straight, smooth geometric vector.
  5. The display processor immediately proceeds to the next command and repeats the whole display file 30–60 times per second.

Characteristics of Random Scan:

  • Resolution is extremely high — lines are mathematically precise vectors, not pixel approximations.
  • Color is limited — changing color requires hardware intervention (a different electron gun or filter).
  • Best for line drawings, wireframe CAD, oscilloscopes, and air traffic control displays.
  • Poorly suited for filled areas and photorealistic images.
  • Image complexity is limited — too many vectors in the display file means flicker because the refresh cycle takes too long.

The Video Controller (Role in Raster Scan — covered here for comparison):

In a raster scan system, the video controller performs a different role:

  • Reads the frame buffer (a 2D array of pixel color values) sequentially — row by row, left to right.
  • Converts each pixel's stored color value into an analog R, G, B voltage signal through a DAC.
  • Sends the signal to the monitor with precise timing — horizontal sync pulses at the end of each row, vertical sync pulses at the end of each frame.
  • Manages horizontal retrace (beam jumps back to start of next row) and vertical retrace (beam jumps back to top-left corner) — both happen during blanking intervals.
  • A typical video controller for a 1024×768 display at 60 Hz reads and transmits over 47 million pixel values per second.

Random Scan Display Processor:

The display processor in a random scan system is more intelligent than a simple video controller. It:

  • Interprets high-level drawing commands (lines, circles, text) from the display file.
  • Computes the analog voltages needed for each primitive.
  • Handles clipping (removing parts of objects outside the visible area).
  • In advanced systems, it performs transformations (scaling, rotation) in hardware.
  • Offloads the CPU so the host computer is not busy managing every beam movement.

Common Mistake

Students confuse "display file" with "frame buffer." A display file stores drawing commands (draw line, draw circle) and is used in random scan systems. A frame buffer stores pixel color values and is used in raster scan systems. They are fundamentally different memory structures serving different display architectures.

Test Yourself

  1. A random scan system stores drawing commands; a raster system stores pixel values. What is the memory structure called in each case?
  2. What is the role of the DAC in a random scan display system?
  3. Why does image complexity limit a random scan display?

Answers: 1) Random scan: Display File / Display List. Raster: Frame Buffer. 2) The DAC converts digital (x, y) coordinates into analog voltage levels that move the electron beam via the deflection system. 3) All commands in the display file must be executed within one refresh cycle. Too many commands means the cycle takes longer than 1/30 second, causing visible flicker.

Summary

  • Random scan draws only where lines exist — the beam traces vectors directly, producing sharp, high-resolution line art.
  • The display file stores drawing commands; the display processor interprets them and drives the deflection system repeatedly.
  • The video controller in raster scan reads the frame buffer row by row and generates sync signals for the monitor.
  • Random scan excels at precise line drawings (CAD, oscilloscopes) but cannot handle filled color or photorealistic images.

One-Liner Revision

Random scan steers the electron beam only to lines in a stored command list; the video controller in raster scan reads a frame buffer pixel by pixel and drives the monitor with sync signals.

1.4 Raster Graphics

Core Definition

Raster Graphics is a display technology where the screen is treated as a rectangular grid of discrete picture elements called pixels, and an image is formed by assigning a color value to every pixel in that grid. The electron beam (in CRT) or backlight modulator (in LCD) scans every row from left to right, top to bottom, refreshing the entire grid at a fixed rate.
Imagine the screen as a sheet of graph paper. Every square gets exactly one color. The finer the grid, the more realistic the image.

Detailed Explanation

Key Concepts:

  • Pixel (Picture Element): The smallest addressable unit of a display. Each pixel stores a color value (e.g., 24-bit RGB: 8 bits each for Red, Green, Blue — giving 16.7 million possible colors).
  • Resolution: The total number of pixels in the display grid, expressed as width × height (e.g., 1920×1080). Higher resolution means more pixels per unit area, producing finer detail. Dot Pitch is the physical distance between adjacent pixels — smaller dot pitch = sharper image.
  • Frame Buffer: A dedicated memory that holds the color value of every pixel. For a 1920×1080 display at 24 bits per pixel, the frame buffer requires 1920 × 1080 × 3 bytes = approximately 5.9 MB per frame.
  • Refresh Rate: How many times per second the entire screen is redrawn. Typical: 60 Hz (60 frames per second). Below 30 Hz, humans perceive flicker.
Raster vs Random Scan Display Comparison

How Raster Scan Renders a Diagonal Line:

A raster system cannot draw a true diagonal — it can only turn pixels on or off. To draw a line from (0,0) to (4,4):

  1. A scan conversion algorithm (DDA or Bresenham's) determines which pixel positions best approximate the ideal mathematical line.
  2. It sets those pixels to the line's color in the frame buffer: (0,0), (1,1), (2,2), (3,3), (4,4).
  3. The video controller reads the frame buffer and illuminates those pixels.
  4. The result looks like a diagonal, but on close inspection is a staircase of pixels — this is called aliasing.

Horizontal and Vertical Retrace (exam question 2022):

  • Horizontal Retrace: After the electron beam completes one horizontal scan line (left to right), it must return to the left edge to begin the next row. This return movement is the horizontal retrace. During retrace, the beam is turned off (blanked) so the retrace movement itself does not draw anything on screen.
  • Vertical Retrace: After the beam completes the last row on the screen (bottom-right), it must return to the top-left corner to begin the next frame. This is the vertical retrace. It is also blanked. The vertical retrace period is longer than horizontal retrace.
  • In a 1920×1080 @ 60 Hz display, there are 1080 horizontal retraces per frame and one vertical retrace per frame — all happening 60 times per second.

Advantages of Raster over Random Scan:

  • Can display any image — photographs, videos, filled shapes, gradients.
  • Cost-effective because hardware is simple (just a frame buffer and a controller that reads it linearly).
  • Image complexity does not affect refresh rate — 10 pixels or 10 million pixels, the frame buffer is read in the same fixed time.

Disadvantages:

  • Lines and curves appear jagged (aliased) at low resolutions.
  • Memory requirement scales with resolution (more pixels = more frame buffer RAM).
  • Lower geometric precision than vector/random scan.

Beam Penetration Method vs. Shadow Mask Method (exam question 2023):

These are two hardware methods for producing color in CRT displays.

AttributeBeam Penetration MethodShadow Mask Method
PrincipleMultiple phosphor layers (red inner, green outer). Beam energy controls penetration depth → color.Three separate electron guns (R, G, B) aimed through tiny holes in a metal mask to hit separate phosphor dots.
Color RangeLimited — mainly red, green, orange, yellow (between layers).Full color range — any RGB combination.
ResolutionHigh — single beam, no mask.Lower than beam penetration for line work due to mask hole spacing (dot pitch).
CostCheaper to manufacture.More expensive due to three-gun setup and precision mask.
UseRandom scan / vector displays (CAD terminals).Raster color monitors (standard TVs and computer monitors).
Image TypeBest for line art / wireframes.Best for photorealistic, full-color images.

Test Yourself

  1. A 1024×768 display uses 24-bit color. Calculate the minimum frame buffer size in bytes.
  2. What happens during horizontal and vertical retrace — is the beam on or off? Why?
  3. Why can shadow mask displays show full color but beam penetration displays cannot?

Answers: 1) 1024 × 768 × 3 = 2,359,296 bytes ≈ 2.25 MB. 2) The beam is turned off (blanked) during both retraces. If it were on, the returning beam would draw unwanted lines across the screen. 3) Shadow mask uses three separate guns with independent control of R, G, B intensities, enabling 16+ million color combinations. Beam penetration can only vary depth into two layers, limiting it to a few colors.

Summary

  • Raster graphics treats the screen as a pixel grid; every pixel has a stored color value in the frame buffer.
  • The beam scans every row left-to-right (horizontal scan), then retraces (blanked) to the next row; vertical retrace returns to the top after the last row.
  • Diagonal lines in raster scan are approximated by pixel staircases using scan conversion algorithms.
  • Beam penetration: limited color, high line resolution (random scan). Shadow mask: full color, standard resolution (raster scan).

One-Liner Revision

Raster graphics stores every pixel's color in a frame buffer, refreshes row by row with blanked retraces, and approximates diagonal lines via scan conversion algorithms.

1.5 Scan Conversion Algorithms (Line, Circle, Ellipse)

Core Definition

Scan Conversion (also called rasterization) is the process of converting a continuous mathematical geometric primitive (line, circle, ellipse) into a discrete set of pixel coordinates that best approximates that primitive on a raster display.
The mathematical line y = mx + c is continuous and infinite. The screen has only whole-number pixel locations. Scan conversion answers: "which pixels do we turn on so the result looks like that line?"

Detailed Explanation

Three algorithms are critical for TU exams:

A. DDA Line Drawing Algorithm (Digital Differential Analyzer)

Core Idea: Use the slope of the line to step from one endpoint to the other, computing each intermediate pixel by adding a fixed increment at each step.

Steps (for |m| ≤ 1, i.e., |Δy| ≤ |Δx|):

  1. Calculate Δx = x2 - x1, Δy = y2 - y1.
  2. The larger of |Δx| and |Δy| becomes the number of steps: steps = max(|Δx|, |Δy|).
  3. Compute increments: x_inc = Δx / steps, y_inc = Δy / steps.
  4. Start at (x1, y1). At each step: x = x + x_inc, y = y + y_inc.
  5. Plot the pixel at (round(x), round(y)) for each step.

Worked Example (2022 exam question): Line from (2, 2) to (9, 6)

Δx = 9 - 2 = 7, Δy = 6 - 2 = 4. Steps = max(7, 4) = 7.

x_inc = 7/7 = 1.0, y_inc = 4/7 ≈ 0.571

Stepx (exact)y (exact)Plot (rounded)
Start2.0002.000(2, 2)
13.0002.571(3, 3)
24.0003.143(4, 3)
35.0003.714(5, 4)
46.0004.286(6, 4)
57.0004.857(7, 5)
68.0005.429(8, 5)
79.0006.000(9, 6)

Also verify with 2023 example: Line from (15, 25) to (21, 35)

Δx = 6, Δy = 10. Steps = max(6, 10) = 10.

x_inc = 6/10 = 0.6, y_inc = 10/10 = 1.0

Stepx (exact)y (exact)Plot (rounded)
Start15.025.0(15, 25)
115.626.0(16, 26)
216.227.0(16, 27)
316.828.0(17, 28)
417.429.0(17, 29)
518.030.0(18, 30)
618.631.0(19, 31)
719.232.0(19, 32)
819.833.0(20, 33)
920.434.0(20, 34)
1021.035.0(21, 35)

Advantages of DDA: Simple to understand, easy to implement, works for all slopes.

Disadvantages of DDA: Uses floating-point arithmetic (slow on older hardware), rounding at every step accumulates error over long lines.

B. Bresenham's Line Drawing Algorithm

Core Idea: Use only integer arithmetic — no floating-point at all. At each step, choose between two candidate pixels (the one directly to the right, or the one diagonally up-right) by evaluating a decision parameter p that tells which pixel is closer to the ideal line.

Derivation of the Decision Parameter (for 0 < m < 1, i.e., the slope is between 0 and 1):

The true line equation: y = mx + b, where m = Δy/Δx.

At each step from pixel (xk, yk), the next x is xk+1 = xk + 1. The true y at this x is:

y_true = m(xk + 1) + b

Two candidate pixels: lower pixel (xk+1, yk) and upper pixel (xk+1, yk+1).

The distance from the true y to the lower pixel: d_lower = y_true - yk

The distance from the upper pixel to the true y: d_upper = (yk + 1) - y_true

The decision: if d_lower < d_upper, choose lower pixel; otherwise choose upper pixel.

The sign of (d_lower - d_upper) tells us which to choose:

d_lower - d_upper = 2(y_true) - 2yk - 1
                   = 2m(xk + 1) + 2b - 2yk - 1
                   = 2(Δy/Δx)(xk + 1) + 2b - 2yk - 1

Multiply through by Δx (positive, so inequality direction unchanged):

pk = 2Δy·xk - 2Δx·yk + (2Δy + Δx(2b - 1))
pk = 2Δy·xk - 2Δx·yk + C  (where C is a constant)

Decision rule:

  • If pk < 0 → choose lower pixel (yk+1 = yk), then: pk+1 = pk + 2Δy
  • If pk ≥ 0 → choose upper pixel (yk+1 = yk + 1), then: pk+1 = pk + 2Δy - 2Δx

Initial value: p0 = 2Δy - Δx

Why integer arithmetic helps: All increments (2Δy and 2Δy - 2Δx) are computed once at the start as integers. Every subsequent step uses only integer addition — no multiplication, no division, no rounding. This makes Bresenham's algorithm much faster than DDA on hardware that lacks floating-point units, and it eliminates accumulated rounding errors.

DDA vs Bresenham Line Drawing Comparison

Comparison: DDA vs. Bresenham's

AttributeDDABresenham's
ArithmeticFloating-pointInteger only
SpeedSlower (float ops)Faster
AccuracyRounding error accumulatesNo accumulated error
ImplementationSimpler to understandMore efficient
Hardware suitabilityNeeds FPUWorks on any integer unit

Let's Break It Down

Imagine walking diagonally across a chessboard. DDA says: "Calculate exactly where your foot lands, then step to the nearest square." Bresenham says: "At each step, ask only: is the true path closer to the square directly ahead, or to the one diagonally ahead? One comparison, one integer add, done." Bresenham's genius is reducing a continuous geometric calculation to a single yes/no integer comparison at every pixel.

C. Midpoint Circle Drawing Algorithm

Core Idea: A circle centered at the origin has equation x² + y² = r². Starting at (0, r), the algorithm moves clockwise through the first octant, choosing at each step between the pixel directly to the right or the pixel diagonally down-right using an integer decision parameter. The other 7 octants are filled using 8-way symmetry.

8-Way Symmetry: If a point (x, y) is on the circle, then so are (±x, ±y) and (±y, ±x) — 8 symmetric points total. The algorithm computes only one octant and reflects to get all 8.

Decision Parameter:

f(x, y) = x² + y² - r²
If f = 0: point is on the circle.
If f < 0: point is inside the circle.
If f > 0: point is outside the circle.

Starting at (0, r), the midpoint between the two candidate pixels for the next step is (x+1, y - 0.5).

Initial decision parameter: p0 = 1 - r

Update rules:

  • If pk < 0: next pixel is (xk+1, yk), then pk+1 = pk + 2xk+1 + 1
  • If pk ≥ 0: next pixel is (xk+1, yk - 1), then pk+1 = pk + 2xk+1 + 1 - 2yk+1

Continue until x ≥ y (end of first octant).

Midpoint Circle Algorithm Diagram

Worked Example (2022 exam): Circle r = 5, center (10, 5)

Step 1: Compute points with center at origin (0,0), then translate by adding (10, 5).

Initial: x = 0, y = 5 (for r=5). p0 = 1 - 5 = -4.

kpkxyPixel (translated: +10, +5)
0-405(10, 10)
1-4+2(0)+1+1= -215(11, 10) and symmetrics
2-2+2(1)+1+1= 225(12, 10) and symmetrics
3 (pk≥0)2+2(2)+1+1-2(5)= -234(13, 9) and symmetrics
4-2+2(3)+1+1= 644(14, 9) and symmetrics
5 (pk≥0, x≥y stop)—53Stop (x ≥ y)

First octant points (centered at origin): (0,5), (1,5), (2,5), (3,4), (4,3). Apply 8-way symmetry and translate by (10,5) for final pixels.

Worked Example (2024 exam): Circle r = 7, center (5, 5)

Compute at origin first. p0 = 1 - 7 = -6. Start: x=0, y=7.

kpkxyAction
0-607pk<0: y stays
1-6+2(0)+1+1= -417pk<0: y stays
2-4+2(1)+1+1= 027pk≥0: y decreases
30+2(2)+1+1-2(7)= -836pk<0: y stays
4-8+2(3)+1+1= 046pk≥0: y decreases
50+2(4)+1+1-2(6)= -255pk<0: y stays (x≥y — stop)

First octant at origin: (0,7), (1,7), (2,7), (3,6), (4,6), (5,5). Translate by (5,5) → add 5 to each: (5,12), (6,12), (7,12), (8,11), (9,11), (10,10). Apply 8-way symmetry for all octants.

Ellipse Scan Conversion (brief — syllabus item):

An ellipse is defined by x²/a² + y²/b² = 1, where a is the semi-major axis and b is the semi-minor axis. The midpoint ellipse algorithm generalizes the circle approach with two regions (where the slope of the ellipse changes from |slope| < 1 to |slope| > 1) and separate decision parameters for each region. The same integer arithmetic principle applies. Only 4-way symmetry (not 8-way) is used because ellipses are not symmetric under x↔y interchange unless a = b.

Test Yourself

  1. Use DDA to find all pixel positions for the line from (0,0) to (5,3). Show your table.
  2. For Bresenham's line algorithm with endpoints (0,0) and (6,4), what is the initial decision parameter p0?
  3. For the midpoint circle algorithm with r = 6 and center at origin, what is p0, and what is the first update if p0 < 0?

Answers: 1) Δx=5, Δy=3, steps=5, x_inc=1, y_inc=0.6. Points: (0,0),(1,1),(2,1),(3,2),(4,2),(5,3). 2) Δy=4, Δx=6; p0 = 2Δy - Δx = 8 - 6 = 2. 3) p0 = 1 - 6 = -5. Since p0 < 0: next pixel is (1, 6), p1 = p0 + 2x1 + 1 = -5 + 2(1) + 1 = -2.

Summary

  • Scan conversion converts mathematical primitives to discrete pixel coordinates on a raster display.
  • DDA: float arithmetic, divide Δx and Δy by steps, add increments and round. Simple but uses floating-point.
  • Bresenham's line: integer arithmetic only, decision parameter p tells which of two pixels to choose, updated with 2Δy or 2Δy-2Δx. Faster and more accurate than DDA.
  • Midpoint circle: starts at (0,r), uses p0 = 1-r, integer updates choose between right or diagonal-down pixel; 8-way symmetry generates the full circle from one octant.
  • Ellipse uses midpoint method with two regions and 4-way symmetry.

One-Liner Revision

Scan conversion approximates lines (DDA with floats, Bresenham's with integers) and circles (midpoint algorithm with 8-way symmetry and integer decision parameter) onto pixel grids.

1.6 Area Filling (Rectangle, Ellipse), Clipping (Lines, Circle, Ellipse), Clipping Polygons

Core Definition

Area Filling is the process of coloring all the pixels inside a closed boundary with a specified color. Clipping is the process of identifying and discarding parts of a graphical primitive that fall outside a defined rectangular window (the clip window or viewport boundary), while keeping the parts that lie inside.
Area filling says: "color everything inside this shape." Clipping says: "show only what fits in the window — cut off the rest."

Detailed Explanation

Area Filling Algorithms

1. Scan-Line Fill Algorithm:

The most structured approach to filling polygons and closed shapes.

  1. For each horizontal scan line (row of pixels) from the bottom of the shape to the top:
  2. Find all intersection points of that scan line with the edges of the shape.
  3. Sort the intersection points by x-coordinate (left to right).
  4. Fill pixels between pairs of intersections: from x1 to x2, from x3 to x4, etc.
Scan Line vs Flood Fill Algorithm Comparison

2. Flood Fill Algorithm:

Starts at a seed pixel inside the region and spreads to all connected pixels that share the interior color.

FloodFill(x, y, fillColor, interiorColor):
  if getPixel(x, y) == interiorColor:
    setPixel(x, y, fillColor)
    FloodFill(x+1, y, fillColor, interiorColor)
    FloodFill(x-1, y, fillColor, interiorColor)
    FloodFill(x, y+1, fillColor, interiorColor)
    FloodFill(x, y-1, fillColor, interiorColor)

4-connected vs. 8-connected:

  • 4-connected: A pixel's neighbors are only the 4 pixels directly above, below, left, and right. Diagonal pixels are not considered connected. Simpler but may "leak" through diagonal gaps in the boundary.
  • 8-connected: All 8 surrounding pixels (including diagonals) are considered neighbors. Fills more completely but requires more checks per step.
Flood Fill Algorithm - 4-connected and 8-connected

3. Boundary Fill Algorithm:

Similar to flood fill but stops when it reaches the boundary color instead of when it leaves the interior color.

BoundaryFill(x, y, fillColor, boundaryColor):
  current = getPixel(x, y)
  if current != boundaryColor AND current != fillColor:
    setPixel(x, y, fillColor)
    BoundaryFill(x+1, y, fillColor, boundaryColor)
    BoundaryFill(x-1, y, fillColor, boundaryColor)
    BoundaryFill(x, y+1, fillColor, boundaryColor)
    BoundaryFill(x, y-1, fillColor, boundaryColor)

Flood Fill vs. Boundary Fill (exam question 2023):

AttributeFlood FillBoundary Fill
Stop conditionStops when pixel is not interior colorStops when pixel is boundary color
Input neededSeed point + interior color + fill colorSeed point + boundary color + fill color
Multi-colored interiorCannot handle (only fills one interior color)Can handle (stops at boundary regardless of interior)
Use caseRegions with uniform interior colorRegions defined by a drawn boundary
RiskMay miss pixels if interior has mixed colorsMay leak through gaps in boundary

Area Filling Rectangles and Ellipses:

  • Rectangle: The simplest case — just fill all pixels where x_min ≤ x ≤ x_max AND y_min ≤ y ≤ y_max. Two nested loops.
  • Ellipse: Use the scan-line fill. For each scan line y, find the two x-intercepts from x²/a² + y²/b² = 1 → x = ±a·√(1 - y²/b²). Fill from -x to +x on that row. Translate by center if not at origin.

Clipping

Why Clipping is Needed: A scene may contain objects that extend beyond the visible window. Rendering off-screen pixels wastes computation and may crash the display. Clipping ensures only visible portions are passed to the rasterizer.

Cohen-Sutherland Line Clipping Algorithm:

Divides the 2D plane into 9 regions using 4 bits (region codes / outcodes):

Bit 4 (TOP)   : y > y_max
Bit 3 (BOTTOM): y < y_min
Bit 2 (RIGHT) : x > x_max
Bit 1 (LEFT)  : x < x_min

For each endpoint, compute its 4-bit outcode. Then:

  • If both outcodes = 0000: line is completely inside. Accept.
  • If bitwise AND of both outcodes ≠ 0: line is completely outside (both on same side). Reject.
  • Otherwise: clip — find intersection with the relevant edge using the parametric form, update endpoint, and repeat.

Polygon Clipping — Sutherland-Hodgman Algorithm:

Clips a polygon against each edge of the clip window one at a time (left, right, top, bottom). For each edge, it processes the polygon's vertex list and produces a new vertex list using four cases:

  • Inside → Inside: Output the second vertex.
  • Inside → Outside: Output the intersection point.
  • Outside → Outside: Output nothing.
  • Outside → Inside: Output the intersection point, then the second vertex.

Circle and Ellipse Clipping: Circles and ellipses do not clip cleanly with the four-case algorithm used for lines. The standard approach is to check if the circle/ellipse is entirely inside (all boundary points inside), entirely outside (center distance from each edge is greater than radius), or intersecting (clip the rasterized pixels individually against the clip window). More advanced methods compute exact arc segments, but for TU exams, understanding the boundary testing approach is sufficient.

Common Mistake

Students confuse boundary fill and flood fill in exams. Remember: flood fill checks interior color (keep going as long as you are on the interior color); boundary fill checks boundary color (stop when you hit the boundary). They solve the same problem with different termination conditions — and each has use cases the other cannot handle.

Test Yourself

  1. A region has a white interior and a red boundary. Which algorithm is more appropriate: flood fill or boundary fill? Why?
  2. In Cohen-Sutherland clipping, what does an outcode of 0000 for both endpoints mean?
  3. In the Sutherland-Hodgman algorithm, a polygon edge goes from inside to outside the clip boundary. What output is generated?

Answers: 1) Boundary fill — it stops at the red boundary regardless of what color is inside. Flood fill would only work if every interior pixel is the same white, which may not be the case. 2) Both endpoints are inside the clip window: the entire line segment is visible and is accepted without clipping. 3) Only the intersection point with the boundary edge is output (not the outside vertex).

Summary

  • Scan-line fill finds intersections for each row and fills between pairs; efficient for polygons and ellipses.
  • Flood fill spreads from a seed, stopping at non-interior pixels; boundary fill spreads until it hits boundary color.
  • 4-connected fills use 4 neighbors; 8-connected use all 8 (more thorough, handles diagonal gaps).
  • Cohen-Sutherland clips lines using 4-bit region codes; trivial accept/reject before computing intersections.
  • Sutherland-Hodgman clips polygons edge by edge, processing vertex lists with four inside/outside cases.

One-Liner Revision

Area filling (scan-line, flood, boundary) colors enclosed regions; clipping (Cohen-Sutherland for lines, Sutherland-Hodgman for polygons) removes portions outside the view window before rendering.

⭐ Extra: Topics Asked in Exams But Not Explicitly in Syllabus

These topics have appeared in TU past papers. They are not listed in the official 1.1–1.6 syllabus but you must know them — TU examiners set questions from adjacent topics and textbook coverage. Do not skip them.

Pixel and Resolution (2024 exam)

Pixel (short for Picture Element) is the smallest addressable unit on a raster display. Each pixel stores a discrete color value. The resolution of a display is the total count of pixels expressed as columns × rows (e.g., 1920×1080). A higher pixel count per unit area means finer detail and a sharper image. Spatial resolution refers to how many pixels fit in a given area; intensity resolution refers to how many distinct color/gray levels each pixel can represent (determined by bit depth: 8-bit = 256 levels; 24-bit = 16.7 million colors).

Computer Graphics vs. Image Processing (2023 exam)

AttributeComputer GraphicsImage Processing
DirectionData / model → ImageImage → Improved Image / Data
InputGeometric data, coordinates, equationsExisting image (photo, scan, video frame)
OutputRendered image or animationProcessed image or extracted information
GoalCreate or render visual contentEnhance, analyze, or compress images
Examples3D game rendering, CAD, animationMRI enhancement, face recognition, Photoshop filters
TechniquesRay tracing, scan conversion, shadingConvolution, edge detection, compression

Horizontal and Vertical Retrace (2022 exam)

Covered in detail under 1.4 Raster Graphics above. Key exam points: both retraces are blanked (beam turned off), horizontal retrace happens after every scan line, vertical retrace happens after every complete frame. These are essential to how CRT displays work and are frequently asked in 2-mark questions.

Applications of Computer Graphics (2025 short notes)

Covered under 1.1. For short note format: name 5–6 application areas (CAD/CAM, entertainment/gaming, medical imaging, scientific visualization, education, GIS/cartography), give one concrete example for each, and state why graphics is the right tool for that domain.

DDA as Short Notes (2025 short notes)

For a short note on DDA: define (Digital Differential Analyzer, a float-based incremental line algorithm), give the steps (compute Δx, Δy, steps = max(|Δx|,|Δy|), compute increments, loop with rounding), state advantages (simple) and disadvantages (float arithmetic, accumulated rounding error), and compare briefly with Bresenham's (integer, faster).

Exam Guidance

TU Computer Graphics Unit 1 has a clear pattern: display systems and algorithms alternate every year. In any exam, expect at least one algorithm question requiring a worked numerical table (DDA or Midpoint Circle), one display system question (raster vs. random scan or video controller), and one area filling question. Practice working the numerical tables by hand — examiners give marks for each correct row in the table, so showing all steps earns partial credit even with an arithmetic slip.

Whole Chapter Summary

Computer Graphics converts geometric data into visual images; it differs from image processing in that it creates images rather than transforming them. Applications span CAD, entertainment, medicine, GIS, and education.

Hardware includes input devices, CRT/LCD/LED displays, hard copy devices (printers, plotters), and GPU/frame buffer. Software layers go from device drivers to graphics APIs to applications.

Random scan displays store drawing commands in a display file and trace vectors directly — sharp lines, limited color, complexity-limited. Raster displays store pixel values in a frame buffer and scan every row — supports full color and complex images. The video controller reads the frame buffer, generates sync signals, and manages horizontal/vertical retrace (blanked).

Raster graphics treats the screen as a pixel grid. Pixel is the smallest unit; resolution is the grid size. Horizontal retrace returns the beam to the start of the next row; vertical retrace returns it to the top of the screen. Beam penetration gives limited color for vector displays; shadow mask gives full color for raster displays.

Scan conversion approximates continuous shapes in discrete pixels. DDA uses floating-point increments (steps = max(|Δx|,|Δy|), add x_inc and y_inc, round). Bresenham's uses integer arithmetic (decision parameter p0 = 2Δy - Δx; if p<0 → lower pixel; if p≥0 → upper pixel). Midpoint circle uses p0 = 1-r and 8-way symmetry to generate a full circle from one octant. Ellipse uses midpoint with two regions and 4-way symmetry.

Area filling: scan-line fill finds row intersections and fills between pairs. Flood fill spreads from a seed, stopping at non-interior pixels. Boundary fill spreads until hitting boundary color. 4-connected vs. 8-connected controls whether diagonals count as neighbors. Clipping removes out-of-window portions: Cohen-Sutherland for lines (4-bit outcodes), Sutherland-Hodgman for polygons (vertex-by-vertex edge clipping).

Exam Questions

  1. Define raster and random scan display systems. Draw and explain how each system renders a diagonal line. (2025)
  2. How raster scan display is different from vector scan display? What is the role of video controller in raster scan display system? (2024)
  3. Define Pixel and resolution. (2024)
  4. What is scan conversion? Derive the decision parameter for Bresenham's line drawing algorithm for m<1. (2024)
  5. Use the Midpoint Circle drawing Algorithm to draw a circle with a radius of 7 units, centered at (5,5). (2024)
  6. Differentiate between beam penetration method and shadow mask method. How does raster scan display system work? (2023)
  7. How DDA works? Digitize the line segment with the endpoints (15, 25) and (21, 35) using DDA line drawing algorithm. (2023)
  8. Differentiate between boundary fill algorithm and flood fill algorithm in detail. (2023)
  9. Define horizontal and vertical retrace of electron beam. Explain architecture of random scan display system. (2022)
  10. How does decision parameter can be used to draw circle? Calculate the points to draw a circle having radius 5 and center at (10, 5) using mid-point circle algorithm. (2022)
  11. Generate the points between the end points of a line viz. (2, 2) and (9, 6) by using DDA line drawing algorithm. (2022)
  12. Discuss the importance and workflow of area filling algorithms with diagrams. Explain how the flood fill algorithm works with 4-connected and 8-connected boundaries. (2025)
  13. Derive the general formula for the decision parameter in Bresenham's algorithm. How does integer arithmetic help avoid floating-point operations? (2025)
  14. Write short notes on: DDA algorithm. (2025)
  15. Write short notes on: Application of Computer Graphics. (2025)
  16. Write short notes on: Computer Graphics Vs. Image Processing. (2023)

Key Formulas and Points Sheet

Formula / RuleMeaning
steps = max(|Δx|, |Δy|)DDA: number of pixel steps for a line
x_inc = Δx/steps, y_inc = Δy/stepsDDA: per-step increment values
p0 = 2Δy − Δx (Bresenham line)Initial decision parameter for 0 < m < 1
pk<0 → pk+1 = pk + 2Δy (lower pixel)Bresenham update when choosing lower neighbor
pk≥0 → pk+1 = pk + 2Δy − 2Δx (upper pixel)Bresenham update when choosing upper neighbor
p0 = 1 − r (midpoint circle)Initial decision parameter for circle at origin
pk<0 → pk+1 = pk + 2xk+1 + 1 (right pixel)Midpoint circle update: stay at same y
pk≥0 → pk+1 = pk + 2xk+1 + 1 − 2yk+1 (diag pixel)Midpoint circle update: decrease y by 1
f(x,y) = x² + y² − r²Circle function: <0 inside, =0 on, >0 outside
Frame buffer size = W × H × bits_per_pixel / 8 bytesMemory needed to store one frame
8-way symmetry: (x,y) → (±x,±y) and (±y,±x)Mirror circle points across all octants

Last-Minute Revision Sheet

Computer Graphics → data to image → CAD, games, medicine, GIS

CG vs Image Processing → CG creates; IP transforms existing images

Hard copy → plotter (vector), printer (raster), film recorder

Frame buffer → stores every pixel's color → read by video controller → drives monitor

Random scan → display file (commands) → vector precision → limited color → no fills

Raster scan → frame buffer (pixels) → full color → approximated lines

Video controller → reads frame buffer row by row → generates H-sync and V-sync signals

H-retrace → end of row, beam returns left → blanked

V-retrace → end of frame, beam returns top-left → blanked

Beam penetration → 2 phosphor layers → limited color → random scan only

Shadow mask → 3 guns R,G,B → full color → raster monitors

DDA → float → steps = max(|Δx|,|Δy|) → add inc → round → simple, slow

Bresenham line → integer only → p0 = 2Δy−Δx → p<0 lower, p≥0 upper → fast, no error

Midpoint circle → p0 = 1−r → 8-way symmetry → one octant gives full circle

Scan-line fill → find intersections per row → fill between pairs → best for polygons

Flood fill → seed → spread while interior color → 4 or 8 connected

Boundary fill → seed → spread until boundary color → 4 or 8 connected

Cohen-Sutherland → 4-bit outcodes → AND≠0 reject, both 0 accept, else clip to edge

Sutherland-Hodgman → clip polygon one edge at a time → 4 in/out cases per vertex pair

Views: …
TUpapers.com logo tupapers.com
  • Privacy Policy

  • Contact Us

  • Terms

  • Pricing

  • SEEpapers.com

TUpapers on Facebook
TUpapers on Instagram
Contact TUpapers on WhatsApp Contact TUpapers on WhatsApp
TUpapers subreddit on Reddit

Courses

  • BBA

  • BCA

  • BIT

  • CSIT

  • BBS

  • BHM

  • BBM

  • BITM

  • BTTM

  • BA

  • BE

  • BSW

© 2026 tupapers.com. All rights reserved.