Game Development Reference
In-Depth Information
pixel in the upper left-hand corner. A screen with 1024 × 768 resolution
would have the (1023,767) pixel in the bottom right-hand corner. The
highest value pixel has x and y values that are one minus the width and
height, respectively, because the smallest pixel location is referenced as
(0,0). It is also possible to change the default layout depending on the
application being used such that the y values of the pixels are flipped
with (0,0) being in the lower left-hand corner or even moved into the
center of the screen.
1.3.2 Line
On paper, a line is created by the stroke of a pen or brush. It can also
define the boundary where two shapes meet. A line on a digital display is
created by coloring pixels on the screen between two pixel coordinates.
Given the points at the ends of a line, an algorithm calculates the pixel
values that must be colored in to create a straight line. This isn't as
straightforward as it sounds because the pixels can only have whole
number coordinate values. The Bresenham line algorithm was developed
by Jack E. Bresenham in 1962 to effectively calculate the best pixels to
color in to give the appearance of a line. Therefore, the line that appears
on a digital display can only ever be an approximation to the real line as
shown in Figure 1.7 .
Fig 1.7 A real line and a Bresenham
Vector Line
Search Nedrilad ::

Custom Search