Computer graphics

computer graphics (CG) is the field of creating images and animations using computers. It’s a vast and interdisciplinary field that combines elements of:

Physics: Understanding light, reflection, refraction, and materials is important for realistic rendering.

Mathematics: Linear algebra, calculus, geometry, trigonometry are fundamental for transformations, projections, and lighting calculations.

Computer Science: Data structures, algorithms, software engineering, and programming are essential for implementing graphics systems.

Art: Principles of design, color theory, composition, and aesthetics are crucial for creating visually appealing and effective graphics.

Types of Computer Graphics (Computer graphics)

1. Raster Graphics (Bitmap Graphics)

  • Image made of small dots called pixels.
  • Common for photos , scanned images , digital painting .
  • Quality depends on resolution (DPI,PPI).
  • Editing is pixel-based. (Computer graphics)

Examples: JPEG, PNG, BMP, GIF.

2. Vector Graphics (Computer graphics)

  • Uses mathematics equations to draw shapes (lines, curves, polygons).
  • Scalable without losing quality (infinite zoom possible).
  • Best for logos , illustrations, CAD drawings.
Computer graphics

Examples: SVG, EPS, PDF, AI files.


3. 2D Graphics

  • Deals with flat images (X and Y axis).
  • Used in UI design, simple games, charts, diagram.
  • Includes 2D transformations(Translation, Rotation, Scaling).

Examples: Paintings, cartoons, floor plans.


4. 3D Graphics

  • Represents objects with depth (X, Y, Z axis).
  • Used in games, simulations, 3D modeling, movies.
  • Involves 3D transformations, projections, lighting, shading.

Examples: 3D models, VR/AR apps, 3D animations. (Computer graphics)


5. Interactive Graphics

  • User can interact with graphics in real-time.
  • Common in video games, simulations, design software.
  • Requires fast rendering and user input handling.

Examples: AutoCAD, video games, VR simulations. (Computer graphics)


6. Non-Interactive Graphics (Passive)

  • Graphics are static static; no user interaction.
  • Used in print media, display boards, presentations.

Examples: Printed posters, static images.


Summary Table:

TypeKey Points
Raster GraphicsPixel-based, resolution dependent
Vector GraphicsShape-based, scalable without quality loss
2D GraphicsFlat images (X, Y), simple charts, UI, 2D games
3D GraphicsDepth (X, Y, Z), realistic models, animations
Interactive GraphicsUser can interact (games, CAD, simulations)
Non-Interactive GraphicsStatic visuals without user interaction

1. Frame Buffer

Definition:

A Frame Buffer is a memory area that stores pixel data (color values) to be displayed on the screen. It holds information like:

  • Color of each pixel.
  • Intensity (brightness).
  • Depth (for 3D graphics).

Key Points:

  • Located in RAM or VRAM (Video RAM).
  • Acts as a digital canvas for the computer to draw images.
  • The content of the frame buffer is continuously sent to the display screen.
  • The more bits per pixel (bpp), the better color quality (e.g., 8-bit, 16-bit, 24-bit color).

Example:

  • For a screen of 1920×1080 pixels with 24-bit color depth, the frame buffer stores: (Computer graphics)

2. Video Controller

Definition:

A Video Controller (or Graphics Controller) is a hardware device that:

  • Reads data from the frame buffer.
  • Generates the video signal for the display device (like monitor, LCD, LED)
  • Controls the timing and synchronization of the display.

Functions of Video Controller:

  • Converts pixel data (from frame buffer) into signals.
  • Controls refresh rate (like 60Hz, 120Hz).
  • Manages color output, resolution , and sync signals.
  • Acts as an interface between CPU, GPU, Frame Buffer, and Display Screen.

Components:

  • Display Registers (store current settings like resolution, refresh rate).
  • Digital to Analog Converter (DAC) (for analog displays like CRT monitors).
  • Timing Circuits (for scan control). (Computer graphics)
  • GPU (Graphics Processing Unit) may be part of the video controller in modern systems.

