The basics

When programming with graphics in any computer language, there are certain basic ideas which are common to all contexts. This tutorial page will tell you how to do simple drawing in general, because each computer language and operating system has different methods of actually doing the drawing. If you've never done graphics programming before, this is a good place to begin.

The screen

Computer graphics use a different coordinate system than you were taught in mathematics courses. Instead of the bottom left being the point (0,0), the top left represents that point. Especially when you first begin to do graphics programming, this can be confusing. One solution, if you like the "normal" system better is to write a simple function which will convert the coordinates. Depending on the language, this can be done with two functions, or one function (especially easy if you use pointers in C/C++).

Colors

If you want to draw anything that looks remotely nice, however, colors are important. In general, colors are either specified using indexed color or a color system such as RGB. Once again, the specifics depend on the language and OS. Briefly, indexed color means that there is an enumerated index of all the available colors and the graphics call that changes the color specifies one of these. For example, you might have 16 colors available, and the individual numbers could correspond to system defined colors. One might be red, and two might be orange.
With the Red-Green-Blue system, however, colors are specified according to their separate values for each of these colors. In order to create a new color, the colors of light are blended. If all colors of light are blended, the result is white. No intensity for each color, predictably, give you black. Using this method, or a similar one, all colors can be created. The limiting factors, however, are the display, video card, and also the number of bits each color is represented with.
Return to the main page.