The SDL Component Suite is an industry leading collection of components supporting scientific and engineering computing. Please visit the SDL Web site for more information....



FillByInterpolation


Unit: SDL_sdlcolors
Class: TColorArray
Declaration: procedure FillByInterpolation (DiscreteLevels: integer; Colors: array of TColor); {Pascal}
void __fastcall FillByInterpolation(int DiscreteLevels, const Graphics::TColor * Colors, const int Colors_Size); {C++}

The method FillByInterpolation allows to generate an array of colors. The basic idea is to use n pivot colors which are regularly spaced across the entire array (the first pivot color is always at index 1, the last is always the last color of the array). The colors between the pivot colors are calculated by linear interpolation. The parameter Colors is an open array of any number of pivot colors which are to be used for the calculation of the color array.

The parameter DiscreteLevels determines how many color shades are generated. Setting DiscreteLevels to zero generates continuous colors, any positive value results in the corresponding number of shades. This can be used to generate color scales typically used in geographic maps. The following image shows the effect of the parameter DiscreteLevels.

Hint: The declaration of FillByInterpolation in C++ slightly differs from the Pascal declaration (note the extra parameter Colors_Size which specifies the highest index of the color array):
void __fastcall FillByInterpolation(int DiscreteLevels, const Graphics::TColor * Colors, const int Colors_Size);

Example: The following statement creates the color array shown below (upper trace):

MyColorArray1.FillByInterpolation (0, [clRed, clBlue, $00999900, clYellow]);

Setting the DiscreteLevels parameter to 8 results in the color array showing nine shades (eight borders between nine color ranges)

Example: This method is used in the following example program (see http://www.lohninger.com/examples.html for downloading the code): contplot



Last Update: 2015-May-11