Author Topic: Decimal to Hexidecimal  (Read 435 times)

I need to convert 3-point decimal colors (i.e. "1 0 0") to hexadecimal. I have no idea how to do this and I've tried several sites that all have formulas that I don't know how to perform in torque. Don't link to some website with a javascript converter on it, I need actual conversion to be taking place in the script.


Don't link to some website with a javascript converter on it, I need actual conversion to be taking place in the script.

Learn to read

Look through TDM Support_Gamemodes.cs, pretty sure I noticed a function Space Guy made that does it.
EDIT:
Code: [Select]
function RGBToHEX(%col) //In the form of R G B 0-1
{
%red = (getWord(%col,0)*255);
%r = getSubStr("0123456789ABCDEF",(%red - (%red % 16))/16,1) @ getSubStr("0123456789ABCDEF",(%red % 16),1);

%green = (getWord(%col,1)*255);
%g = getSubStr("0123456789ABCDEF",(%green - (%green % 16))/16,1) @ getSubStr("0123456789ABCDEF",(%green % 16),1);

%blue = (getWord(%col,2)*255);
%b = getSubStr("0123456789ABCDEF",(%blue - (%blue % 16))/16,1) @ getSubStr("0123456789ABCDEF",(%blue % 16),1);

return %r @ %g @ %b;
}
« Last Edit: December 14, 2009, 07:57:33 PM by Destiny/Zack0Wack0 »