mixster

mixster

Feb 10th, 2009
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 0.49 KB | None | 0 0
  1. program ColorToHex;
  2. const
  3.   c = clYellow;
  4.  
  5. var
  6.   r, g, b: Integer;
  7.  
  8. function Hex(num: Integer): string;
  9. var
  10.   i: Integer;
  11. begin
  12.   Result := '00';
  13.   i := num div 16;
  14.   if i < 10 then
  15.     Result[1] := Chr(Ord('0') + i)
  16.   else
  17.     Result[1] := Chr(Ord('A') + (i - 10));
  18.   i := num mod 16;
  19.   if i < 10 then
  20.     Result[2] := Chr(Ord('0') + i)
  21.   else
  22.     Result[2] := Chr(Ord('A') + (i - 10));
  23. end;
  24.  
  25. begin
  26.   ColortoRGB(c, r, g, b);
  27.   Writeln(Hex(r) + Hex(g) + Hex(b));
  28. end.
Add Comment
Please, Sign In to add comment