Show Menu
Cheatography

Computer Graphics Cheat Sheet (DRAFT) by

Exam ready computer graphics on turbo c

This is a draft cheat sheet. It is a work in progress and is not finished yet.

UNIT 1

PART A
pixel - smallest addres­sable unit (on digital raster or display screen)
video display devices - Raster Scan (more memory; entire pixel grid/frame buffer) and Random Scan (Vector Scan; drawing commands, less memory)
CRT - Cathode Ray Tube (fig. 1)
area filling primitives - (1) Polygon fill areas and (2) Curved boundary fill areas (or seed-f­illed regions)
Polygon inside testing or Polygon scan conversion identifies polygon's interior pixels
types of refresh buffers - RAM (VRAM or DRAM)
Object geometry - contin­uous; raster repres­ent­ation - discrete approx­imation
 

DDA

1. Calculate ∆x, ∆y and steps
∆x=x2-x1; ∆y=y2-y1; steps=­max­(|∆­x,∆y|)
increm­ents: dx=∆x/­steps; dy=∆y/­steps
start: x1,y1; iterations x=x+dx, y=y+dy
Disadv­antage:
Floati­ng-­point operations are
comput­ati­ona­lly­ slower and hardwa­re-­int­ensive.

Bresen­ham's Line Drawing Algorithm

find ∆x and ∆y
p0=2∆y-∆x
if pk<0; pk+1=pk+2∆y; xk+1=xk+1; yk+1=yk
if pk>0; pk+1=pk+2∆y-2∆x; xk+1=xk+1; yk+1=yk+1

Mid-Point Circle Drawing

starting point : (0, r)
p0=1-r
pk<0 : xk+1=xk+1; yk+1=yk; pk+1=pk+2xk+1+1;
pk>0 : xk+1=xk+1; yk+1=yk-1; pk+1=pk+2xk+1-2yk+1+1;

Defini­tions

Boundary fill colors inward until a specific boundary color is reached.
Flood fill replaces a target color within a bounded area, regardless of the boundary color.
Scan-line fill is more efficient, using horizontal lines to fill polygon interiors.

Flood Fill vs Boundary Fill

Flood Fill
Boundary Fill
Fills all connected pixels having the same old color.
Fills pixels until a boundary color is reached.
Stops when a different color is encoun­tered.
Region is defined by a closed border.
Checking condition
if (pixel­_color == old_color)
if (pixel­_color != bounda­ry_­color && pixel_­color != fill_c­olor)
Disadv­antage
A 4-conn­ected Flood Fill may leak when the boundary is not closed in the 4-conn­ected sense, even if it appears visually closed.
 

Filled area vs. line drawing

For the Statement
Against the Statement
Fill algorithms handle large pixel regions (effic­iency matters)
very frequently used per frame (constant memory)
Boundary Fill can be slow and may leak if the boundary is not properly closed (recursive stack)
Bresenham are highly optimized and essential
Scan-line Fill is fast, iterative, and reliable (minimal memory)
poor choice impacts overall rendering
Applic­ation context:
In real-time systems (games), scan-l­ine­-based raster­ization is preferred for speed and stability.
In paint programs, Boundary Fill is acceptable for smaller regions.

Raster vs. Random Scan

Archit­ectural Trade-offs
Raster Scan
Random Scan
Pixel-­based, uses frame buffer (LCD/OLED displays)
Vector­-based, draws only required lines
Scans entire screen sequen­tially
Stores line endpoints (display list)
Supports shading, textures, complex images
Produces smooth, high-q­uality lines
May have aliasing (jagged edges)
Limited to wireframe images
Requires continuous refresh
Limited by number of vectors per refresh
Real-time 3D / Gaming, Medical Imaging
It cannot effici­ently render complex, filled, or contin­uou­s-tone images (only simple line drawings)
Rendering Comple­xity: Raster: Highly suitable; Random: Not suitable (only wirefr­ames)
Intera­cti­vity: Raster: Good (because of GPU accele­rat­ion); Random: Poor for complex models
Cost-e­ffe­cti­veness: Raster: Low cost; Random: High cost (requires specia­lized hardware)

Jagged lines

Causes
Discrete Sampling - Continuous lines mapped to pixel grid → stair-step effect
Nyquist Violation - Sampling rate too low → high-f­req­uency details lost
Binary Pixel Coverage - Pixel is either fully ON/OFF, no partial coverage → sharp edges
Solution - Supers­amp­ling:
Render at higher resolu­tion, then scaled down after sampling.
The system takes multiple samples within each pixel, rather than just one in the center, to calculate the accurate color of that pixel (Cause 3)

fig. 1

fig. 2