/*
   ===========================================================================
   This function computes the RGB composite color value from the RGB values.

   INPUT: 8-bit Decimal RGB color code values.
   R = Red value    (0 to 255)
   G = Green value  (0 to 255)
   B = Blue value   (0 to 255)

   each color has 256 levels of intensity ranging from 0 = min to 255 = max
   Considering each of the 256 levels a distinct color and there are 3
   primary colors, then the total number of colors equates to 16777216
   with a unique sequential composite color code for each RGB color
   combination ranging from 0 to 16777215.

   each color has 256 = (2^8) levels and there are 3 primary colors.  This
   gives a total of

   Total colors = (Color Levels)^(Primary Colors)
   = (2^8)^3 = 2^(3*8) = 2^24
   = 16777216 colors

// ----------------------------------------------------------------------
   Given the RGB values, the composite color code (C) in
   the range from 0 to 16777215 can be computed by:

   C = 65536*R + 256*G + B

   -----------------------------------------------------
   Given the composite color code (C), the corresponding
   decimal RGB values can be extracted by:

   R = floor(C / 65536)
   B = C mod 256
   G = floor((C - 65536*R - B) / 256)

   ERRORS:
   Returns FALSE if any of the RGB values are non-numeric.

   NO DEPENDENCIES
   ===========================================================================
*/

   function RGB_to_Composite ($R,$G,$B)
{
// Read RGB values and filter for errors.
   $R = trim($R);
   $G = trim($G);
   $B = trim($B);

   if (!Is_Numeric($R) or !Is_Numeric($G) or !Is_Numeric($B))
      {return FALSE;}

// Compute composite color value from RGB values.
   return 65536*$R + 256*$G + $B;
}