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   Win16 executable

   C.ZIP         C/C++ source code files
   BUILDER.ZIP   C++Builder source code files
   DELPHI.ZIP    Delphi source code files
   BASIC.ZIP     Visual Basic source code files
   PASCAL.ZIP    Pascal source code files
   FORTRAN.ZIP   Fortran source code files

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 each programming
language. 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)

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