Overview

This course is mainly about how to generate graphics in a computer display. So it focuses on some graphic generation algorithms.

Such as:

  • Straight Line Generation Algorithm: like DDA Algorithm
  • Character Generation: Dot Matrix, Vector
  • Area filling algorithm: Seed Filling and Scan Line Filling

一、Straight Line Generation Algorithm

The most basic two-dimensional graphic is a straight line.

It is a collection of points, and the display is composed of pixels.

Therefore, the process of drawing a line is to determine which pixel the point is on.

1) DDA Digital Differential Analyzer

The idea of the DDA algorithm is to determine a group of pixels that are closest to the straight line.

计算机图形学 Computer Graphics_ide

Steps:

  • Calculate slope \(k\) of the line
  • \(Xi = X_{i-1}+1,Yi=Y_{i-1}+k\)
  • \((Xi,Yi)=(Xi,round(Yi))\)

According to the value of slope, the calculation may be different.

2) Bresenham Algorithm

You see, in DDA algorithm, data type must be float, and the result must be rounded at each step. which is time-wasting.

Bresenham Algorithm doesn't have that problem.

But it's complicated, I don't remember the specific process of it.

二、Character Generation

We also want the computer to display the characters we use.

We can use dot matrix or vector.

1) Dot Matrix

Each character is defined as a matrix called a mask.

With Dot Matrix, we can store some beautiful fonts.

计算机图形学 Computer Graphics_git_02

The larger the dot matrix, the clearer the characters

2) Vector Character

Think of a character as a graphic, and use a sequence of point coordinates to represent a character. Two adjacent points represent a vector.

计算机图形学 Computer Graphics_analyzer_03

三、Area Filling Algorithm

We use the area filling algorithm to color the graphics.

Commonly used area filling algorithms include seed filling algorithm and scan line filling algorithm.

1) Seed Filling

Choose a point inside the graphic as a seed, then recursively color the point and change the seed until it reaches the boundary.

计算机图形学 Computer Graphics_sed_04

2) Scan Line Filling

We can use the continuity of the scan line to fill in the segment of each scan line that is located inside the polygon.

To do this, we need to calculate the intersection of the scan line and the polygon, and sort the intersections, and fill in the line segments between every two intersections.

计算机图形学 Computer Graphics_git_05

In this algorithm, we use the edge table ET to represent a polygon.

计算机图形学 Computer Graphics_git_06