PdfConverter/utils/TSColorToolKit.tsf

24 lines
560 B
Plaintext

unit TSColorToolKit;
interface
function HexToRGB(hex);
implementation
function HexToRGB(hex);
begin
hex_string := ifnumber(hex) ? format("%x", hex) : hex;
if length(hex_string) = 7 then
begin
if hex_string[1] <> "#" then raise "Invalid hexadecimal parameter.";
hex_string := hex_string[1:];
end
if length(hex_string) <> 6 then raise "Invalid hexadecimal parameter";
r := eval(&"return 0x" + hex_string[1:2]);
g := eval(&"return 0x" + hex_string[3:4]);
b := eval(&"return 0x" + hex_string[5:6]);
return array(r, g, b);
end;
end.