CFLib.org – Common Function Library Project

reverseColor(startingColor)

Last updated November 18, 2003

author

Matt Liotta

Version: 1 | Requires: CF5 | Library: UtilityLib

Description:
Returns the opposite of a color.

Return Values:
Returns a string.

Example:

<cfoutput>#reverseColor("ffee22")#</cfoutput>

Parameters:

Name Description Required
startingColor RGB value minus the #. Yes

Full UDF Source:

/**
 * Returns the opposite of a color.
 * 
 * @param startingColor 	 RGB value minus the #. (Required)
 * @return Returns a string. 
 * @author Matt Liotta (mliotta@r337.com) 
 * @version 1, November 18, 2003 
 */
function reverseColor(startingColor) {
	var start = InputBaseN(startingColor, 16);
	var red = InputBaseN("FF", 16);
	var green = InputBaseN("FF00", 16);
	var blue = InputBaseN("FF0000", 16);
	var tmp = "";

	invertRed = BitAnd(BitXOR(start, red), red);
	invertGreen = BitAnd(BitXOR(start, green), green);
	invertBlue = BitAnd(BitXOR(start, blue), blue);

	tmp = invertRed + invertGreen + invertBlue;
	tmp = Ucase(FormatBaseN(tmp, 16));
	if(len(tmp) is 4) tmp = "00" & tmp;

	return tmp;
}
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