The Fastgraph for Windows RAINBOW program
-----------------------------------------

The RAINBOW program demonstrates color cycling with Fastgraph for Windows.
Color cycling is the process of rapidly changing an object's colors to
achieve the illusion of smooth movement. It is often used in games to animate
waterfalls, lava, or torches in a cyclic manner. The beauty of color cycling
is that we achieve this motion simply by changing the colors in a logical
palette. Once we draw the object itself, we never modify the pixels
comprising the object. However, we must be careful not to use the colors
being cycled outside the desired object(s), or we'll see undesirable color
changes as we perform the color cycling.

The files in the RAINBOW distribution are:

   RAINBOW.TXT   this file (ASCII text format)
   RAINBOW.WRI   this file (Windows Write 3.1 format)
   RAINBOW.EXE   16-bit Windows executable

   RAINBOW.C     C source code
   RAINBOW.PAS   Pascal source code

   RAINBOW.FRM   Visual Basic 4.0 source code
   RAINBOW.VBP   Visual Basic 4.0 project file

   RAINBOW.DPR   Delphi project file
   RAINBOW.RES   Delphi resource file
   RAINBOWU.PAS  Delphi source code unit
   RAINBOWU.FRM  Delphi graphical form file

How the program works
---------------------

The RAINBOW program demonstrates color cycling within a 24-color rainbow (the
rainbow uses colors 10 to 33). The key lies in the RGBvalues array, which is
large enough to hold two sets of 24 RGB triples. The function
fill_color_palette() fills the first half of this array with the initial
color components for colors 10 to 33 and then duplicates these same values in
the second half of the array. We initially define a logical palette for
colors 10 to 33 using the RGB values in the first half of RGBvalues.
Following this, we use fg_ellipsef() to draw a rainbow of consecutive-color
bands, with color 10 at the outside and color 33 the innermost color.

The actual color cycling occurs with the help of a Windows timer. We set up
the timer to generate a timer event at 50 millisecond intervals (you cannot
rely on this being an exact time, but for our purposes it will be more than
adequate). The method of setting up the timer differs for C, Pascal, Delphi,
and Visual Basic. In all cases, however, the timer events pass control to a
specific message handler or function in the RAINBOW program. Each time this
handler executes, we point start to the next RGB triple in RGBvalues, going
back to the start of the array if needed. We then define new values for
colors 10 to 33 beginning with the RGB triple pointed to by start. For all
but color 10, this makes fg_setdacs() use some color values from the second
half of the RGBvalues array, effectively simulating a "wrap" to the start of
RGBvalues that would otherwise require two fg_setdacs() calls. If we're using
a high color or true color display driver, we call fg_vbscale() to blit the
image after each color change because these color modes are not
palette-based.

For more information about Fastgraph for Windows, contact:
----------------------------------------------------------

Ted Gruber Software
P.O. Box 13408
Las Vegas, NV  89112

(702) 735-1980 (voice)
(702) 735-4603 (fax)
(702) 796-7134 (bbs)

email: fastgraph@aol.com
ftp: ftp.accessnv.com\fg\Windows
web: http://www.fastgraph.com