Diagram: Frame Buffer & Video Controller Relationship

+------------------+        +---------------------+        +-----------------+
|                  |        |                     |        |                 |
|   CPU / GPU      | -----> |     Frame Buffer    | -----> |  Video Controller |
|                  |        | (Pixel Data Memory) |        | (Signal Generator) |
+------------------+        +---------------------+        +-----------------+
                                                                     |
                                                                     |
                                                            +-----------------+
                                                            |    Monitor /    |
                                                            |  Display Device |
                                                            +-----------------+

Points and Lines in Computer Graphics
A) Point:

1–A point represents a single pixel on the screen.

2–Defined by its coordinates (x, y) in 2D or (x, y, z) in 3D.

B)Line:

A line is a collection of connected points between two coordinates.

Defined by starting point (x1, y1) and ending point (x2, y2).

Equation of line: y = mx + c, where:

  • m = slope = (y2 – y1) / (x2 – x1)
  • c = y-intercept.

DDA (Digital Differential Analyzer) Algorithm

Definition:

DDA is an incremental scan-conversion algorithm. It calculates pixel positions along a line by incrementing one coordinate and calculating the other. (Computer graphics)

Algorithm Steps (DDA-1):

  1. Calculate differences:
    dx = x2 – x1,
    dy = y2 – y1.
  2. Calculate steps:
    steps = max(|dx|, |dy|).
  3. Calculate increments:
    Xinc = dx / steps,
    Yinc = dy / steps.
  4. Initialize starting point:
    (X = x1, Y = y1).
  5. For each step:
    • Plot (round(X), round(Y)).
    • Update X = X + Xinc.
    • Update Y = Y + Yinc.

Example (DDA-2):

For line from (2, 3) to (10, 8):

  • dx = 8, dy = 5.
  • steps = 8.
  • Xinc = 1, Yinc = 0.625.
  • Start plotting from (2, 3), increment X and Y for each step.

Bresenham’s Line Drawing Algorithm

Definition:

Bresenham’s algorithm is an efficient line drawing algorithms that uses only integer calculations (no floating points).

Algorithm Steps (Bresenham-1):

  1. Calculate dx = x2 – x1, dy = y2 – y1.
  2. Initialize decision parameter:
    p = 2dy – dx.
  3. For every x from x1 to x2:
    • Plot (x, y).
    • If p < 0, next pixel is (x+1, y), update p = p + 2dy.
    • Else, next pixel is (x+1, y+1), update p = p + 2dy – 2dx.

Example (Bresenham-2):

For line from (2, 2) to (7, 5):

  • dx = 5, dy = 3.
  • Initial p = 2dy – dx = 2*3 – 5 = 1.
  • Plot pixels step by step using p values.

Midpoint Circle Drawing Algorithm

Definition:

An efficient method to draw a circle by calculating pixel positions in one octant and reflecting them to other parts of the circle.

Formula & Steps (Midpoint Circle-1):

  1. Start at (x = 0, y = r).
  2. Initial decision parameter:
    p = 1 – r.
  3. For each x from 0 to y:
    • Plot symmetric points in 8 octants.
    • If p < 0:
      • Next point is (x+1, y).
      • p = p + 2x + 3.
    • Else:
      • Next point is (x+1, y-1).
      • p = p + 2x – 2y + 5.

Example with Definition (Midpoint Circle-2):

  • For a circle of radius r = 5.
  • Start with (0, 5).
  • Compute p = 1 – 5 = -4.
  • Plot points and update p for each step.
  • Reflect points in all 8 symmetrical positions.

Summary Table

AlgorithmKey Points
DDA AlgorithmUses floating point increments, simple but slower due to real number calculations.
Bresenham’s AlgorithmUses only integer operations, faster and efficient for raster devices.
Midpoint Circle AlgorithmEfficiently plots circle points using symmetry and integer calculations.

also read this :- Introduction to Operating System (OS)

Similar Posts