Chapter 12 Drawing Graphics

Some theoretical discussions of computer graphics assume that you are supplied with only two graphics primitives—a ”write pixel“ routine and a ”read pixel“ routine. In theory, you can do anything you want with these two functions. Drawing a line, for instance, simply requires that you call the ”write pixel“ routine numerous times, adjusting the x- and y- coordinates appropriately.

In reality, you can indeed do anything you want with only ”write pixel“ and ”read pixel“ routines—if you don't mind waiting for the results. It is much more efficient for a graphics system to do line drawing and other complex graphics operations at the level of the device driver, which can have its own optimized code to perform the operations. Moreover, as video display technology becomes more sophisticated, the adapter boards will contain graphics coprocessors that allow the video hardware itself to draw the figures.

But of course, no graphics language would be complete without routines to draw one pixel at a time, and that's where we'll begin. From there we'll proceed to drawing lines, and then we'll tackle bounded areas.