CFLib.org – Common Function Library Project

HexToRGB(hexColor)

Last updated November 6, 2001

author

Eric Carlisle

Version: 1 | Requires: CF5 | Library: UtilityLib

Description:
HexToRGB is the opposite of RGBtoHex. HexToRGB converts a 6 character hexadecimal color value into an RGB list (rr,gg,bb).

Return Values:
Returns a string.

Example:

<CFSET Color="33ccff">
<cfoutput>
The RGB values for #Color# are: #HextoRGB(Color)#
</cfoutput>

Parameters:

Name Description Required
hexColor 6 character hexadecimal color value. Yes

Full UDF Source:

/**
 * Convert a hexadecimal color into a RGB color value.
 * 
 * @param hexColor 	 6 character hexadecimal color value. 
 * @return Returns a string. 
 * @author Eric Carlisle (ericc@nc.rr.com) 
 * @version 1.0, November 6, 2001 
 */
function HexToRGB(hexColor){
  /* Strip out poundsigns. */
  Var tHexColor = replace(hexColor,'##','','ALL');
	
  /* Establish vairable for RGB color. */
  Var RGBlist='';
  Var RGPpart='';	

  /* Initialize i */
  Var i=0;

  /* Loop through each hex triplet */
  for (i=1; i lte 5; i=i+2){
    RGBpart = InputBaseN(mid(tHexColor,i,2),16);
    RGBlist = listAppend(RGBlist,RGBpart);
  }
  return RGBlist;
}
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson